Jump to content
  • Advertisement
Sign in to follow this  

Collada animation leads to distorted model

This topic is 1337 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In collada the skinning equation is : v += {[(v * BSM) * IBMi * JMi] * JW}  I'd like to clear something..

1) BSM = bind shape matrix , located in the tag "bind_shape_matrix"?

2) IBMi = inverse bind matrix, located in "library_controller", the same number as the total number of the joints?

3) JMi = joint matrix. Is it animation matrix from <library_animation>, or world matrix or local matrix ?

4) For now I want to just change the model to another different 'pose'. The pose is defined in a keyframe in Blender. For now I only have two poses for my model. The first one is bind pose/rest pose at frame 0, the second is a different pose at frame 30.

5) To my understanding, animation matrix's(from "library_animation") purpose is to replace JMi in the skinning formula , in order to give the model a different 'pose'. If so, what's use of each joint's world matrix? And If BSM is an identity matrix, can it be ignored?

6) To get a bone's world matrix, can I just multiply its parent's world matrix by its relative matrix?


The joints found in <library_visual_scene> are local/relative matrix for each joint. What I have done to simply switch to another pose was , take the local matrix for the current bone and multiply it with only the world matrix of its parent(i mean not all the way to the root bone's world matrix, only by its parents). But I doubt the world matrix is used in the formula so I didn't use it. Then I send the inverse bind bone matrix and animation matrix and vertex weights to the shader, and use that formula. Since the BSM is an identity matrix I didn't use it nether. As for JMi, I replace it with the animation matrix. But the result is not correct. The model is completely distorted.

I do the vertex skinning on vertex shader. For now there are three bones for the model. The snippet of code for skinning in vertex shader is the following

`in vec4 position; // The vertice position

uniform mat4 inver,inver2,inver3; // The inverse bind matrix for each bone(3 bones)

uniform mat4 joint,joint2,joint3; // The animation matrix for each bone(directly from

vec4 v = vec4(0,0,0,1); v+= ( weight1 * inver * joint * position) + (weight2* inver2 * joint2* position) + (weight3 * inver3 * joint3 * position);

// all the inver are inverse bind matrix found in <library_controller>, all the joint are animation matrix from <library_animation> `

I use v as the final position. The result is that the model is completely distorted. What could likely be wrong here? Thanks very much.

Share this post

Link to post
Share on other sites

While someone else may have clearer advice to your specific questions (though, I find you'll receive fewer answers to complex questions like this) I thought I'd offer some more general advice that ultimately helped me get through the same issue (most of it from member Haegarr on these forums).


Most importantly, use an extremely simple model, such as a 3D rectangle or cube, without an animation but still bone-rigged (try with just a single bone, then try with two bones, etc), in its bind pose, and render that. You'll have a clearer idea of where you may be going wrong, and it's a little easier to see visually what your code is really doing with your bones/mesh.


If the bind pose is rendering ok, add a simple transformation animation, then a rotation animation, etc, to rule out issues with your individual math functions for each.


I.e. perhaps with a single bone, you'll find everything is ok and it translates/rotates/scales correctly. Then you can be relatively sure that your issue is with the child bones and how you're transforming them. Maybe with a second bone, you'll see that your offsets aren't correct, and the vertices belonging to your child bone are rendering at the base of the parent bone, etc. Anyhow, you'll likely be able to pinpoint your exact problem/issue a little more closely.


For me specifically, I ended up having to follow the numbers from the beginning, and print them out every step of the way, to finally realize that I was screwing up passing them into the shader, in the very, very last step (the one step I was stupidly not looking for the error in) :P But, animation is rather complex, and any error anywhere in your code will likely bork the entire mesh in pretty spectacular ways. Simplifying things will make debugging much easier.


For reference, here are some links to my same question with collada animation. Perhaps they'll be of some use, and the advice that posters gave will likely still apply.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!