fixed rotation problem

This commit is contained in:
Anakin 2017-01-02 16:43:38 +01:00
parent 24d26cfdfa
commit fc7941a890
3 changed files with 4 additions and 1 deletions

View File

@ -30,6 +30,7 @@ struct Model {
std::string name = "";
std::string parent = "";
QMatrix4x4 m4x4Translation;
QQuaternion quadRotation;
std::vector<Segment*> segmList;
};

View File

@ -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)

View File

@ -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;