关于ID3DXAnimationController接口函数解析

一个Track就是一个AnimationSet
ID3DXAnimationController* m_pAnimController;

 

HRESULT CSkinMesh::Init( LPCSTR pName, LPDIRECT3DDEVICE9 pDevice )
{
 m_pDevice = pDevice;
 HRESULT hr;
 V_RETURN( D3DXLoadMeshHierarchyFromX( pName, D3DXMESH_MANAGED, m_pDevice,
  &m_Alloc, NULL, &m_pFrameRoot, &m_pAnimController ) );
 // calculate each mesh 's bone matrix array,  for efficiency look up .
 V_RETURN( SetupBoneMatrixPointers( m_pFrameRoot ) );

 return S_OK;
}

 

这样m_pAnimController就能开始工作了

得到动画集数目:

m_pAnimController->GetNumAnimationSets();

 得到给定索引的动画集:

  LPD3DXANIMATIONSET pAnimSet = NULL;
 m_pAnimController->GetAnimationSet( index, &pAnimSet );

得到动画集的名称:

pAnimSet->GetName();
 /// 当前动画总播放时间
 double     m_lfTotalFrameTime;

m_lfTotalFrameTime = pAnimSet->GetPeriod();

通过名字得到动画集:

 LPD3DXANIMATIONSET pAnimSet = NULL;
 m_pAnimController->GetAnimationSetByName( pName, &pAnimSet );

改变动画集:

   DWORD dwNewTrack = 0;
   m_pAnimController->SetTrackAnimationSet( dwNewTrack, pAnimSet );
   m_pAnimController->SetTrackEnable( dwNewTrack, TRUE );


原文来自:http://blog.csdn.net/dotnet90/article/details/6105270

你可能感兴趣的:(动画,DirectX,Direct3D,游戏编程,骨骼动画)