开发者

Additive Skeleton Animation [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

Im having a hard time to code additive skeletal animation.

Everything work fine if I playback each animation separately so I know that the pose of each animation is correct... What I can't figure out is how to additively blend them.

I got the following:

void MD5ANIM_additive_blending( MD5MD5ANIM *md5, MD5MD5ANIMJOINT *dst, MD5MD5ANIMJOINT *pose0, MD5MD5ANIMJOINT *pose1 )
{
unsigned int i = 0;

while( i != md5->n_joint )
{
    vec3 location;

    quat4 quaternion;

    // The joints location difference
    vec3_subtract( &location, &pose1[ i ].location, &pose0[ i ].location );

    // Add the joint location difference to the first pose to create additive new pose.
    vec3_add( &dst[ i ].location, &pose0[ i ].location, &location );


    // The quaternion difference
    quat4_sub开发者_如何学JAVAtract( &quaternion, &pose0[ i ].quaternion, &pose1[ i ].quaternion );

    // Add the joint quaternion difference to the first pose to create additive new pose.
    quat4_add( &dst[ i ].quaternion, &pose0[ i ].quaternion, &quaternion );

    quat4_normalize( &dst[ i ].quaternion,
            &dst[ i ].quaternion );

    ++i;
}
}

Anybody can point me out where I get it wrong. From what I understand additively blending to skeleton pose is as simple as:

additive_pose = pose0 + ( pose0 - pose1 )

What I am doing wrong?


Lets say you have a walk animation, and another one with a hand in the air. So basically walk + hand = walk with hand in the air

There are two possibilities:

  1. Your walk animation does not affect the same bones that your hand animation does.

  2. Your walk animation does affect the same bones that your hand animation does.

Case 1

In this case, you have two options. Your pose structure can have a bitfield telling whether a particular bone is in it. Thus you can compose two poses by seeing which pose has bones that the other one doesn't provide.

If there is no bitfield or other information saying whether a pose actually contains bone data, then you can do this. Any bone for a pose that was not in the animation should be identity. Therefore, you can multiply the bones of the two poses together via quaternion multiplication.

Case 2

Since there is overlap between the two animations, someone has to win. Basically, you have to know what bones the layered animation has and replace the data from the lower pose with ones from the higher pose.

The code you posted is gibberish. In general, if you have two orientation quaternions and think that adding/subtracting them is a good idea, then you're either doing some complex optimizations (in which case you know what you're doing), or you're doing something very wrong.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜