Direct3DX provides not one but several animation-oriented objects. When combined, these can help us code complex animation routines with little effort. An ID3DXAnimationController allows the user to define blending parameters when transitioning from one animation loop to another. The ID3DXAnimationSet allows you to work with a set of interpolators that can be used to compute animation in a multinode system. The GetInterpolatorByIndex, for example, receives an unsigned integer as its first parameter and returns as a second parameter the interpolator defined by that identifier. Then, the following call from the ID3DXInterpolator class allows you to, given an interpolator and a time value, retrieve rotation, translation, and scaling vectors that represent the state of the node at that time:
Notice how rotations are implemented via quaternions to avoid gimbal locking.
The ID3DXKeyFrameInterpolator interface inherits from the previous interface and provides extra interpolation controls for keyframed skeletal animation. We can retrieve the number of rotation, scaling, and translation key frames, and so on.
Additionally, the ID3DXSkinInfo interface can be used to implement weighted matrices for skeletal animation. We can define and retrieve bone influences, attach bones to vertices, and compute the resulting mesh after skinning is computed. The following call receives the list of matrices that represent bone transforms, as well as a list containing the inverse transpose of these matrices:
HRESULT UpdateSkinnedMesh( CONST D3DXMATRIX *pBoneTransforms, CONST D3DXMATRIX *pBoneInvTransposeTransforms, PVOID pVerticesSrc, PVOID pVerticesDst );
The third and fourth parameters represent the input and output vertex list.