Sign in to follow this  
derek7

If I have many animationSet ,how to indicate one of them to use?

Recommended Posts

derek7    100
I use ID3DXAnimationController to do animation.there are many animation set in a ID3DXAnimationController object.how to select one of them to update the current frame data?

Share this post


Link to post
Share on other sites
derek7    100
I do search MSDN,but infomation is not enough.

I just know ID3DXAnimationController Interface have a frame structure .and many animationset that is key frame is used to create "pose" of current time drived by AdvanceTime mothod.

but by default it just use first animationset in .x file.so how to indicate the ID3DXAnimationController use other animationset to create "pose" of current time.

Share this post


Link to post
Share on other sites
GeekPlusPlus    124
Here's some source out of a tutorial you can find here


void CXfileEntity::SetAnimationSet(UINT index)
{
if (index>=GetNumberOfAnimationSets())
return;

m_currentAnimationSet=index;

// Get the animation set
LPD3DXANIMATIONSET set;
m_animController->GetAnimationSet(m_currentAnimationSet, &set );

DWORD newTrack = ( m_currentTrack == 0 ? 1 : 0 );

// Assign to our track
m_animController->SetTrackAnimationSet( newTrack, set );
set->Release();

// Note: for a smooth transition between animation sets we can use two tracks and assign the new set to the track
// not currently playing then insert Keys into the KeyTrack to do the transition between the tracks
// tracks can be mixed together so we can gradually change into the new animation

// Clear any track events currently assigned to our two tracks
m_animController->UnkeyAllTrackEvents( m_currentTrack );
m_animController->UnkeyAllTrackEvents( newTrack );

// Add an event key to disable the currently playing track kMoveTransitionTime seconds in the future
m_animController->KeyTrackEnable( m_currentTrack, FALSE, m_currentTime + kMoveTransitionTime );
// Add an event key to change the speed right away so the animation completes in kMoveTransitionTime seconds
m_animController->KeyTrackSpeed( m_currentTrack, 0.0f, m_currentTime, kMoveTransitionTime, D3DXTRANSITION_LINEAR );
// Add an event to change the weighting of the current track (the effect it has blended with the secon track)
m_animController->KeyTrackWeight( m_currentTrack, 0.0f, m_currentTime, kMoveTransitionTime, D3DXTRANSITION_LINEAR );

// Enable the new track
m_animController->SetTrackEnable( newTrack, TRUE );
// Add an event key to set the speed of the track
m_animController->KeyTrackSpeed( newTrack, 1.0f, m_currentTime, kMoveTransitionTime, D3DXTRANSITION_LINEAR );
// Add an event to change the weighting of the current track (the effect it has blended with the first track)
// As you can see this will go from 0 effect to total effect(1.0f) in kMoveTransitionTime seconds and the first track goes from
// total to 0.0f in the same time.
m_animController->KeyTrackWeight( newTrack, 1.0f, m_currentTime, kMoveTransitionTime, D3DXTRANSITION_LINEAR );

m_currentTrack = newTrack;

}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this