Collada Skeleton Rendering

Started by
3 comments, last by Ashaman73 11 years, 9 months ago
Hi.

I am trying to write a Collada parser and renderer in C++ with OpenGL, and have got geometry and texturing working so far.

I have also wrote a parser for the skeleton in the Collada file, and want to render it in its static shape, before I go about and implement animation. Is this possible or will I need to parse the animation library as well? What do I need to do to convert collada's matrices into a form OpenGL will understand?

So far I have tried looping through the main bone, and through its children and drawing lines between all the positions, but my understanding is not too great on how each matrix in the Collada file relates to its parent and I end up with a mess of lines which I can make no sense of.

Looking forward to your suggestions.
2rockon
Advertisement
I would recommend to use the Assimp library. It will do the Collada parsing for you. Eventually (for a commercial application), you would want to make your own file format.

To get an animation up and running is hard work. I documented some of my efforts at: http://ephenationopengl.blogspot.se/2012/06/doing-animations-in-opengl.html.
[size=2]Current project: Ephenation.
[size=2]Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/
Typically a skeleton is represented as a heirarchy of transforms. Each matrix is multiplied by all parent transforms, back up to the root.

The point you want to draw for a joint is (0,0,0,1) transformed by that joint's transform multiplied by the multiplication of ALL of its parent transforms. You might need to reverse the order depending on how you've set up matrices.

So, for a bone with matrix X, You'd draw a line from (Parent of Parent of X)*(Parent of X)(0,0,0,1) to (Parent of parent of X)*(Parent of X)*X*(0,0,0,1)
I am actually parsing the Collada file into my own structure, which also has methods to read/write itself from the disk from a binary file format I have designed. I have so far got the scene, library_visual_scenes and library_visual_scenes parsed, which I believe would be enough to get a static skeleton to render.

If I had the 16 number matrix, for example from one of my own models:
[source lang="xml"]<matrix>0.9971483 0.07496392 -0.008701464 2.835394 -0.0749609 0.9971862 6.72192e-4 -0.2716522 0.00872737 -1.80052e-5 0.9999619 5.72205e-6 0 0 0 1</matrix>[/source]
which components make up position, rotation etc, is what is really confusing me, as I cannot seem to find what each component means, or how I can give it to OpenGL to simply draw.

Many Thanks
2rockon
The 16 number will form up a matrix like this:
[source lang="java"]
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
[/source]
(3,7,11) will be the position vector.

(0 1 2)
(4 5 6)
(8 9 10)
the rotation matrix.

(0 4 8) the right vector
(1 5 9) the up vector
(2 6 10) the look at vector

This topic is closed to new replies.

Advertisement