From 9efb32e5ccce96eca6aed99c413fed419da72590 Mon Sep 17 00:00:00 2001 From: Elon Date: Wed, 10 Apr 2019 13:19:58 -0600 Subject: [PATCH] mergeing elonsTest with renderableSatellites --- .../earth/satellites/satellites_shared.asset | 32 +++---- modules/space/rendering/elonstest.h | 1 + .../space/rendering/renderablesatellites.cpp | 85 +++++++++---------- .../space/rendering/renderablesatellites.h | 15 ++-- modules/space/shaders/debrisViz_fs.glsl | 40 +++++++++ modules/space/shaders/debrisViz_vs.glsl | 48 +++++++++++ modules/space/spacemodule.cpp | 2 - .../space/translation/keplertranslation.cpp | 19 ----- modules/space/translation/keplertranslation.h | 5 +- 9 files changed, 150 insertions(+), 97 deletions(-) create mode 100644 modules/space/shaders/debrisViz_fs.glsl create mode 100644 modules/space/shaders/debrisViz_vs.glsl diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_shared.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_shared.asset index 232debb883..3b2cd2eca5 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_shared.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_shared.asset @@ -49,31 +49,25 @@ local addSatelliteGroupObjects = function(group, tleFolder, shouldAddDuplicates) return true end - function test(title, file) + function debris(title, file) return { Identifier = title, Parent = transforms.EarthInertial.Identifier, Renderable = { Type = "RenderableSatellites", - --Type = "ElonsTest", - - --Translation = { - --- Type = "TLETranslation", --- Body = title, --- Observer = transforms.EarthInertial.Identifier, --- File = file --- }, Path = file, - Segments = 1, - EccentricityColumn = "bubbis", - SemiMajorAxisColumn = "bubbis", + + -- The initialization with "-" is just a placeholder. + -- (needed to be initialized) + Segments = 160, + EccentricityColumn = "-", + SemiMajorAxisColumn = "-", SemiMajorAxisUnit = 1, - InclinationColumn = "bubbis", - AscendingNodeColumn = "bubbis", - ArgumentOfPeriapsisColumn = "bubbis", - MeanAnomalyAtEpochColumn = "bubbis", - EpochColumn = "bubbis", + InclinationColumn = "-", + AscendingNodeColumn = "-", + ArgumentOfPeriapsisColumn = "-", + MeanAnomalyAtEpochColumn = "-", + EpochColumn = "-", }, GUI = { @@ -82,7 +76,7 @@ local addSatelliteGroupObjects = function(group, tleFolder, shouldAddDuplicates) } end - local Debris = test(filenameSansExt, path) + local Debris = debris(filenameSansExt, path) assetHelper.registerSceneGraphNodesAndExport(asset, { Debris }) -- asset.export("satImageFolder", satImageFolder) diff --git a/modules/space/rendering/elonstest.h b/modules/space/rendering/elonstest.h index e5b33ec85f..874c457b0b 100644 --- a/modules/space/rendering/elonstest.h +++ b/modules/space/rendering/elonstest.h @@ -130,4 +130,5 @@ private: } // namespace openspace #endif // __OPENSPACE_MODULE_SPACE___ELONSTEST___H__ + */ diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index d446413bc5..cfa7d7a6c5 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -439,14 +439,14 @@ RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary) addProperty(_nSegments); addProperty(_semiMajorAxisUnit); +<<<<<<< HEAD +======= +>>>>>>> mergeing elonsTest with renderableSatellites LINFO(fmt::format("KeyFile: {} ", KeyFile)); const std::string& file = dictionary.value(KeyFile); LINFO(fmt::format("file: {} ", file)); - //readTLEFile(file); - - } @@ -560,8 +560,7 @@ void RenderableSatellites::readTLEFile(const std::string& filename) { _TLEData.push_back(keplerElements); - } // !while loop - + } // !for loop file.close(); } /* @@ -603,18 +602,18 @@ void RenderableSatellites::initializeGL() { []() -> std::unique_ptr { return global::renderEngine.buildRenderProgram( ProgramName, - absPath("${MODULE_SPACE}/shaders/RenderableKeplerOrbits_vs.glsl"), - absPath("${MODULE_SPACE}/shaders/RenderableKeplerOrbits_fs.glsl") + absPath("${MODULE_SPACE}/shaders/debrisViz_vs.glsl"), + absPath("${MODULE_SPACE}/shaders/debrisViz_fs.glsl") ); } ); - _uniformCache.opacity = _programObject->uniformLocation("opacity"); - _uniformCache.modelView = _programObject->uniformLocation("modelViewTransform"); - _uniformCache.projection = _programObject->uniformLocation("projectionTransform"); - _uniformCache.color = _programObject->uniformLocation("color"); - _uniformCache.useLineFade = _programObject->uniformLocation("useLineFade"); - _uniformCache.lineFade = _programObject->uniformLocation("lineFade"); +// _uniformCache.opacity = _programObject->uniformLocation("opacity"); +// _uniformCache.modelView = _programObject->uniformLocation("modelViewTransform"); +// _uniformCache.projection = _programObject->uniformLocation("projectionTransform"); +// _uniformCache.color = _programObject->uniformLocation("color"); +// _uniformCache.useLineFade = _programObject->uniformLocation("useLineFade"); +// _uniformCache.lineFade = _programObject->uniformLocation("lineFade"); setRenderBin(Renderable::RenderBin::Overlay); @@ -624,9 +623,9 @@ void RenderableSatellites::deinitializeGL() { SpaceModule::ProgramObjectManager.release(ProgramName); - glDeleteBuffers(1, &_vertexBuffer); - glDeleteBuffers(1, &_indexBuffer); - glDeleteVertexArrays(1, &_vertexArray); + // glDeleteBuffers(1, &_vertexBuffer); + // glDeleteBuffers(1, &_indexBuffer); + // glDeleteVertexArrays(1, &_vertexArray); } @@ -639,37 +638,37 @@ bool RenderableSatellites::isReady() const { void RenderableSatellites::update(const UpdateData&) {} void RenderableSatellites::render(const RenderData& data, RendererTasks&) { - _programObject->activate(); - _programObject->setUniform(_uniformCache.opacity, _opacity); + // _programObject->activate(); + // _programObject->setUniform(_uniformCache.opacity, _opacity); - glm::dmat4 modelTransform = - glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * - glm::dmat4(data.modelTransform.rotation) * - glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); + // glm::dmat4 modelTransform = + // glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * + // glm::dmat4(data.modelTransform.rotation) * + // glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); - _programObject->setUniform( - _uniformCache.modelView, - data.camera.combinedViewMatrix() * modelTransform - ); + // _programObject->setUniform( + // _uniformCache.modelView, + // data.camera.combinedViewMatrix() * modelTransform + // ); - _programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix()); - _programObject->setUniform(_uniformCache.color, _appearance.lineColor); - _programObject->setUniform(_uniformCache.useLineFade, _appearance.useLineFade); + // _programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix()); + // _programObject->setUniform(_uniformCache.color, _appearance.lineColor); + //_programObject->setUniform(_uniformCache.useLineFade, _appearance.useLineFade); if (_appearance.useLineFade) { _programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade); } - glDepthMask(false); - //glBlendFunc(GL_SRC_ALPHA, GL_ONE); + // glDepthMask(false); + // //glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glBindVertexArray(_vertexArray); - glDrawElements(GL_LINES, - static_cast(_indexBufferData.size()), - GL_UNSIGNED_INT, - 0); - glBindVertexArray(0); - _programObject->deactivate(); + // glBindVertexArray(_vertexArray); + // glDrawElements(GL_LINES, + // static_cast(_indexBufferData.size()), + // GL_UNSIGNED_INT, + // 0); + // glBindVertexArray(0); + // _programObject->deactivate(); } void RenderableSatellites::updateBuffers() { @@ -681,7 +680,7 @@ void RenderableSatellites::updateBuffers() { size_t elementindex = 0; for (const auto& orbit : _TLEData) { - + _keplerTranslator.setKeplerElements( orbit.eccentricity, orbit.semiMajorAxis, @@ -698,9 +697,9 @@ void RenderableSatellites::updateBuffers() { float timeOffset = orbit.period * static_cast(i) / static_cast(_nSegments); - - glm::vec3 position = _keplerTranslator.debrisPos(Time(orbit.epoch + timeOffset)); - + + glm::vec3 position = _keplerTranslator.debrisPos(Time(orbit.epoch + timeOffset)); + _vertexBufferData[index].x = position.x; _vertexBufferData[index].y = position.y; _vertexBufferData[index].z = position.z; @@ -730,7 +729,7 @@ void RenderableSatellites::updateBuffers() { GL_STATIC_DRAW ); - glBindVertexArray(0); + // glBindVertexArray(0); } diff --git a/modules/space/rendering/renderablesatellites.h b/modules/space/rendering/renderablesatellites.h index d3623544cd..cdfe3b6dd4 100644 --- a/modules/space/rendering/renderablesatellites.h +++ b/modules/space/rendering/renderablesatellites.h @@ -22,20 +22,20 @@ // * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * // ****************************************************************************************/ +#ifndef __OPENSPACE_MODULE_BASE___RenderableSatellites___H__ +#define __OPENSPACE_MODULE_BASE___RenderableSatellites___H__ + #include #include #include -// #include #include #include #include #include -#ifndef __OPENSPACE_MODULE_BASE___RenderableSatellites___H__ -#define __OPENSPACE_MODULE_BASE___RenderableSatellites___H__ namespace openspace { @@ -54,7 +54,6 @@ namespace openspace { class RenderableSatellites : public Renderable { public: RenderableSatellites(const ghoul::Dictionary& dictionary); - //virtual ~RenderableSatellites(); void initialize() override; void deinitialize() override; @@ -89,13 +88,9 @@ namespace openspace { GLuint _vertexBuffer; GLuint _indexBuffer; - void readFromCsvFile(); void updateBuffers(); - std::vector _orbits; ghoul::opengl::ProgramObject* _programObject; - //ghoul::ObjectManager* _objectManager; - properties::StringProperty _path; properties::UIntProperty _nSegments; @@ -111,8 +106,8 @@ namespace openspace { RenderableTrail::Appearance _appearance; - UniformCache(opacity, modelView, projection, color, useLineFade, lineFade) - _uniformCache; + //UniformCache(opacity, modelView, projection, color, useLineFade, lineFade) + // _uniformCache; /** * Reads the provided TLE file and calles the KeplerTranslation::setKeplerElments diff --git a/modules/space/shaders/debrisViz_fs.glsl b/modules/space/shaders/debrisViz_fs.glsl new file mode 100644 index 0000000000..5915e3e6f5 --- /dev/null +++ b/modules/space/shaders/debrisViz_fs.glsl @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +in vec3 vs_position; +in vec3 vs_color; +in vec2 vs_texcoord; + +out vec4 fs_color; + +void main { + fs_color = vec4(vs_color, 1.f); +} + + + + + + + diff --git a/modules/space/shaders/debrisViz_vs.glsl b/modules/space/shaders/debrisViz_vs.glsl new file mode 100644 index 0000000000..2baedc67ae --- /dev/null +++ b/modules/space/shaders/debrisViz_vs.glsl @@ -0,0 +1,48 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#version __CONTEXT__ + +layout (location = 0) in vec3 vertex_position; +layout (location = 1) in vec3 vertex_color; +layout (location = 2) in vec2 vertex_texcoord; + +out vec3 vs_position; +out vec3 vs_color; +out vec2 vs_texcoord; + +void main() { + vs_position = vertex_position; + vs_color = vertex_color; + vs_texcoord - vec2(vertex_texcoord.x, vertex_texcoord.y); + + gl_Position = vec4(vertex_position, 1.f); +} + + + + + + + diff --git a/modules/space/spacemodule.cpp b/modules/space/spacemodule.cpp index 12a91b6eed..d52212073e 100644 --- a/modules/space/spacemodule.cpp +++ b/modules/space/spacemodule.cpp @@ -86,7 +86,6 @@ void SpaceModule::internalInitialize(const ghoul::Dictionary&) { fRenderable->registerClass("RenderableRings"); fRenderable->registerClass("RenderableStars"); fRenderable->registerClass("RenderableSatellites"); - //fRenderable->registerClass("ElonsTest"); auto fTranslation = FactoryManager::ref().factory(); @@ -118,7 +117,6 @@ std::vector SpaceModule::documentations() const { RenderableRings::Documentation(), RenderableStars::Documentation(), RenderableSatellites::Documentation(), - //ElonsTest::Documentation(), SpiceRotation::Documentation(), SpiceTranslation::Documentation(), KeplerTranslation::Documentation(), diff --git a/modules/space/translation/keplertranslation.cpp b/modules/space/translation/keplertranslation.cpp index 0850e2b584..5acadc818a 100644 --- a/modules/space/translation/keplertranslation.cpp +++ b/modules/space/translation/keplertranslation.cpp @@ -283,25 +283,6 @@ double KeplerTranslation::eccentricAnomaly(double meanAnomaly) const { return 0.0; } } -glm::dvec3 KeplerTranslation::position(const Time& time) const { - if (_orbitPlaneDirty) { - computeOrbitPlane(); - _orbitPlaneDirty = false; - } - - const double t = time.j2000Seconds() - _epoch; - const double meanMotion = glm::two_pi() / _period; - const double meanAnomaly = glm::radians(_meanAnomalyAtEpoch.value()) + t * meanMotion; - const double e = eccentricAnomaly(meanAnomaly); - - // Use the eccentric anomaly to compute the actual location - const glm::dvec3 p = { - _semiMajorAxis * 1000.0 * (cos(e) - _eccentricity), - _semiMajorAxis * 1000.0 * sin(e) * sqrt(1.0 - _eccentricity * _eccentricity), - 0.0 - }; - return _orbitPlaneRotation * p; -} glm::dvec3 KeplerTranslation::position(const UpdateData& data) const { if (_orbitPlaneDirty) { diff --git a/modules/space/translation/keplertranslation.h b/modules/space/translation/keplertranslation.h index aa2b582f83..a6120b2ebc 100644 --- a/modules/space/translation/keplertranslation.h +++ b/modules/space/translation/keplertranslation.h @@ -88,12 +88,9 @@ public: * * \param time The time to use when doing the position lookup */ - glm::dvec3 position(const Time& time) const ; glm::dvec3 position(const UpdateData& data) const override; - // Is only used in renderableDebris so far - // glm::dvec3 position(const Time& time) const; - + // Is only used in renderableDebris so far. May rename if needed glm::dvec3 debrisPos(const Time& time) const;