X files have skeletal animation, but I don't know if its possible to do what your saying.
Right now my game loads the models like one of the sdk samples with D3DXLoadMeshHierarchyFromX and builds the matrices for bones and animates them using the AnimationController class. Each specific animation has an animation set like walk,run,idle and I can change the current animation set with something like below. This changes from one set to another gradually instead of a very sudden change.
void AnimInstance::SetAnimationSet(unsigned int index) { if (index == m_CurrentAnimationSet) return; if (index >= m_Model->m_AnimationSetCount) index = 0; m_CurrentTime = 0.0f; m_AnimationController->ResetTime(); // Remember current animation m_CurrentAnimationSet = index; // Get the animation set from the controller LPD3DXANIMATIONSET set; m_AnimationController->GetAnimationSet(m_CurrentAnimationSet, &set ); // Alternate tracks DWORD newTrack = ( m_CurrentTrack == 0 ? 1 : 0 ); // Assign to our track m_AnimationController->SetTrackAnimationSet( newTrack, set ); set->Release(); // Clear any track events currently assigned to our two tracks m_AnimationController->UnkeyAllTrackEvents( m_CurrentTrack ); m_AnimationController->UnkeyAllTrackEvents( newTrack ); // Add an event key to disable the currently playing track kMoveTransitionTime seconds in the future m_AnimationController->KeyTrackEnable( m_CurrentTrack, FALSE, m_CurrentTime + m_MoveTransitionTime ); // Add an event key to change the speed right away so the animation completes in kMoveTransitionTime seconds m_AnimationController->KeyTrackSpeed( m_CurrentTrack, 0.0f, m_CurrentTime, m_MoveTransitionTime, D3DXTRANSITION_LINEAR ); // Add an event to change the weighting of the current track (the effect it has blended with the secon track) m_AnimationController->KeyTrackWeight( m_CurrentTrack, 0.0f, m_CurrentTime, m_MoveTransitionTime, D3DXTRANSITION_LINEAR ); // Enable the new track m_AnimationController->SetTrackEnable( newTrack, TRUE ); // Add an event key to set the speed of the track m_AnimationController->KeyTrackSpeed( newTrack, 1.0f, m_CurrentTime, m_MoveTransitionTime, 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_AnimationController->KeyTrackWeight( newTrack, 1.0f, m_CurrentTime, m_MoveTransitionTime, D3DXTRANSITION_LINEAR ); //m_AnimationController->KeyTrackPosition(newTrack,0.0f,m_CurrentTime + 0.001f); m_AnimationController->SetTrackPosition(newTrack,0.0f); // Remember current track m_CurrentTrack = newTrack; }
And my system right now is one bone per vertex.
My animations sets are idle,running and attack but I don't have an animation for attacking while running so if you press attack in the game the character plays the attack animation while moving which looks like sliding on the ground.
I don't know how to integrate bone weights in this system to do what I want. Separating the models seems like an easier way to me :/.
So If a character moves ill do;
lowerbody->setAnimationSet(RUN);
upperbody->setAnimationSet(RUN);
if they press attack button while running;
lowerbody->setAnimationSet(RUN);
lowerbody->setAnimationSet(ATTACK);
and so on.
I am still open to suggestions though :)