From d368ad9054fa9c922bd2f4e8109b5320b596ae0e Mon Sep 17 00:00:00 2001 From: Sebastian Piwell Date: Tue, 14 Jun 2016 13:33:55 -0400 Subject: [PATCH] Correct coordinate transformation --- modules/iswa/rendering/datasphere.cpp | 5 ++++ modules/iswa/rendering/iswacygnet.cpp | 3 ++- modules/iswa/rendering/iswacygnet.h | 2 ++ src/util/transformationmanager.cpp | 35 +++------------------------ 4 files changed, 13 insertions(+), 32 deletions(-) diff --git a/modules/iswa/rendering/datasphere.cpp b/modules/iswa/rendering/datasphere.cpp index b704be05c7..8184530338 100644 --- a/modules/iswa/rendering/datasphere.cpp +++ b/modules/iswa/rendering/datasphere.cpp @@ -43,6 +43,8 @@ DataSphere::DataSphere(const ghoul::Dictionary& dictionary) _programName = "DataSphereProgram"; _vsPath = "${MODULE_ISWA}/shaders/datasphere_vs.glsl"; _fsPath = "${MODULE_ISWA}/shaders/datasphere_fs.glsl"; + + } DataSphere::~DataSphere(){} @@ -50,6 +52,9 @@ DataSphere::~DataSphere(){} bool DataSphere::initialize(){ IswaCygnet::initialize(); + //rotate 90 degrees because of the texture coordinates in PowerScaledSphere + _rotation = glm::rotate(_rotation, (float)M_PI_2, glm::vec3(1.0, 0.0, 0.0)); + if(_group){ _dataProcessor = _group->dataProcessor(); subscribeToGroup(); diff --git a/modules/iswa/rendering/iswacygnet.cpp b/modules/iswa/rendering/iswacygnet.cpp index f5c9e4e92a..a1afa13653 100644 --- a/modules/iswa/rendering/iswacygnet.cpp +++ b/modules/iswa/rendering/iswacygnet.cpp @@ -42,6 +42,7 @@ IswaCygnet::IswaCygnet(const ghoul::Dictionary& dictionary) , _shader(nullptr) , _group(nullptr) , _textureDirty(false) + , _rotation(glm::mat4(1.0f)) { std::string name; dictionary.getValue("Name", name); @@ -146,12 +147,12 @@ void IswaCygnet::render(const RenderData& data){ psc position = data.position; glm::mat4 transform = glm::mat4(1.0); - glm::mat4 rot = glm::mat4(1.0); for (int i = 0; i < 3; i++){ for (int j = 0; j < 3; j++){ transform[i][j] = static_cast(_stateMatrix[i][j]); } } + transform = transform*_rotation; position += transform*glm::vec4(_data->spatialScale.x*_data->offset, _data->spatialScale.w); diff --git a/modules/iswa/rendering/iswacygnet.h b/modules/iswa/rendering/iswacygnet.h index 6040f26f99..c123aa5c22 100644 --- a/modules/iswa/rendering/iswacygnet.h +++ b/modules/iswa/rendering/iswacygnet.h @@ -142,6 +142,7 @@ protected: std::string _fsPath; std::string _programName; + glm::mat4 _rotation; //to rotate objects with fliped texture coordniates private: bool destroyShader(); glm::dmat3 _stateMatrix; @@ -152,6 +153,7 @@ private: std::chrono::milliseconds _realTime; std::chrono::milliseconds _lastUpdateRealTime; int _minRealTimeUpdateInterval; + }; }//namespace openspace diff --git a/src/util/transformationmanager.cpp b/src/util/transformationmanager.cpp index 3b5448baf0..eee4aefb48 100644 --- a/src/util/transformationmanager.cpp +++ b/src/util/transformationmanager.cpp @@ -39,11 +39,9 @@ #else LWARNING("Kameleon module needed for transformations with dynamic frames"); #endif - _kameleonFrames = { "J2000", "GEI", "GEO", "MAG", "GSE", "GSM", "SM", "RTN", "GSEQ", //geocentric "HEE", "HAE", "HEEQ" //heliocentric }; - // _dipoleFrames = {"GSM", "MAG"}; } TransformationManager::~TransformationManager(){ @@ -68,15 +66,11 @@ _kameleon->_cxform(from.c_str(), to.c_str(), ephemerisTime, &in1, &out1); _kameleon->_cxform(from.c_str(), to.c_str(), ephemerisTime, &in2, &out2); - glm::dmat3 out = glm::dmat3( + return glm::dmat3( out0.c0 , out0.c1 , out0.c2, out1.c0 , out1.c1 , out1.c2, out2.c0 , out2.c1 , out2.c2 - ); - - // Need to rotate 90 degrees around x-axis becuase kameleon is flipped - out = glm::dmat3(glm::rotate(glm::mat4(out), (float)M_PI_2, glm::vec3(1.0f, 0.0f, 0.0f))); - return out; + );; } glm::dmat3 TransformationManager::frameTransformationMatrix(std::string from, @@ -84,32 +78,11 @@ double ephemerisTime) const { #ifdef OPENSPACE_MODULE_KAMELEON_ENABLED - auto fromit = _dipoleFrames.find(from); - auto toit = _dipoleFrames.find(to); - - // //diopole frame to J200 makes the frame rotate. - // if(fromit != _dipoleFrames.end()) from = "GSE"; - // if(toit != _dipoleFrames.end()) to = "GSE"; - - fromit = _kameleonFrames.find(from); - toit = _kameleonFrames.find(to); + auto fromit = _kameleonFrames.find(from); + auto toit = _kameleonFrames.find(to); bool fromKameleon = (fromit != _kameleonFrames.end()); bool toKameleon = (toit != _kameleonFrames.end()); - - ccmc::Position in0 = {1.f, 0.f, 0.f}; - ccmc::Position in1 = {0.f, 1.f, 0.f}; - ccmc::Position in2 = {0.f, 0.f, 1.f}; - - glm::dmat3 in( - in0.c0, in0.c1, in0.c2, - in1.c0, in1.c1, in1.c2, - in2.c0, in2.c1, in2.c2 - ); - - ccmc::Position out0; - ccmc::Position out1; - ccmc::Position out2; if(!fromKameleon && !toKameleon){ return SpiceManager::ref().frameTransformationMatrix(from, to, ephemerisTime);