正在加载 Collada 动画关节?

发布于 2024-12-29 03:13:38 字数 2382 浏览 2 评论 0原文

我在从 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 中的关节位于相同的位置。

然后,我尝试从“动画”节点加载关节。问题是,我找不到任何 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>

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

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

这里有人可以帮忙吗?

谢谢。

(抱歉,因为我的声望不超过10个,所以我不可以放图片。)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

貪欢 2025-01-05 03:13:38

我终于为那些可能感兴趣的人找到了答案。

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

类似的东西:

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

Pose    bind_pose;

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

Pose    anim_pose(bind_pose);

因此在构造之后,bind_pose 来自Visual_scene 和 anim_pose 是相同的。

然后我将迭代library_animations中的所有动画节点,找到通道并感兴趣:

  • 源数据,它告诉在哪里可以找到联合动画信息(“n”float(s)代表“n”动画) ) :))
  • 和目标关节。

    <通道源=“#joint1-translate.X”目标=“joint1/translate.X”>
    

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

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

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 正确加载动画关节所需要做的全部工作。

如果您发现这里有任何问题,请告诉我。

希望这会有所帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文