Question

I'm having trouble loading joint data information from 'animation' node of collada file.

First, I try to load joints from 'library_visual_scenes' :

The first 2 joints look like that :

<visual_scene id="" name="">
    <node name="joint1" id="joint1" sid="joint1" type="JOINT">
        <translate sid="translate">0.000000 -2.000000 0.000000</translate>
        <rotate sid="jointOrientZ">0 0 1 90.000000</rotate>
        <rotate sid="rotateZ">0 0 1 0.000000</rotate>
        <rotate sid="rotateY">0 1 0 0.000000</rotate>
        <rotate sid="rotateX">1 0 0 0.000000</rotate>
        <scale sid="scale">1.000000 1.000000 1.000000</scale>
        <extra>
        <node name="joint2" id="joint2" sid="joint2" type="JOINT">
            <translate sid="translate">2.000000 0.000000 0.000000</translate>
            <rotate sid="rotateZ">0 0 1 0.000000</rotate>
            <rotate sid="rotateY">0 1 0 0.000000</rotate>
            <rotate sid="rotateX">1 0 0 0.000000</rotate>
            <scale sid="scale">1.000000 1.000000 1.000000</scale>
            <extra>

which went well !

Maya joints :

http://www.hostingpicture.fr/upload/c3eaf96247e99b90f9087b2d37fb509f.PNG

My joints :

I would like to put a picture but as a new member, i'm not allowed. You'll have to trust me on this case, in my engine, joints are in the same place as in maya.

Then, I try to load joints from 'animation' node. Here is the problem, I can't find any jointOrient.

<animation id="joint1-anim" name="joint1">
<animation>
    <source id="joint1-translate.Y-output">
        <float_array id="joint1-translate.Y-output-array" count="2">-2.000000 -2.000000</float_array>
<animation>
    <source id="joint1-rotateZ.ANGLE-output">
        <float_array id="joint1-rotateZ.ANGLE-output-array" count="2">0.000000 0.000000</float_array>

<animation id="joint2-anim" name="joint2">
<animation>
    <source id="joint2-translate.X-output">
        <float_array id="joint2-translate.X-output-array" count="2">2.000000 2.000000</float_array>

So after loading joints, they look like that :

http://www.hostingpicture.fr/image.php?nom=upload/b26b6f8ed80f2bcdb69645d400ac023d.png

Anybody here could help ?

Thanks.

(Sorry as I don't have more than 10 reputations, i'm not allowed to put pictures.)

Was it helpful?

Solution

I finally figured out the answer, for those who might be interested.

The visual_scene node from collada will give you the bind pose for your joints. So, I'm going to load visual_scene joint coordinates in a structure :

Something like that :

struct Pose
{
    vec3    translation,
            orientation,
            rotation,
            scale;
};

Pose    bind_pose;

Then I'm going to create another instanciation of "Pose" struct, with a constructor which take a Pose as parameter :

Pose    anim_pose(bind_pose);

So after construction, bind_pose from visual_scene and anim_pose are the same.

Then I'm going to iterate through all the animation node in library_animations, find the channel and get interested with :

  • the source data, which tell where to find joint animations info ("n" float(s) for "n" animation(s) :))
  • and the target joint.

    <channel source="#joint1-translate.X" target="joint1/translate.X"></channel>
    

This tell us (and that's where I was a little lost) that we are going to REPLACE the targeted value with the source value.

If the source data find in channel node is the same as the target data, ie. :

bind_pose.translation.x has -3.0 as a value after loading visual_scene data, and

<source id="joint1-translate.X-output">
    <float_array id="joint1-translate.X-output-array" count="1">-3.000000</float_array>

I do nothing.

If the source data is different from the target data, I simply replace in anim_pose with the good value.

And that's pretty much all you have to do to properly load animated joints from collada.

If you see anything wrong here, please tell me.

Hope this will help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top