diff --git a/QtMeshViewer/Header/FileInterface.h b/QtMeshViewer/Header/FileInterface.h index 0508ea896854d6945a376c0edd544049fb42c4b1..7db28b87f8a8f71ca68365aa5fbedf21093ec6f1 100644 --- a/QtMeshViewer/Header/FileInterface.h +++ b/QtMeshViewer/Header/FileInterface.h @@ -30,6 +30,7 @@ struct Model { std::string name = ""; std::string parent = ""; QMatrix4x4 m4x4Translation; + QQuaternion quadRotation; std::vector<Segment*> segmList; }; diff --git a/QtMeshViewer/Source/GeometryEngine.cpp b/QtMeshViewer/Source/GeometryEngine.cpp index e2961d7cdaa47948acd01a20163651cea8c15a49..4bc510bfaa87034ae7108490c57e970a4c8eaba1 100644 --- a/QtMeshViewer/Source/GeometryEngine.cpp +++ b/QtMeshViewer/Source/GeometryEngine.cpp @@ -59,6 +59,7 @@ void GeometryEngine::loadFile(const char* filePath) new_info.size = segmentIterator->indices.size(); new_info.textureIndex = segmentIterator->textureIndex; new_info.modelMatrix = modelIterator->m4x4Translation; + new_info.modelMatrix.rotate(modelIterator->quadRotation); // add offset to indices for (auto& it : segmentIterator->indices) diff --git a/QtMeshViewer/Source/MshFile.cpp b/QtMeshViewer/Source/MshFile.cpp index 5d52e922e33a1e9607f2ea35e281bfc9cd047717..290aad9aaa92bf45da7beb2aeee917b1999dd1ab 100644 --- a/QtMeshViewer/Source/MshFile.cpp +++ b/QtMeshViewer/Source/MshFile.cpp @@ -293,8 +293,9 @@ void MshFile::analyseModlChunks(Model * dataDestination, std::list<ChunkHeader*> // modify the matrix dataDestination->m4x4Translation.scale(tmp_scale[0], tmp_scale[1], tmp_scale[2]); - dataDestination->m4x4Translation.rotate(QQuaternion(tmp_rotation[3], tmp_rotation[0], tmp_rotation[1], tmp_rotation[2])); dataDestination->m4x4Translation.translate(tmp_trans[0], tmp_trans[1], tmp_trans[2]); + dataDestination->quadRotation.setVector(QVector3D(tmp_rotation[0], tmp_rotation[1], tmp_rotation[2])); + dataDestination->quadRotation.setScalar(tmp_rotation[3]); dataDestination->m4x4Translation = getParentMatrix(dataDestination->parent) * dataDestination->m4x4Translation;