我目前正在加载一个 MD5 模型,用于使用 ASSIMP 测试动画(来自以下教程:http ://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html )。到目前为止,一切似乎都加载得很好(静态模型渲染得很好),但由于某种原因,Assimp 中的节点不显示骨骼名称。每个节点的名称是<MD5_Root>
或<MD5_Mesh>
不是它应该显示的任何骨骼名称。
以下是代码片段,它使用节点名称检查 ASSIMP 中的所有骨骼名称。永远不会到达字符串变成"HOI"
. nodeName 应该成为像“pubis”或“upperarm.L”这样的骨骼名称。
void MeshLoader::ReadNodeHeirarchy(float AnimationTime, const aiNode* pNode, const aiMatrix4x4 ParentTransform)
{
string nodeName = pNode->mName.data;
const aiAnimation* pAnimation = m_pScene->mAnimations[0]; // Update from here if you want different animations! :O
aiMatrix4x4 nodeTransformation(pNode->mTransformation);
const aiNodeAnim* pNodeAnim = FindNodeAnim(pAnimation, nodeName);
if(nodeName != "<MD5_Root>" && nodeName != "<MD5_Mesh>")
nodeName = "HOI";
...
}
const aiNodeAnim* MeshLoader::FindNodeAnim(const aiAnimation* pAnimation, const string NodeName)
{
for (unsigned int i = 0 ; i < pAnimation->mNumChannels ; i++)
{
const aiNodeAnim* pNodeAnim = pAnimation->mChannels[i];
if (string(pNodeAnim->mNodeName.data) == NodeName)
return pNodeAnim;
}
return NULL;
}
此外,还有一段 .MD5 文件,它可能会显示一些有用的信息。
MD5Version 10
commandline ""
numJoints 33
numMeshes 6
joints {
"origin" -1 ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000000 0.707107 ) //
"sheath" 0 ( 11.004813 -3.177138 31.702473 ) ( 0.307041 -0.578614 0.354181 ) // origin
"sword" 1 ( 9.809593 -9.361549 40.753730 ) ( 0.305557 -0.578155 0.353505 ) // sheath
"pubis" 0 ( 0.014076 2.064442 26.144581 ) ( -0.466932 -0.531013 -0.466932 ) // origin
"pelvis" 3 ( 0.014076 2.592741 30.241238 ) ( -0.535591 -0.462288 -0.534983 ) // pubis
"spine" 4 ( 0.023039 1.427001 38.133138 ) ( -0.499998 -0.500002 -0.499998 ) // pelvis
"neck" 5 ( 0.023039 1.427122 51.620732 ) ( -0.643897 -0.292228 -0.643896 ) // spine
"head" 6 ( 0.023047 -1.828043 55.341849 ) ( -0.707074 -0.007564 -0.707059 ) // neck
"upperarm.L" 5 ( -7.999740 4.449851 48.597286 ) ( -0.000001 -0.000001 -0.716595 ) // spine
"forearm.L" 8 ( -20.905890 4.101032 48.597330 ) ( -0.000001 -0.000001 -0.746270 ) // upperarm.L
"wrist.L" 9 ( -32.023143 2.795714 48.607747 ) ( 0.009625 0.009713 -0.703812 ) // forearm.L
...
}
mesh {
shader "....OpenGL/Resources/Objects/Bob/guard1_body.png"
numverts 494
vert 0 ( 0.394531 0.513672 ) 0 1
vert 1 ( 0.447266 0.449219 ) 1 2
vert 2 ( 0.453125 0.517578 ) 3 1
...
}
由于某种原因,它没有正确加载名称,或者它可能是 MD5 文件本身的错误?