From 9aefc203a3483337a8ae03e8455088ed5edd2263 Mon Sep 17 00:00:00 2001 From: Agnes Heppich Date: Mon, 12 Nov 2018 17:30:33 -0500 Subject: [PATCH 1/3] ra dec translation --- data/assets/dsn.scene | 1 + .../scene/solarsystem/dsn/spacecrafts.asset | 36 +++++++++++ modules/dsn/rendering/renderablesignals.cpp | 61 +++++++------------ modules/dsn/rendering/renderablesignals.h | 11 +--- modules/dsn/translation/radectranslation.cpp | 44 +++++++++++-- modules/dsn/translation/radectranslation.h | 18 +++++- 6 files changed, 115 insertions(+), 56 deletions(-) create mode 100644 data/assets/scene/solarsystem/dsn/spacecrafts.asset diff --git a/data/assets/dsn.scene b/data/assets/dsn.scene index 075d71ad1a..05d7f00247 100644 --- a/data/assets/dsn.scene +++ b/data/assets/dsn.scene @@ -21,6 +21,7 @@ asset.require('scene/solarsystem/dsn/stations') --Communication --assetHelper.requestAll(asset, 'scene/solarsystem/dsn') asset.require('scene/solarsystem/dsn/communicationlines/communicationlines') +asset.require('scene/solarsystem/dsn/spacecrafts') -- Load default key bindings applicable to most scenes asset.require('util/default_keybindings') diff --git a/data/assets/scene/solarsystem/dsn/spacecrafts.asset b/data/assets/scene/solarsystem/dsn/spacecrafts.asset new file mode 100644 index 0000000000..5e60bcbf52 --- /dev/null +++ b/data/assets/scene/solarsystem/dsn/spacecrafts.asset @@ -0,0 +1,36 @@ +local assetHelper = asset.require('util/asset_helper') + +local models = asset.syncedResource({ + Name = "Dsn models", + Type = "HttpSynchronization", + Identifier = "dsn_stations", + Version = 1 +}) + +local testSpaceCraft = { + Identifier = "testSpaceCraft", + Transform = { + Translation = { + Type = "RadecTranslation" + }, + Scale = { + Type = "StaticScale", + Scale = 1000.0 + } + + }, + Renderable = { + Type = "RenderableModel", + Geometry = { + Type = "MultiModelGeometry", + GeometryFile = models .. "/34m_dish/34m_dish.obj" + }, + ColorTexture = models .. "/34m_dish/base_AO.png", + }, + GUI = { + Name = "testSpaceCraft", + Path = "/Solar System/testSpaceCraft" + } +} + +assetHelper.registerSceneGraphNodesAndExport(asset, {testSpaceCraft}) \ No newline at end of file diff --git a/modules/dsn/rendering/renderablesignals.cpp b/modules/dsn/rendering/renderablesignals.cpp index b8493b862a..80c4dc1b51 100644 --- a/modules/dsn/rendering/renderablesignals.cpp +++ b/modules/dsn/rendering/renderablesignals.cpp @@ -390,8 +390,29 @@ void RenderableSignals::pushSignalDataToVertexArray(SignalManager::Signal signal _vertexArray.push_back(color.b); _vertexArray.push_back(color.a); -} + //For testing + glm::vec3 worldTestPos = getSuitablePrecisionPositionForSceneGraphNode("testSpaceCraft"); + + _vertexArray.push_back(posStation.x); + _vertexArray.push_back(posStation.y); + _vertexArray.push_back(posStation.z); + + _vertexArray.push_back(color.r); + _vertexArray.push_back(color.g); + _vertexArray.push_back(color.b); + _vertexArray.push_back(color.a); + + _vertexArray.push_back(worldTestPos.x); + _vertexArray.push_back(worldTestPos.y); + _vertexArray.push_back(worldTestPos.z); + + _vertexArray.push_back(color.r); + _vertexArray.push_back(color.g); + _vertexArray.push_back(color.b); + _vertexArray.push_back(color.a); + +} /* Since our station dishes have a static translation from Earth, we * can get their local translation. The reason to handle it differently @@ -408,21 +429,6 @@ glm::dvec3 RenderableSignals::getCoordinatePosFromFocusNode(SceneGraphNode* node return diff; } -glm::dvec3 RenderableSignals::getEstimatedCoordinatePosFromFocusNode(glm::vec3 pos) { - - glm::dvec3 earthPos = global::renderEngine.scene()->sceneGraphNode("Earth")->worldPosition(); - glm::dvec3 focusNodePos = _focusNode->worldPosition(); - - glm::dmat4 translationMatrixEarth = glm::translate(glm::dmat4(1.0), glm::dvec3(earthPos)); - - glm::dvec4 newPos = { pos, 1.0 }; - glm::dvec4 nodePos = _rotEquatorialSphere * translationMatrixEarth *newPos; - - glm::dvec3 diff = glm::vec3(nodePos.x - focusNodePos.x, nodePos.y - focusNodePos.y, - nodePos.z - focusNodePos.z); - - return diff; -} glm::vec3 RenderableSignals::getSuitablePrecisionPositionForSceneGraphNode(std::string id) { @@ -434,7 +440,7 @@ glm::vec3 RenderableSignals::getSuitablePrecisionPositionForSceneGraphNode(std:: } else { //If no scenegraphnode with proper id was found, estimate the position of the spacecraft by RA/DEC/RANGE - position = convertRaDecRangeToCartesian(); + //position = convertRaDecRangeToCartesian(); } return position; @@ -457,27 +463,6 @@ glm::vec3 RenderableSignals::getPositionForGeocentricSceneGraphNode(const char* } -glm::dvec3 RenderableSignals::convertRaDecRangeToCartesian() { - //Todo: stream data from file - //Dummy data for voyager 1 - double ra = 257.777029167736; //2018-246 - double dec = 12.2537708651048; // 2018-246 - double range = 2.14044781771236e+13; - - // Convert RA and DEC from degrees to radians - ra = glm::radians(ra); - dec = glm::radians(dec); - - //Save array in vector - glm::dvec3 raDecPos = SpiceManager::getPositionFromRaDecRange(ra,dec,range); - - //Get the RA / DEC values in world coordinates with respect to the current focus node - raDecPos = getEstimatedCoordinatePosFromFocusNode(raDecPos); - - return raDecPos; -} - - RenderableSignals::ColorVBOLayout RenderableSignals::getSiteColor(std::string dishidentifier) { glm::vec3 color(0.0f,0.0f,0.0f); diff --git a/modules/dsn/rendering/renderablesignals.h b/modules/dsn/rendering/renderablesignals.h index c8bc6c23df..9f06e07bd0 100644 --- a/modules/dsn/rendering/renderablesignals.h +++ b/modules/dsn/rendering/renderablesignals.h @@ -86,10 +86,6 @@ namespace openspace { void pushSignalDataToVertexArray(SignalManager::Signal signal); /* Returns a position relative the current focus node */ glm::dvec3 getCoordinatePosFromFocusNode(SceneGraphNode* node); - /* Returns the estimated position expressed relative to the current focusnode */ - glm::dvec3 getEstimatedCoordinatePosFromFocusNode(glm::vec3 pos); - /* Converts the Ra Dec range coordinates into cartesian coordinates*/ - glm::dvec3 convertRaDecRangeToCartesian(); /*Returns a position for a spacecraft*/ glm::vec3 getSuitablePrecisionPositionForSceneGraphNode(std::string id); /*Returns a position for a station that has Earth as parent*/ @@ -193,11 +189,8 @@ namespace openspace { /*Checks if the current time is within a signal's start and endtime*/ bool isSignalActive(double currentTime, std::string signalStartTime, std::string signalEndTime); - /* Rotation matrix to transform into equatorial sphere coordinate system*/ - glm::dmat4 _rotEquatorialSphere = { -0.05487554, 0.4941095, -0.8676661, 0.0, - -0.8734371 , -0.4448296, -0.1980764, 0.0, - -0.483835 , 0.7469823, 0.4559838, 0.0, - 0.0 , 0.0 , 0.0 , 1.0 }; + + }; } // namespace openspace diff --git a/modules/dsn/translation/radectranslation.cpp b/modules/dsn/translation/radectranslation.cpp index d4c36436fc..ad257771d9 100644 --- a/modules/dsn/translation/radectranslation.cpp +++ b/modules/dsn/translation/radectranslation.cpp @@ -23,7 +23,6 @@ ****************************************************************************************/ #include - #include #include @@ -51,7 +50,7 @@ documentation::Documentation RadecTranslation::Documentation() { { PositionInfo.identifier, new DoubleVector3Verifier, - Optional::No, + Optional::Yes, PositionInfo.description } } @@ -66,7 +65,9 @@ RadecTranslation::RadecTranslation() glm::dvec3(-std::numeric_limits::max()), glm::dvec3(std::numeric_limits::max()) ) -{ +{ + + addProperty(_position); _position.onChange([this]() { @@ -83,11 +84,42 @@ RadecTranslation::RadecTranslation(const ghoul::Dictionary& dictionary) dictionary, "RadecTranslation" ); - - _position = dictionary.value(PositionInfo.identifier); } -glm::dvec3 RadecTranslation::position(const UpdateData&) const { +glm::dvec3 RadecTranslation::convertRaDecRangeToCartesian() const{ + //Todo: stream data from file + //Static data for voyager 1 + double ra = 257.777029167736; //2018-246 + double dec = 12.2537708651048; // 2018-246 + double range = 2.14044781771236e+13; + + //Convert RA and DEC from degrees to radians + ra = glm::radians(ra); + dec = glm::radians(dec); + + //Save array in vector + glm::dvec3 raDecPos = SpiceManager::getPositionFromRaDecRange(ra, dec, range); + + return raDecPos; +} + +glm::dvec3 RadecTranslation::transformCartesianCoordinates() const { + + glm::vec3 pos = convertRaDecRangeToCartesian(); + + glm::dvec3 earthPos = global::renderEngine.scene()->sceneGraphNode("Earth")->worldPosition(); + glm::dmat4 translationMatrixEarth = glm::translate( glm::dmat4(1.0), glm::dvec3(earthPos) ); + + glm::dvec4 newPos = { pos, 1.0 }; + glm::dvec4 nodePos = translationMatrixEarth * _rotEquatorialSphere * newPos; + glm::dvec3 worldposition = { nodePos.x, nodePos.y, nodePos.z }; + + return worldposition; +} + +glm::dvec3 RadecTranslation::position(const UpdateData&) const{ + + glm::dvec3 _position = transformCartesianCoordinates(); return _position; } diff --git a/modules/dsn/translation/radectranslation.h b/modules/dsn/translation/radectranslation.h index 6e433a9c8f..97fe46ef2d 100644 --- a/modules/dsn/translation/radectranslation.h +++ b/modules/dsn/translation/radectranslation.h @@ -26,8 +26,11 @@ #define __OPENSPACE_MODULE_DSN___RADECTRANSLATION___H__ #include - +#include +#include +#include #include +#include namespace openspace { @@ -39,14 +42,23 @@ class RadecTranslation : public Translation { public: RadecTranslation(); RadecTranslation(const ghoul::Dictionary& dictionary); - + /* Converts the Ra Dec range coordinates into cartesian coordinates*/ + glm::dvec3 convertRaDecRangeToCartesian() const; + /*Transforms the cartesian coordinates with a rotation and a translation*/ + glm::dvec3 transformCartesianCoordinates() const; glm::dvec3 position(const UpdateData& data) const override; static documentation::Documentation Documentation(); private: properties::DVec3Property _position; -}; + glm::dmat4 _rotEquatorialSphere = { -0.05487554, 0.4941095, -0.8676661, 0.0, + -0.8734371 , -0.4448296, -0.1980764, 0.0, + -0.483835 , 0.7469823, 0.4559838, 0.0, + 0.0 , 0.0 , 0.0 , 1.0 + }; + +}; } // namespace openspace #endif // __OPENSPACE_MODULE_DSN___RADECTRANSLATION___H__ From 2bdb7fece9f7492439aee61744b47a08275d3a33 Mon Sep 17 00:00:00 2001 From: Agnes Heppich Date: Mon, 12 Nov 2018 18:05:37 -0500 Subject: [PATCH 2/3] clean up --- modules/dsn/rendering/renderablesignals.cpp | 27 +++------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/modules/dsn/rendering/renderablesignals.cpp b/modules/dsn/rendering/renderablesignals.cpp index 80c4dc1b51..ca2b1a6691 100644 --- a/modules/dsn/rendering/renderablesignals.cpp +++ b/modules/dsn/rendering/renderablesignals.cpp @@ -391,27 +391,6 @@ void RenderableSignals::pushSignalDataToVertexArray(SignalManager::Signal signal _vertexArray.push_back(color.a); - //For testing - glm::vec3 worldTestPos = getSuitablePrecisionPositionForSceneGraphNode("testSpaceCraft"); - - _vertexArray.push_back(posStation.x); - _vertexArray.push_back(posStation.y); - _vertexArray.push_back(posStation.z); - - _vertexArray.push_back(color.r); - _vertexArray.push_back(color.g); - _vertexArray.push_back(color.b); - _vertexArray.push_back(color.a); - - _vertexArray.push_back(worldTestPos.x); - _vertexArray.push_back(worldTestPos.y); - _vertexArray.push_back(worldTestPos.z); - - _vertexArray.push_back(color.r); - _vertexArray.push_back(color.g); - _vertexArray.push_back(color.b); - _vertexArray.push_back(color.a); - } /* Since our station dishes have a static translation from Earth, we @@ -439,8 +418,8 @@ glm::vec3 RenderableSignals::getSuitablePrecisionPositionForSceneGraphNode(std:: position = getCoordinatePosFromFocusNode(spacecraftNode); } else { - //If no scenegraphnode with proper id was found, estimate the position of the spacecraft by RA/DEC/RANGE - //position = convertRaDecRangeToCartesian(); + LERROR(fmt::format("No scengraphnode found for the spacecraft {}", id)); + } return position; @@ -455,7 +434,7 @@ glm::vec3 RenderableSignals::getPositionForGeocentricSceneGraphNode(const char* position = global::renderEngine.scene()->sceneGraphNode(id)->position(); } else { - LERROR(fmt::format("No position data for the station dish {}, drawing line from center of Earth", id)); + LERROR(fmt::format("No scengraphnode found for the station dish {}, drawing line from center of Earth", id)); position = glm::vec3(0, 0, 0); } From c3d031e6a5e6a0fea5d5a163b3ed93a40eda7a0c Mon Sep 17 00:00:00 2001 From: Agnes Heppich Date: Mon, 12 Nov 2018 18:14:32 -0500 Subject: [PATCH 3/3] reduced data struct, clean up --- modules/dsn/managers/signalmanager.cpp | 4 ---- modules/dsn/managers/signalmanager.h | 4 ---- 2 files changed, 8 deletions(-) diff --git a/modules/dsn/managers/signalmanager.cpp b/modules/dsn/managers/signalmanager.cpp index 50ebecd49c..f1ad789876 100644 --- a/modules/dsn/managers/signalmanager.cpp +++ b/modules/dsn/managers/signalmanager.cpp @@ -191,10 +191,7 @@ namespace openspace { //loop through all signals in the data for (const auto& signalsInJson : j["Signals"]) { - - structSignal.signalId = signalsInJson["activityid"].get(); structSignal.dishName = signalsInJson["facility"].get(); - structSignal.year = signalsInJson["year"].get(); structSignal.spacecraft = signalsInJson["projuser"].get(); structSignal.endTime = signalsInJson["eot"].get(); structSignal.startTime = signalsInJson["bot"].get(); @@ -202,7 +199,6 @@ namespace openspace { //Add signals to vector of signals _signalData.signals.push_back(structSignal); - //_dsnData.signalStartTimes.push_back(Time::convertTime(structSignal.startTime)); } _signalData.isLoaded = true; diff --git a/modules/dsn/managers/signalmanager.h b/modules/dsn/managers/signalmanager.h index a7691e5ba6..d24fca52a0 100644 --- a/modules/dsn/managers/signalmanager.h +++ b/modules/dsn/managers/signalmanager.h @@ -46,15 +46,11 @@ namespace openspace { public: static struct Signal { - int signalId; std::string dishName; - int year; std::string spacecraft; std::string direction; std::string startTime; std::string endTime; - glm::vec3 color; - }; static struct SignalData {