加载Collada动画关节?

时间:2012-01-26 10:38:37

标签: c++ collada

我无法从collada文件的“动画”节点加载联合数据信息。

首先,我尝试从'library_visual_scenes'加载关节:

前两个关节看起来像这样:

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

进展顺利!

Maya关节:

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

我的关节:

我想拍一张照片,但作为新成员,我不被允许。在这种情况下,你必须相信我,在我的引擎中,关节与maya在同一个地方。

然后,我尝试从“动画”节点加载关节。这是问题,我找不到任何jointOient。

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

因此在加载关节后,它们看起来像这样:

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

这里有人可以帮忙吗?

感谢。

(对不起,因为我没有超过10个声誉,我不允许放照片。)

1 个答案:

答案 0 :(得分: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和anim_pose的bind_pose是相同的。

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

  • 源数据,告诉在哪里找到联合动画信息(“n”float(s)为“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正确加载动画关节的所有工作。

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

希望这会有所帮助。

相关问题