Blending Two Animations

Started by
27 comments, last by Anddos 10 years, 7 months ago

@Tispe: I'm getting jerky transition between animations no matter what I do on the track, simply executing the following code make the animation change suddenly:


animController->SetTrackAnimationSet(0, walkAnim);
animController->SetTrackAnimationSet(1, reloadAnim);
Advertisement

No surprise, you are reloading the tracks. Once they are loaded, don't reload them. Just enable, disable, weight, or reposition them.

@Tispe: Well, that's not how I manage animations, I could have bunches of animations, maybe 10-12 different animation per character.

The way I'm working on it is that I ONLY assign currently playing animations to the track.

Ok, I have a suggestion then.

Before you reload your animation tracks, get the current track position using ::GetTrackDesc().

When you reapply the animation track, use ::SetTrackPosition() with the position you got from ::GetTrackDesc().

Do the same for the track weight, then the track should be where it left off.

You can do all of these steps by using SetTrackDesc() instead of :SetTrackPosition() :SetTrackWeight().


::GetTrackDesc();

//reload track

::SetTrackDesc();

@Tispe: Take a look at my code, it's manipulating the walking animation making the character walking animation restart from the beginning.

I don't know why, I'm just trying to add reload animation to the track (without doing anything to walk animation)


D3DXTRACK_DESC trackDesc;
m_animController->GetTrackDesc(currentTrack, &trackDesc);

m_animController->UnkeyAllTrackEvents(0);
m_animController->UnkeyAllTrackEvents(1);

m_animController->SetTrackAnimationSet(0, walkAnim); // Walking
m_animController->SetTrackAnimationSet(1, reloadAnim); // Reloading

// Keep walking (I don't want to do changes on walking animation here)
m_animController->SetTrackDesc(0, &trackDesc);

// Add reloading animation to the track
m_animController->SetTrackEnable(1, true);
m_animController->SetTrackWeight(1, 1.0f);
m_animController->KeyTrackWeight(1, 1.0f, m_currentTime, transitionTime, D3DXTRANSITION_LINEAR);
m_animController->SetTrackSpeed(1, 1.0f);

m_animController->GetTrackDesc(currentTrack, &trackDesc);

Make sure currentTrack is 0, since that is where you place the walking animation


m_animController->SetTrackWeight(1, 1.0f);

Change this to:


m_animController->SetTrackWeight(1, 0.0f);

Did it work?

@Tispe: No, same problem, it's restarting the walk animation (smoothly)

My intention is to ONLY play reload animation without restarting the walk animation or doing any manipulation to it.

Here is the code:


// Get walk animation track desc
D3DXTRACK_DESC trackDesc;
animController->GetTrackDesc(0, &trackDesc);

animController->UnkeyAllTrackEvents(0);
animController->UnkeyAllTrackEvents(1);

animController->SetTrackAnimationSet(0, walkAnim);
animController->SetTrackAnimationSet(1, reloadAnim);

// Walk animation
animController->SetTrackDesc(0, &trackDesc);

// Reload animation
animController->SetTrackEnable(1, true);
animController->SetTrackWeight(1, 0.0f);
animController->KeyTrackWeight(1, 1.0f, currentTime, transitionTime, D3DXTRANSITION_LINEAR);
animController->SetTrackSpeed(1, 1.0f);

I have a strong feeling your reload animation is trying to animate the lower body. Try to only play the reload animation and watch what happens to the legs, if they move then that would be the problem.

@Tispe: Nothing happens to the legs when I play reload animation, it only gets to it's default position (I don't have animated legs in reload animation)

Have you tested my code above?

I am curious is this your own model?, what program and exporter did you use for your .x 3D model?

Thanks if you can answer this

:)

This topic is closed to new replies.

Advertisement