Transform issues

Help
2013-07-12
2013-07-13
  • I am using assimp to load model data in order to convert to a proprietary format for my engine. For testing purposes I am using a couple of the Doom3 models in md5 format. Things seem to work ok, until I come to render the data, aside from skinning issues a debug render of the node hierarchy looks incorrect.

    Basically I am traversing the node hierarchy generated by assimp and exporting the node information (name, parent, etc) including the node->mTransform, which I assume is the local node transform. When I recursively calculate the world node transform and render the hierarchy a few (not all) of the positions look incorrect.

    Am I missing something here? I'm sure I am doing something wrong, but can't spot it. All I want to obtain is the node transforms (either local or world) such that when I use them to transform vector x=0 y=0 z=0 the resulting position appears correct against the original model. Any help would be appreciated.

    Below is a code snippet from the code I use to extract the transforms.

    aiMatrix4x4 getNodeOffset( const aiNode* node, const aiScene* scene )
    {
        for( int i = 0; i < scene->mNumMeshes; i++ )
        {
            aiMesh* mesh = scene->mMeshes[i];
    
            for( int j = 0; j < mesh->mNumBones; j++ )
            {
                aiBone* bone = mesh->mBones[j];
    
                if( bone->mName == node->mName )
                {
                    return bone->mOffsetMatrix;
                }
            }
        }
    
        return aiMatrix4x4();
    }
    
    NodeList createHierarchy( const aiScene* scene )
    {
        NodeList nodeList;
    
        createHierarchyRecurse( scene, scene->mRootNode, -1, nodeList, false );
    
        return nodeList;
    }
    
    void createHierarchyRecurse( const aiScene* scene, const aiNode* node, int parent, NodeList& nodeList )
    {
        HNode hn;
    
        aiMatrix4x4 offset = getNodeOffset( node, scene );
    
        aiQuaternion quat;
        aiVector3D pos;
        offset.DecomposeNoScaling( quat, pos );
    
        printf( "%s mOffset %f %f %f\n", node->mName.C_Str(), quat.x, quat.y, quat.z, pos.x, pos.y, pos.z );
    
        hn.offset.q = quat;
        hn.offset.p = pos;
    
        node->mTransform.DecomposeNoScaling( quat, pos );
    
        hn.trans.q = quat;
        hn.trans.p = pos;
    
        nodeList.push_back( hn );
    
        parent = nodeList.size() - 1;
    
        for( int i = 0; i < node->mNumChildren; i++ )
        {
            createHierarchyRecurse( scene, node->mChildren[i], parent, nodeList );
        }
    }
    

    Many thanks in advance

    Alex

     
    Last edit: Alexander Snape 2013-07-13
  • Problem solved - issue was with row major -> column major matrices.