AllocateHierarchy.h
上传用户:junlon
上传日期:2022-01-05
资源大小:39075k
文件大小:3k
源码类别:

DirextX编程

开发平台:

Visual C++

  1. //--------------------------------------------------------------------------------------
  2. // 头文件: AllocateHierarchy.h , 作者:曾凡喜
  3. //
  4. // 该头文件实现了D3DXFRAME_DERIVED结构体,D3DXMESHCONTAINER_DERIVED结构体,CAllocateHierarchy类
  5. //
  6. // 分别派生自D3DXFRAME结构体,D3DXMESHCONTAINER结构体,ID3DXAllocateHierarchy虚基类
  7. //
  8. // 版权归作者所有,未经允许不得利用源代码进行任何商业活动
  9. //
  10. // 完成时间:2008-05-03
  11. //--------------------------------------------------------------------------------------
  12. #ifndef __AllocateHierarchy_H__
  13. #define __AllocateHierarchy_H__
  14. #include "zfxd3dUtility.h"
  15. //-----------------------------------------------------------------------------
  16. // 继承自DXDXFRAME结构的结构
  17. //-----------------------------------------------------------------------------
  18. struct D3DXFRAME_DERIVED: public D3DXFRAME
  19. {
  20.     D3DXMATRIXA16 CombinedTransformationMatrix;//组合变换矩阵
  21. };
  22. //-----------------------------------------------------------------------------
  23. // 继承自D3DXMESHCONTAINER结构的结构
  24. //-----------------------------------------------------------------------------
  25. struct D3DXMESHCONTAINER_DERIVED: public D3DXMESHCONTAINER
  26. {
  27.     LPDIRECT3DTEXTURE9*  ppTextures;            //纹理数组
  28.     LPD3DXMESH           pOrigMesh;             //原始网格
  29. DWORD                NumInfl;               //每个顶点最多受多少骨骼的影响
  30.     DWORD                NumAttributeGroups;    //属性组数量,即子网格数量
  31.     LPD3DXBUFFER         pBoneCombinationBuf;   //骨骼结合表
  32.     D3DXMATRIX**         ppBoneMatrixPtrs;      //存放骨骼的组合变换矩阵
  33.     D3DXMATRIX*          pBoneOffsetMatrices;   //存放骨骼的初始变换矩阵
  34. DWORD                NumPaletteEntries;     //骨骼数量上限
  35. bool                 UseSoftwareVP;         //标识是否使用软件顶点处理
  36. };
  37. //-----------------------------------------------------------------------------
  38. // 该类用来从.X文件加载框架层次和网格模型数据,继承自ID3DXAllocateHierarchy接口。
  39. // 该类的CreateFrame()和CreateMeshContainer()函数在D3DXLoadMeshHierarchyFromX()函数执行时
  40. // 由框架自动执行,无需显式调用。
  41. // 同理,DestroyFrame()和DestroyMeshContainer()在D3DXFrameDestroy函数执行时由框架自动执行,
  42. // 无需显式调用。
  43. //-----------------------------------------------------------------------------
  44. class CAllocateHierarchy: public ID3DXAllocateHierarchy
  45. {
  46. private:
  47. HRESULT GenerateSkinnedMesh(D3DXMESHCONTAINER_DERIVED *pMeshContainer, LPDIRECT3DDEVICE9 pd3dDevice);
  48. // 拷贝字符串
  49. HRESULT AllocateName( LPCSTR Name, LPSTR *pNewName );
  50. public:
  51. STDMETHOD(CreateFrame)(THIS_ LPCSTR Name, LPD3DXFRAME *ppNewFrame);
  52. STDMETHOD(CreateMeshContainer)( THIS_ LPCSTR              Name, 
  53.                                     CONST D3DXMESHDATA*       pMeshData,
  54.                                     CONST D3DXMATERIAL*       pMaterials, 
  55.                                     CONST D3DXEFFECTINSTANCE* pEffectInstances, 
  56.                                     DWORD                     NumMaterials, 
  57.                                     CONST DWORD *             pAdjacency, 
  58.                                     LPD3DXSKININFO pSkinInfo, 
  59.                                     LPD3DXMESHCONTAINER *ppNewMeshContainer);    
  60.     STDMETHOD(DestroyFrame)(THIS_ LPD3DXFRAME pFrameToFree);
  61.     STDMETHOD(DestroyMeshContainer)(THIS_ LPD3DXMESHCONTAINER pMeshContainerBase);
  62. };
  63. #endif  //__AllocateHierarchy_H__