Merge pull request #640 from skyjake/md5-fix

MD5: Fix quaternion conversions
pull/669/head
Alexander Gessler 2015-10-10 13:53:27 +02:00
commit 878d0745d3
3 changed files with 3 additions and 6 deletions

View File

@ -285,9 +285,6 @@ void MD5Importer::AttachChilds_Mesh(int iParentID,aiNode* piParent, BoneList& bo
aiQuaternion quat; aiQuaternion quat;
MD5::ConvertQuaternion ( bones[i].mRotationQuat, quat ); MD5::ConvertQuaternion ( bones[i].mRotationQuat, quat );
// FIX to get to Assimp's quaternion conventions
quat.w *= -1.f;
bones[i].mTransform = aiMatrix4x4 ( quat.GetMatrix()); bones[i].mTransform = aiMatrix4x4 ( quat.GetMatrix());
bones[i].mTransform.a4 = bones[i].mPositionXYZ.x; bones[i].mTransform.a4 = bones[i].mPositionXYZ.x;
bones[i].mTransform.b4 = bones[i].mPositionXYZ.y; bones[i].mTransform.b4 = bones[i].mPositionXYZ.y;
@ -656,9 +653,6 @@ void MD5Importer::LoadMD5AnimFile ()
MD5::ConvertQuaternion(vTemp, qKey->mValue); MD5::ConvertQuaternion(vTemp, qKey->mValue);
qKey->mTime = vKey->mTime = dTime; qKey->mTime = vKey->mTime = dTime;
// we need this to get to Assimp quaternion conventions
qKey->mValue.w *= -1.f;
} }
} }

View File

@ -262,6 +262,9 @@ inline void ConvertQuaternion (const aiVector3D& in, aiQuaternion& out) {
if (t < 0.0f) if (t < 0.0f)
out.w = 0.0f; out.w = 0.0f;
else out.w = std::sqrt (t); else out.w = std::sqrt (t);
// Assimp convention.
out.w *= -1.f;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

Binary file not shown.