Menu

#114 MD5 bones not being added to scene nodes

Release 3.0
closed
nobody
Assimp lib (91)
5
2016-02-01
2013-02-13
Anonymous
No

When I was importing .md5mesh and .md5anim files that share the same name ( "test2.md5mesh" and "test2.md5anim"), bone nodes weren't being add to Scene graph. Walking through 'scene->mRootNode' childrens yielded following list:
- <MD5_Root>
- <MD5_Mesh>
- <MD5_Hierarchy>
I can assume that bones should be childrens of the '<MD5_Hierarchy>' node ( at least when importing Collada .dae file they were).

I've fixed the problem by adding following lines ( between '//@@@@@@@@@@@@' markers):

// If we didn't build the hierarchy yet (== we didn't load a MD5MESH),
// construct it now from the data given in the MD5ANIM.
if (!pScene->mRootNode) {
pScene->mRootNode = new aiNode();
pScene->mRootNode->mName.Set("<MD5_Hierarchy>");

AttachChilds_Anim(-1,pScene->mRootNode,animParser.mAnimatedBones,(const aiNodeAnim**)anim->mChannels);

// Call SkeletonMeshBuilder to construct a mesh to represent the shape
if (pScene->mRootNode->mNumChildren) {
SkeletonMeshBuilder skeleton_maker(pScene,pScene->mRootNode->mChildren[0]);
}
}

// here ends original Assimp code, following lines are my fix:

//@@@@@@@@@@@@
else{
std::cout << "NODE EXIST !!!!!!! Custom add nodes";

aiNode* root = pScene->mRootNode, *hierarchy = NULL;
for( int i = 0; i < root->mNumChildren ; i++){
std::string name( root->mChildren[i]->mName.data);
if( name.compare("<MD5_Hierarchy>") == 0 ){
hierarchy = root->mChildren[i];
break;
}
}
if( hierarchy==NULL){
// not found
hierarchy = new aiNode();
hierarchy->mName.Set("<MD5_Hierarchy>");
root->mChildren[ root->mNumChildren] = hierarchy;
root->mNumChildren += 1;
}

AttachChilds_Anim( -1, hierarchy, animParser.mAnimatedBones, (const aiNodeAnim**)anim->mChannels);
std::cout << "NODE EXIST !!!!!!! Custom add nodes EEEENDDDDD";
}
//@@@@@@@@@@@@

FILE: MD5Loader.cpp
FIX_LINE_NUMBER: 670

Probable cause: when loading the mesh, the '<MD5_Root>' node is being created, causing the 'if (!pScene->mRootNode) {' to fail when loading animation.

Compiler: VC++ 10
MD5 Exporter: Blender unofficial plugin ( I've double checked - file was 100% correct)
Assimp version: 3.0.1270
cmake version: 2.8.10.2

Discussion

  • Nobody/Anonymous

    I've discovered that one of my bones had ' ' in the name, that caused the problem. When i changed the name, problem was fixed ( with 'default' Assimp library version). I was using scene->mMeshes[i] to get all the meshes loaded from file, so this small inconsistency between scene graph and actual loaded scene was overlooked. Sorry for causing trouble, Mark this 'bug' as closed !

     
  • Kim Kulling

    Kim Kulling - 2013-09-25
    • status: open --> pending
    • Group: --> Release 3.0
     
  • Kim Kulling

    Kim Kulling - 2016-02-01

    OK, deprecated issue.

     
  • Kim Kulling

    Kim Kulling - 2016-02-01
    • status: pending --> closed