Merge pull request #1594 from Matter-and-Form/fix/gltf2-transforms

[glTF2] Fix transform matrices multiplication order
pull/1599/head
Kim Kulling 2017-11-28 09:22:01 +01:00 committed by GitHub
commit e6381b7616
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 9 deletions

View File

@ -539,7 +539,13 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
CopyValue(node.translation.value, trans); CopyValue(node.translation.value, trans);
aiMatrix4x4 t; aiMatrix4x4 t;
aiMatrix4x4::Translation(trans, t); aiMatrix4x4::Translation(trans, t);
matrix = t * matrix; matrix = matrix * t;
}
if (node.rotation.isPresent) {
aiQuaternion rot;
CopyValue(node.rotation.value, rot);
matrix = matrix * aiMatrix4x4(rot.GetMatrix());
} }
if (node.scale.isPresent) { if (node.scale.isPresent) {
@ -547,14 +553,7 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
CopyValue(node.scale.value, scal); CopyValue(node.scale.value, scal);
aiMatrix4x4 s; aiMatrix4x4 s;
aiMatrix4x4::Scaling(scal, s); aiMatrix4x4::Scaling(scal, s);
matrix = s * matrix; matrix = matrix * s;
}
if (node.rotation.isPresent) {
aiQuaternion rot;
CopyValue(node.rotation.value, rot);
matrix = aiMatrix4x4(rot.GetMatrix()) * matrix;
} }
} }