1
votes

I need to combine multiple matrices to do skeletal animation in c++.

I already got the following matrices:

  1. Bind Shape Matrix from a COLLADA file.
  2. Bone Matrix for every bone from a COLLADA file.
  3. Bind Pose Matrix for every bone from a COLLADA file.
  4. Inverse Bind Pose Matrix for every bone calculated.
  5. Frame Matrix of every frame per bone of an animation from a COLLADA file.

Let's call these matrices:

  1. bindShapeTrans (XMFloat4X4)
  2. localBoneTrans (vector of XMFloat4X4)
  3. bindPoses (vector of XMFloat4X4)
  4. invBindPoses (vector of XMFloat4X4)
  5. animations (vector of vector of XMFloat4X4)

Now I have to create an array of matrices out of these to pass to my vertex shader, which uses it to calculate the final positions of the vertices considering their weights.

And here I got lost. I already read a lot of tutorials, but they all say different things about the order to combine the matrices. They also use different names for the matrices and now I'm totally confused.

So, how do I have to combine these matrices to get the correct final matrices?

Thank you for your help.

Depends on how you want to animate the model. Do you want to use a simple linear blend skinning? What is the difference between 2 (bone matrix for every bone) and 3 (bind pose matrix for every bone)? Is the bind shape matrix the model's world transformation?Nico Schertler
Yes, I want simple linear blend skinning.user3564880
Number 2 are the matrices from the value of the float_array-node of the second source-node of COLLADA-library_controllers-skin (COLLADA file). Number 3 are the matrices from the values of the matrix-nodes of the node-nodes of COLLADA-library_visual_scenes-visual_scene (COLLADA file). The bind shape matrix is the value of the bind_shape_matrix-node of COLLADA-library_controllers-controller-skin in the COLLADA file. It appears that there is just one bind shape matrix per model and it is the identity matrix, so it can be ignored, I suppose.user3564880
Then you should find out what these matrices mean. In my opinion, you would need frameMatrix * invBindPose for every bone, every frame. Maybe the other way round, depending on your math API. Do the bone matrices differ from the bind pose matrices?Nico Schertler
Thanks for your tip. :) The bone matrices do differ from the bind pose matrices. But I found out that I got it wrong: the bind pose matrices are in fact the inverse bind pose matrices. I will go through my entire code again to correct it.user3564880