سؤال

I'm currently loading an MD5 model for testing out animations using ASSIMP (from the following tutorial: http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html). So far, everything seems to load just fine (static model renders fine), but for some reason the nodes in Assimp do not display bone names. The names of each node is <MD5_Root> or <MD5_Mesh> and not any of the bone names it should display.

The following is a snippet from the code that checks for all the bone names in ASSIMP with the node Name. Never reaching the point where the string becomes "HOI". nodeName should become a bone name like 'pubis' or '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;
}

Also, a piece of the .MD5 file, which might show something usefull.

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
    ...
}

For some reason it's not loading the names correctly or maybe it's an error in the MD5 file itself?

هل كانت مفيدة؟

المحلول

I found the solution to my problem. Appareantly the issue was not in the name section of ASSIMP or the file itself. It was an issue with a loop counter somewhere in the Mesh Loading code for the child traversel of each node. It was currently only traversing the 1st node of all the node's children, so it wouldn't move on to the bone nodes.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top