Assimp mOffsetMatrix broken?

Started by
3 comments, last by JackOfAllTrades 12 years, 3 months ago
I've started using Assimp but I can't seem to figure out how to get the position of bones? The documentation says that mOffsetMatrix should be the bone's position relative to the mesh but I can't seem to get the mOffsetMatrix to return the proper result. Now as I understand assimp's matrices are suppose to be right handed like OpenGL but from what I can tell they are not. This is how I'm converting the matrices to my matrix type which is a right handed matrix:

bone->matrix = (*(Matrix44*)&scene->mMeshes[m]->mBones->mOffsetMatrix.Transpose());

However, something is off that I can't quite place a finger on.
Advertisement
you can download my ASSIMP animation exporter, maybe that will help you out
http://nolimitsdesigns.com/game-design/open-asset-import-library-animation-loader/
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.

you can download my ASSIMP animation exporter, maybe that will help you out
http://nolimitsdesig...imation-loader/


I've reviewed your code quite extensively but I don't understand why it's working. From what I can tell I need to iterate backwards through the bone node's hierarchy to construct a global transformation. However, I had actually already tried this but failed to receive any logical results. Maybe you can see what I have done wrong?



aiNode* bnode = scene->mRootNode->FindNode(scene->mMeshes[m]->mBones->mName);
aiMatrix4x4 GlobalTransform = bnode->mTransformation;
aiNode* parent = bnode->mParent;
while( parent->mParent != scene->mRootNode )
{
GlobalTransform *= parent->mTransformation;
parent = parent->mParent;
}
bone->matrix = (*(Matrix44*)&GlobalTransform.Transpose());
I belive your are mutliplying in the wrong order. When I load the matrix from assimp on the init function, i transpose everything in the copy. Then, after the copy is finished, I build the skeleton. In your code . .

GlobalTransform *= parent->mTransformation;

Then, you transpose afterwards. Right handed and left handed matrix operations are backward from each other. Try transposing all your matrix before you do any calculations., otherwise, change the order of mutiplication to be backwards, i.e
GlobalTransform = parent->mTransformation * GlobalTransform ;
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.

I belive your are mutliplying in the wrong order. When I load the matrix from assimp on the init function, i transpose everything in the copy. Then, after the copy is finished, I build the skeleton. In your code . .

GlobalTransform *= parent->mTransformation;

Then, you transpose afterwards. Right handed and left handed matrix operations are backward from each other. Try transposing all your matrix before you do any calculations., otherwise, change the order of mutiplication to be backwards, i.e
GlobalTransform = parent->mTransformation * GlobalTransform ;


I forgot to reply back to you. That was the problem and I had quickly figured it out. Thank you for all your help! I really appreciate it!

This topic is closed to new replies.

Advertisement