我正在從本教程中脫離http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html 不幸的是,它並不能解釋Assimp如何派生它的骨骼數據。 我知道全局逆變換是默認的矩陣值混合器用於將y值設置爲z值,將z值設置爲-y。 (或者至少這是我的測試車型的MD5用什麼)骨骼動畫:如何手動派生Assimp骨骼偏移矩陣
GlobalInverseTransform = aiScene->mRootNode->mTransformation;
我想了解如何Assimp派生偏移矩陣或反綁定從MD5文件存在。例如BobLampClean.md5mesh有32個關節和32偏移矩陣
aiMesh->mBones[i]->mOffsetMatrix;
從我通過他們計算它是這樣的偏移矩陣其他樣品在網上看到...
void ComputeQuatW(glm::quat& quat)
{
float t = 1.0f - (quat.x * quat.x) - (quat.y * quat.y) - (quat.z * quat.z);
if (t < 0.0f)
quat.w = 0.0f;
else
quat.w = -sqrtf(t);
}
glm::mat4 rotation, rotationInv, translationInv, offsetmatrix;
glm::quat MyQuaternion;
//here I chose an arbitrary joint and hard coded its orientation and position
MyQuaternion = glm::quat(glm::quat(-0.535591, -0.462288, -0.534983, 1));
ComputeQuatW(MyQuaternion);
glm::mat4 RotationMatrix = glm::toMat4(MyQuaternion);
rotationInv = glm::transpose(RotationMatrix);
translationInv = glm::translate(translationInv, glm::vec3(-0.014076, -2.592741, -30.241238));
offsetmatrix = rotationInv*translationInv;
我已經輸出每個這些偏移矩陣comapre與Assimp的骨骼矩陣,但無濟於事。我不太確定我在做什麼錯...
編輯更新:好所以我做我的操作不正確,我正在調試一個工作代碼示例,不使用Assimp,它可以複製與Assimp的數據相同的值。我將更新如何正確計算數據。