mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-08 12:39:49 -06:00
Correct coordinate transformation
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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<float>(_stateMatrix[i][j]);
|
||||
}
|
||||
}
|
||||
transform = transform*_rotation;
|
||||
|
||||
position += transform*glm::vec4(_data->spatialScale.x*_data->offset, _data->spatialScale.w);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user