3

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.)

4

1 回答 1

3

终于找到答案了,有兴趣的朋友可以看看。

collada 的 visual_scene 节点将为您提供关节的绑定姿势。因此,我将在结构中加载 visual_scene 关节坐标:

类似的东西:

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

Pose    bind_pose;

然后我将创建另一个“Pose”结构的实例化,使用一个以 Pose 作为参数的构造函数:

Pose    anim_pose(bind_pose);

所以构造后,来自visual_scene的bind_pose和anim_pose是一样的。

然后我将遍历 library_animations 中的所有动画节点,找到频道并对以下内容感兴趣:

  • 源数据,它告诉在哪里可以找到联合动画信息(“n”个浮点数用于“n”个动画:))
  • 和目标关节。

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

这告诉我们(这就是我有点迷茫的地方)我们将用源值替换目标值。

如果在通道节点中找到的源数据与目标数据相同,即。:

bind_pose.translation.x 在加载 visual_scene 数据后具有 -3.0 作为值,并且

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

我什么都不做。

如果源数据与目标数据不同,我只需将 anim_pose 中的值替换为好的值。

这就是从 collada 正确加载动画关节所需要做的几乎所有事情。

如果您在这里看到任何错误,请告诉我。

希望这会有所帮助。

于 2012-02-18T22:58:44.333 回答