Lets say that I have a fan and want to make the fan rotate fast and keep rotating at the same speed, I want to animate this rotation, so I used 3Ds Max to create animation and rotated the fan 360 degree so I can use this animation in the DirectX 9 program and play the animation with loop at any speed that I want.
In my DirectX 9 program I notice slight delay between the loop, so it doesn't look realistic at all, it's like the fan is rotating and stopping then rotating then stoping even the animation is looping, I'm trying to make the animation loop play at the same speed all the time.
This is a general problem that I'm having with animation looping, so the problem is not only about rotating a fan, it's about animation looping in general.
I'm loading .x file hierarchy, here is the code that I'm using for animation:
// Remember current animation m_currentAnimationSet=index; // Get the animation set from the controller LPD3DXANIMATIONSET set; m_animController->GetAnimationSet(index, &set); // 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 // Alternate tracks DWORD newTrack = ( m_currentTrack == 0 ? 1 : 0 ); // Assign to our track m_animController->SetTrackAnimationSet( newTrack, set ); set->Release(); // 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 ); // Remember current track m_currentTrack = newTrack;