From fc7941a890c5ecd44eaa06f0282ccdeb4eaa635c Mon Sep 17 00:00:00 2001 From: Anakin Date: Mon, 2 Jan 2017 16:43:38 +0100 Subject: [PATCH] fixed rotation problem --- QtMeshViewer/Header/FileInterface.h | 1 + QtMeshViewer/Source/GeometryEngine.cpp | 1 + QtMeshViewer/Source/MshFile.cpp | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/QtMeshViewer/Header/FileInterface.h b/QtMeshViewer/Header/FileInterface.h index 0508ea8..7db28b8 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 segmList; }; diff --git a/QtMeshViewer/Source/GeometryEngine.cpp b/QtMeshViewer/Source/GeometryEngine.cpp index e2961d7..4bc510b 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 5d52e92..290aad9 100644 --- a/QtMeshViewer/Source/MshFile.cpp +++ b/QtMeshViewer/Source/MshFile.cpp @@ -293,8 +293,9 @@ void MshFile::analyseModlChunks(Model * dataDestination, std::list // 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;