0
\$\begingroup\$

I'm trying to make an animation from a Collada file, but I'm not having any success in animating it correctly. I assume it's an error in the Quartenions class, either during creation from matrices or when converting to rotation matrices.

I've tried two methods, but neither worked. I'm following the tutorial on the ThinMatrix YouTube channel. I took care to transpose all the matrices coming from the Collada file. I've already checked the indices of the animation transformation matrices that are passed to the Shader. I've already tried using different Inverse Bind Matrices. I've already changed the multiplication order of all the animation matrices: vertex * bindShapeMatrix * TransformMatrix * InvBindMatrix, but without success. All I get is a shapeless goo from the movie "The Thing".

The vertices are saved in a file named "body.txt", and the project is stored at in this GitHub repository. The model is in the Assets/human/human.dae".

I've already tried using the INV_BIND_MATRIX provided by the controller skin, as well as creating my own inverse. I've already tried multiplying the animation matrices with just the parent matrices, as well as multiplying with the parents until reaching the root joint. I have already tried multiplying the bindShapeMatrix with the vertices in the Shader, with the invBindMatrix, with the Transform matrix, from left to right. Nothing works.

The result is this thing: Rainbow-coloured malformed jumble of vertices

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

I created a short video on the subject, explaining the math principle of skeletal animation in both pure vector form and matrix form. Writing Collada loader like I did isn't for beginners because the file is complex and obscure.

Here's an overview:

  1. Find the bones (inverse the bone matrices and get translations).
  2. Find the hierarchy.
  3. Find all animations.
  4. Each set of animation also has their corresponding "bind pose" matrix to multiple with (get these in the joint node) + (transpose them if needed).
  5. Precompute the animation using obtained data.

Caution:

  • On shader, you can implement single weight skinning for simplicity or multiple weights as usual. If muti-weights are used, do the basics linear interpolation between two vectors.
  • Sometime inanimate bones are not exported with any animation, use bone names and order to generate dummy animations.
  • Always have Blender to sort the bone name as hierarchical.
  • Only the root bone should have translations and scale & for safety reasons, disable all translation/scale if your system is premature.
  • Convert Z-up to Y-up, apply for the mesh geometry and bones only.
\$\endgroup\$
3
  • \$\begingroup\$ in response to the topic "overview": 1-> Loader->loadDAE->colladaDataHandler.createSkeleton(); 2-> colladaDataHandler->createJoints() 3-> Animation() -> getAnimationTransforms(rootJointId); 4 -> got to step 1; DynamicModel -> updateAnimation();. Thanks friend, but your video tutorial is in C++ and I don't know this language and I didn't quite understand what stage of the animation it is in. If it were in Java it would help a lot. \$\endgroup\$ Commented Mar 30 at 16:29
  • \$\begingroup\$ I'm trying the fix given by <vlad.website/game-engine-skeletal-animation> in the chapter "Realising we’ve made a terrible mistake", but I can't understand the c++ code properly. It makes a kind of sandwich with the transformation matrix of the Root Bone. \$\endgroup\$ Commented Mar 30 at 23:55
  • \$\begingroup\$ I got it! I just multiplied the root's inverse bind matrix to the left of the joint bind pose matrix in Animation -> apllyPoseToJoints(). \$\endgroup\$ Commented Mar 31 at 13:05
0
\$\begingroup\$

the correct sequence for multiplying matrices is this (before passing to the shader):

jointAnim = rootJointInverseBind * ( currentRootJointTransform * currentParentJointTransform *... * currentJointTransform ) * jointInverseBind 

In shader:

sum of jointAnim[i] * (bindShapeMatrix * vertexPosition) * weight[i]

(bindShapeMatrix * vertexPosition) was done previously.

The "current" matrices are the interpolated transforms from animation keyframes.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.