Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

752 lines
28 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: d3dx8mesh.h
  6. // Content: D3DX mesh types and functions
  7. //
  8. //////////////////////////////////////////////////////////////////////////////
  9. #include "d3dx8.h"
  10. #ifndef __D3DX8MESH_H__
  11. #define __D3DX8MESH_H__
  12. #include "dxfile.h" // defines LPDIRECTXFILEDATA
  13. // {A69BA991-1F7D-11d3-B929-00C04F68DC23}
  14. DEFINE_GUID(IID_ID3DXBaseMesh,
  15. 0xa69ba991, 0x1f7d, 0x11d3, 0xb9, 0x29, 0x0, 0xc0, 0x4f, 0x68, 0xdc, 0x23);
  16. // {9D84AC46-6B90-49a9-A721-085C7A3E3DAE}
  17. DEFINE_GUID(IID_ID3DXMesh,
  18. 0x9d84ac46, 0x6b90, 0x49a9, 0xa7, 0x21, 0x8, 0x5c, 0x7a, 0x3e, 0x3d, 0xae);
  19. // {15981AA8-1A05-48e3-BBE7-FF5D49654E3F}
  20. DEFINE_GUID(IID_ID3DXPMesh,
  21. 0x15981aa8, 0x1a05, 0x48e3, 0xbb, 0xe7, 0xff, 0x5d, 0x49, 0x65, 0x4e, 0x3f);
  22. // {BC3BBDE2-1F7D-11d3-B929-00C04F68DC23}
  23. DEFINE_GUID(IID_ID3DXSPMesh,
  24. 0xbc3bbde2, 0x1f7d, 0x11d3, 0xb9, 0x29, 0x0, 0xc0, 0x4f, 0x68, 0xdc, 0x23);
  25. // {82A53844-F322-409e-A2E9-992E1104069D}
  26. DEFINE_GUID(IID_ID3DXSkinMesh,
  27. 0x82a53844, 0xf322, 0x409e, 0xa2, 0xe9, 0x99, 0x2e, 0x11, 0x4, 0x6, 0x9d);
  28. // Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags
  29. enum _D3DXMESH {
  30. D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices.
  31. D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB.
  32. D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB.
  33. D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB.
  34. D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB.
  35. D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER
  36. D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB.
  37. D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB.
  38. D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB.
  39. D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB.
  40. D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER
  41. D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB.
  42. D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB.
  43. D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB.
  44. D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB.
  45. D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer
  46. D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinMesh::ConvertToBlendedMesh
  47. // Helper options
  48. D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM
  49. D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED
  50. D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY
  51. D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC
  52. D3DXMESH_SOFTWAREPROCESSING = 0x18000, // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING
  53. ;begin_internal
  54. D3DXMESH_VALIDBITS = 0x1cfff,
  55. D3DXMESH_VALIDCLONEBITS = 0x1dfff,
  56. D3DXMESH_VALIDBLENDEDBITS = 0x1efff,
  57. ;end_internal
  58. };
  59. // option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh
  60. enum _D3DXMESHSIMP
  61. {
  62. D3DXMESHSIMP_VERTEX = 0x1,
  63. D3DXMESHSIMP_FACE = 0x2,
  64. ;begin_internal
  65. D3DXMESHSIMP_VALIDBITS =0x03
  66. ;end_internal
  67. };
  68. enum _MAX_FVF_DECL_SIZE
  69. {
  70. MAX_FVF_DECL_SIZE = 20
  71. };
  72. typedef struct ID3DXBaseMesh *LPD3DXBASEMESH;
  73. typedef struct ID3DXMesh *LPD3DXMESH;
  74. typedef struct ID3DXPMesh *LPD3DXPMESH;
  75. typedef struct ID3DXSPMesh *LPD3DXSPMESH;
  76. typedef struct ID3DXSkinMesh *LPD3DXSKINMESH;
  77. typedef struct _D3DXATTRIBUTERANGE
  78. {
  79. DWORD AttribId;
  80. DWORD FaceStart;
  81. DWORD FaceCount;
  82. DWORD VertexStart;
  83. DWORD VertexCount;
  84. } D3DXATTRIBUTERANGE;
  85. typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE;
  86. #ifdef __cplusplus
  87. extern "C" {
  88. #endif //__cplusplus
  89. struct D3DXMATERIAL
  90. {
  91. D3DMATERIAL8 MatD3D;
  92. LPSTR pTextureFilename;
  93. };
  94. typedef struct D3DXMATERIAL *LPD3DXMATERIAL;
  95. #ifdef __cplusplus
  96. }
  97. #endif //__cplusplus
  98. typedef struct _D3DXATTRIBUTEWEIGHTS
  99. {
  100. FLOAT Position;
  101. FLOAT Boundary;
  102. FLOAT Normal;
  103. FLOAT Diffuse;
  104. FLOAT Specular;
  105. FLOAT Tex[8];
  106. } D3DXATTRIBUTEWEIGHTS;
  107. typedef D3DXATTRIBUTEWEIGHTS* LPD3DXATTRIBUTEWEIGHTS;
  108. enum _D3DXWELDEPSILONSFLAGS
  109. {
  110. D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping
  111. D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched
  112. // vertices so that both components identical AND if all components "equal"
  113. // remove one of the vertices
  114. D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal
  115. // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set
  116. // useful to modify vertices to be equal, but not allow vertices to be removed
  117. };
  118. typedef struct _D3DXWELDEPSILONS
  119. {
  120. FLOAT SkinWeights;
  121. FLOAT Normal;
  122. FLOAT Tex[8];
  123. DWORD Flags;
  124. } D3DXWELDEPSILONS;
  125. typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS;
  126. #undef INTERFACE
  127. #define INTERFACE ID3DXBaseMesh
  128. DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown)
  129. {
  130. // IUnknown
  131. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  132. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  133. STDMETHOD_(ULONG, Release)(THIS) PURE;
  134. // ID3DXBaseMesh
  135. STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE;
  136. STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE;
  137. STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE;
  138. STDMETHOD_(DWORD, GetFVF)(THIS) PURE;
  139. STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE;
  140. STDMETHOD_(DWORD, GetOptions)(THIS) PURE;
  141. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE;
  142. STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options,
  143. DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE;
  144. STDMETHOD(CloneMesh)(THIS_ DWORD Options,
  145. CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE;
  146. STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE;
  147. STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE;
  148. STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE;
  149. STDMETHOD(UnlockVertexBuffer)(THIS) PURE;
  150. STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE;
  151. STDMETHOD(UnlockIndexBuffer)(THIS) PURE;
  152. STDMETHOD(GetAttributeTable)(
  153. THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE;
  154. STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE;
  155. STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE;
  156. STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE;
  157. };
  158. #undef INTERFACE
  159. #define INTERFACE ID3DXMesh
  160. DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh)
  161. {
  162. // IUnknown
  163. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  164. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  165. STDMETHOD_(ULONG, Release)(THIS) PURE;
  166. // ID3DXBaseMesh
  167. STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE;
  168. STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE;
  169. STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE;
  170. STDMETHOD_(DWORD, GetFVF)(THIS) PURE;
  171. STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE;
  172. STDMETHOD_(DWORD, GetOptions)(THIS) PURE;
  173. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE;
  174. STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options,
  175. DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE;
  176. STDMETHOD(CloneMesh)(THIS_ DWORD Options,
  177. CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE;
  178. STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE;
  179. STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE;
  180. STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE;
  181. STDMETHOD(UnlockVertexBuffer)(THIS) PURE;
  182. STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE;
  183. STDMETHOD(UnlockIndexBuffer)(THIS) PURE;
  184. STDMETHOD(GetAttributeTable)(
  185. THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE;
  186. STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE;
  187. STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE;
  188. STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE;
  189. // ID3DXMesh
  190. STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE;
  191. STDMETHOD(UnlockAttributeBuffer)(THIS) PURE;
  192. STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut,
  193. DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap,
  194. LPD3DXMESH* ppOptMesh) PURE;
  195. STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut,
  196. DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE;
  197. };
  198. #undef INTERFACE
  199. #define INTERFACE ID3DXPMesh
  200. DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh)
  201. {
  202. // IUnknown
  203. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  204. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  205. STDMETHOD_(ULONG, Release)(THIS) PURE;
  206. // ID3DXBaseMesh
  207. STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE;
  208. STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE;
  209. STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE;
  210. STDMETHOD_(DWORD, GetFVF)(THIS) PURE;
  211. STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE;
  212. STDMETHOD_(DWORD, GetOptions)(THIS) PURE;
  213. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE;
  214. STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options,
  215. DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE;
  216. STDMETHOD(CloneMesh)(THIS_ DWORD Options,
  217. CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE;
  218. STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE;
  219. STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE;
  220. STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE;
  221. STDMETHOD(UnlockVertexBuffer)(THIS) PURE;
  222. STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE;
  223. STDMETHOD(UnlockIndexBuffer)(THIS) PURE;
  224. STDMETHOD(GetAttributeTable)(
  225. THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE;
  226. STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE;
  227. STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE;
  228. STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE;
  229. // ID3DXPMesh
  230. STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options,
  231. DWORD FVF, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE;
  232. STDMETHOD(ClonePMesh)(THIS_ DWORD Options,
  233. CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE;
  234. STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE;
  235. STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE;
  236. STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE;
  237. STDMETHOD_(DWORD, GetMinFaces)(THIS) PURE;
  238. STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE;
  239. STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE;
  240. STDMETHOD(Save)(THIS_ IStream *pStream, LPD3DXMATERIAL pMaterials, DWORD NumMaterials) PURE;
  241. STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut,
  242. DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap,
  243. LPD3DXMESH* ppOptMesh) PURE;
  244. STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE;
  245. STDMETHOD(TrimByFaces)(THIS_ DWORD NewFacesMin, DWORD NewFacesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE;
  246. STDMETHOD(TrimByVertices)(THIS_ DWORD NewVerticesMin, DWORD NewVerticesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE;
  247. STDMETHOD(GetAdjacency)(THIS_ DWORD* pAdjacency) PURE;
  248. };
  249. #undef INTERFACE
  250. #define INTERFACE ID3DXSPMesh
  251. DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown)
  252. {
  253. // IUnknown
  254. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  255. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  256. STDMETHOD_(ULONG, Release)(THIS) PURE;
  257. // ID3DXSPMesh
  258. STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE;
  259. STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE;
  260. STDMETHOD_(DWORD, GetFVF)(THIS) PURE;
  261. STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE;
  262. STDMETHOD_(DWORD, GetOptions)(THIS) PURE;
  263. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE;
  264. STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options,
  265. DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE;
  266. STDMETHOD(CloneMesh)(THIS_ DWORD Options,
  267. CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE;
  268. STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options,
  269. DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE;
  270. STDMETHOD(ClonePMesh)(THIS_ DWORD Options,
  271. CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE;
  272. STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE;
  273. STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE;
  274. STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE;
  275. STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE;
  276. STDMETHOD(GetVertexAttributeWeights)(THIS_ LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights) PURE;
  277. STDMETHOD(GetVertexWeights)(THIS_ FLOAT *pVertexWeights) PURE;
  278. };
  279. #define UNUSED16 (0xffff)
  280. #define UNUSED32 (0xffffffff)
  281. // ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags
  282. enum _D3DXMESHOPT {
  283. D3DXMESHOPT_COMPACT = 0x01000000,
  284. D3DXMESHOPT_ATTRSORT = 0x02000000,
  285. D3DXMESHOPT_VERTEXCACHE = 0x04000000,
  286. D3DXMESHOPT_STRIPREORDER = 0x08000000,
  287. D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices
  288. D3DXMESHOPT_SHAREVB = 0x20000000,
  289. ;begin_internal
  290. D3DXMESHOPT_VALIDBITS = 0x3f000000,
  291. D3DXMESHOPTINT_ALREADYATTRSORTED = 0x40000000,
  292. D3DXMESHOPTINT_INVERTFACEREMAP = 0x80000000,
  293. D3DXMESHOPTINT_VALIDBITS = 0xff000000,
  294. ;end_internal
  295. };
  296. // Subset of the mesh that has the same attribute and bone combination.
  297. // This subset can be rendered in a single draw call
  298. typedef struct _D3DXBONECOMBINATION
  299. {
  300. DWORD AttribId;
  301. DWORD FaceStart;
  302. DWORD FaceCount;
  303. DWORD VertexStart;
  304. DWORD VertexCount;
  305. DWORD* BoneId;
  306. } D3DXBONECOMBINATION, *LPD3DXBONECOMBINATION;
  307. #undef INTERFACE
  308. #define INTERFACE ID3DXSkinMesh
  309. DECLARE_INTERFACE_(ID3DXSkinMesh, IUnknown)
  310. {
  311. // IUnknown
  312. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  313. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  314. STDMETHOD_(ULONG, Release)(THIS) PURE;
  315. // ID3DXMesh
  316. STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE;
  317. STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE;
  318. STDMETHOD_(DWORD, GetFVF)(THIS) PURE;
  319. STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE;
  320. STDMETHOD_(DWORD, GetOptions)(THIS) PURE;
  321. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE;
  322. STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE;
  323. STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE;
  324. STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE;
  325. STDMETHOD(UnlockVertexBuffer)(THIS) PURE;
  326. STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE;
  327. STDMETHOD(UnlockIndexBuffer)(THIS) PURE;
  328. STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE;
  329. STDMETHOD(UnlockAttributeBuffer)(THIS) PURE;
  330. // ID3DXSkinMesh
  331. STDMETHOD_(DWORD, GetNumBones)(THIS) PURE;
  332. STDMETHOD(GetOriginalMesh)(THIS_ LPD3DXMESH* ppMesh) PURE;
  333. STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE;
  334. STDMETHOD_(DWORD, GetNumBoneInfluences)(THIS_ DWORD bone) PURE;
  335. STDMETHOD(GetBoneInfluence)(THIS_ DWORD bone, DWORD* vertices, FLOAT* weights) PURE;
  336. STDMETHOD(GetMaxVertexInfluences)(THIS_ DWORD* maxVertexInfluences) PURE;
  337. STDMETHOD(GetMaxFaceInfluences)(THIS_ DWORD* maxFaceInfluences) PURE;
  338. STDMETHOD(ConvertToBlendedMesh)(THIS_ DWORD Options,
  339. CONST LPDWORD pAdjacencyIn,
  340. LPDWORD pAdjacencyOut,
  341. DWORD* pNumBoneCombinations,
  342. LPD3DXBUFFER* ppBoneCombinationTable,
  343. DWORD* pFaceRemap,
  344. LPD3DXBUFFER *ppVertexRemap,
  345. LPD3DXMESH* ppMesh) PURE;
  346. STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ DWORD Options,
  347. CONST LPDWORD pAdjacencyIn,
  348. DWORD paletteSize,
  349. LPDWORD pAdjacencyOut,
  350. DWORD* pNumBoneCombinations,
  351. LPD3DXBUFFER* ppBoneCombinationTable,
  352. DWORD* pFaceRemap,
  353. LPD3DXBUFFER *ppVertexRemap,
  354. LPD3DXMESH* ppMesh) PURE;
  355. STDMETHOD(GenerateSkinnedMesh)(THIS_ DWORD Options,
  356. FLOAT minWeight,
  357. CONST LPDWORD pAdjacencyIn,
  358. LPDWORD pAdjacencyOut,
  359. DWORD* pFaceRemap,
  360. LPD3DXBUFFER *ppVertexRemap,
  361. LPD3DXMESH* ppMesh) PURE;
  362. STDMETHOD(UpdateSkinnedMesh)(THIS_ CONST D3DXMATRIX* pBoneTransforms, CONST D3DXMATRIX* pBoneInvTransforms, LPD3DXMESH pMesh) PURE;
  363. };
  364. #ifdef __cplusplus
  365. extern "C" {
  366. #endif //__cplusplus
  367. HRESULT WINAPI
  368. D3DXCreateMesh(
  369. DWORD NumFaces,
  370. DWORD NumVertices,
  371. DWORD Options,
  372. CONST DWORD *pDeclaration,
  373. LPDIRECT3DDEVICE8 pD3D,
  374. LPD3DXMESH* ppMesh);
  375. HRESULT WINAPI
  376. D3DXCreateMeshFVF(
  377. DWORD NumFaces,
  378. DWORD NumVertices,
  379. DWORD Options,
  380. DWORD FVF,
  381. LPDIRECT3DDEVICE8 pD3D,
  382. LPD3DXMESH* ppMesh);
  383. HRESULT WINAPI
  384. D3DXCreateSPMesh(
  385. LPD3DXMESH pMesh,
  386. CONST DWORD* pAdjacency,
  387. CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights,
  388. CONST FLOAT *pVertexWeights,
  389. LPD3DXSPMESH* ppSMesh);
  390. // clean a mesh up for simplification, try to make manifold
  391. HRESULT WINAPI
  392. D3DXCleanMesh(
  393. LPD3DXMESH pMeshIn,
  394. CONST DWORD* pAdjacencyIn,
  395. LPD3DXMESH* ppMeshOut,
  396. DWORD* pAdjacencyOut,
  397. LPD3DXBUFFER* ppErrorsAndWarnings);
  398. HRESULT WINAPI
  399. D3DXValidMesh(
  400. LPD3DXMESH pMeshIn,
  401. CONST DWORD* pAdjacency,
  402. LPD3DXBUFFER* ppErrorsAndWarnings);
  403. HRESULT WINAPI
  404. D3DXGeneratePMesh(
  405. LPD3DXMESH pMesh,
  406. CONST DWORD* pAdjacency,
  407. CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights,
  408. CONST FLOAT *pVertexWeights,
  409. DWORD MinValue,
  410. DWORD Options,
  411. LPD3DXPMESH* ppPMesh);
  412. HRESULT WINAPI
  413. D3DXSimplifyMesh(
  414. LPD3DXMESH pMesh,
  415. CONST DWORD* pAdjacency,
  416. CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights,
  417. CONST FLOAT *pVertexWeights,
  418. DWORD MinValue,
  419. DWORD Options,
  420. LPD3DXMESH* ppMesh);
  421. HRESULT WINAPI
  422. D3DXComputeBoundingSphere(
  423. PVOID pPointsFVF,
  424. DWORD NumVertices,
  425. DWORD FVF,
  426. D3DXVECTOR3 *pCenter,
  427. FLOAT *pRadius);
  428. HRESULT WINAPI
  429. D3DXComputeBoundingBox(
  430. PVOID pPointsFVF,
  431. DWORD NumVertices,
  432. DWORD FVF,
  433. D3DXVECTOR3 *pMin,
  434. D3DXVECTOR3 *pMax);
  435. HRESULT WINAPI
  436. D3DXComputeNormals(
  437. LPD3DXBASEMESH pMesh,
  438. DWORD *pAdjacency);
  439. HRESULT WINAPI
  440. D3DXCreateBuffer(
  441. DWORD NumBytes,
  442. LPD3DXBUFFER *ppBuffer);
  443. HRESULT WINAPI
  444. D3DXLoadMeshFromX(
  445. LPSTR pFilename,
  446. DWORD Options,
  447. LPDIRECT3DDEVICE8 pD3D,
  448. LPD3DXBUFFER *ppAdjacency,
  449. LPD3DXBUFFER *ppMaterials,
  450. DWORD *pNumMaterials,
  451. LPD3DXMESH *ppMesh);
  452. HRESULT WINAPI
  453. D3DXSaveMeshToX(
  454. LPSTR pFilename,
  455. LPD3DXMESH pMesh,
  456. CONST DWORD* pAdjacency,
  457. CONST LPD3DXMATERIAL pMaterials,
  458. DWORD NumMaterials,
  459. DWORD Format
  460. );
  461. HRESULT WINAPI
  462. D3DXCreatePMeshFromStream(
  463. IStream *pStream,
  464. DWORD Options,
  465. LPDIRECT3DDEVICE8 pD3DDevice,
  466. LPD3DXBUFFER *ppMaterials,
  467. DWORD* pNumMaterials,
  468. LPD3DXPMESH *ppPMesh);
  469. HRESULT WINAPI
  470. D3DXCreateSkinMesh(
  471. DWORD NumFaces,
  472. DWORD NumVertices,
  473. DWORD NumBones,
  474. DWORD Options,
  475. CONST DWORD *pDeclaration,
  476. LPDIRECT3DDEVICE8 pD3D,
  477. LPD3DXSKINMESH* ppSkinMesh);
  478. HRESULT WINAPI
  479. D3DXCreateSkinMeshFVF(
  480. DWORD NumFaces,
  481. DWORD NumVertices,
  482. DWORD NumBones,
  483. DWORD Options,
  484. DWORD FVF,
  485. LPDIRECT3DDEVICE8 pD3D,
  486. LPD3DXSKINMESH* ppSkinMesh);
  487. HRESULT WINAPI
  488. D3DXCreateSkinMeshFromMesh(
  489. LPD3DXMESH pMesh,
  490. DWORD numBones,
  491. LPD3DXSKINMESH* ppSkinMesh);
  492. HRESULT WINAPI
  493. D3DXLoadMeshFromXof(
  494. LPDIRECTXFILEDATA pXofObjMesh,
  495. DWORD Options,
  496. LPDIRECT3DDEVICE8 pD3DDevice,
  497. LPD3DXBUFFER *ppAdjacency,
  498. LPD3DXBUFFER *ppMaterials,
  499. DWORD *pNumMaterials,
  500. LPD3DXMESH *ppMesh);
  501. HRESULT WINAPI
  502. D3DXLoadSkinMeshFromXof(
  503. LPDIRECTXFILEDATA pxofobjMesh,
  504. DWORD Options,
  505. LPDIRECT3DDEVICE8 pD3D,
  506. LPD3DXBUFFER* ppAdjacency,
  507. LPD3DXBUFFER* ppMaterials,
  508. DWORD *pMatOut,
  509. LPD3DXBUFFER* ppBoneNames,
  510. LPD3DXBUFFER* ppBoneTransforms,
  511. LPD3DXSKINMESH* ppMesh);
  512. HRESULT WINAPI
  513. D3DXTessellateNPatches(
  514. LPD3DXMESH pMeshIn,
  515. CONST DWORD* pAdjacencyIn,
  516. FLOAT NumSegs,
  517. BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic
  518. LPD3DXMESH *ppMeshOut,
  519. LPD3DXBUFFER *ppAdjacencyOut);
  520. UINT WINAPI
  521. D3DXGetFVFVertexSize(DWORD FVF);
  522. HRESULT WINAPI
  523. D3DXDeclaratorFromFVF(
  524. DWORD FVF,
  525. DWORD Declaration[MAX_FVF_DECL_SIZE]);
  526. HRESULT WINAPI
  527. D3DXFVFFromDeclarator(
  528. CONST DWORD *pDeclarator,
  529. DWORD *pFVF);
  530. HRESULT WINAPI
  531. D3DXWeldVertices(
  532. CONST LPD3DXMESH pMesh,
  533. LPD3DXWELDEPSILONS pEpsilons,
  534. CONST DWORD *pAdjacencyIn,
  535. DWORD *pAdjacencyOut,
  536. DWORD* pFaceRemap,
  537. LPD3DXBUFFER *ppVertexRemap);
  538. typedef struct _D3DXINTERSECTINFO
  539. {
  540. DWORD FaceIndex; // index of face intersected
  541. FLOAT U; // Barycentric Hit Coordinates
  542. FLOAT V; // Barycentric Hit Coordinates
  543. FLOAT Dist; // Ray-Intersection Parameter Distance
  544. } D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO;
  545. HRESULT WINAPI
  546. D3DXIntersect(
  547. LPD3DXBASEMESH pMesh,
  548. CONST D3DXVECTOR3 *pRayPos,
  549. CONST D3DXVECTOR3 *pRayDir,
  550. BOOL *pHit, // True if any faces were intersected
  551. DWORD *pFaceIndex, // index of closest face intersected
  552. FLOAT *pU, // Barycentric Hit Coordinates
  553. FLOAT *pV, // Barycentric Hit Coordinates
  554. FLOAT *pDist, // Ray-Intersection Parameter Distance
  555. LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest)
  556. DWORD *pCountOfHits); // Number of entries in AllHits array
  557. HRESULT WINAPI
  558. D3DXIntersectSubset(
  559. LPD3DXBASEMESH pMesh,
  560. DWORD AttribId,
  561. CONST D3DXVECTOR3 *pRayPos,
  562. CONST D3DXVECTOR3 *pRayDir,
  563. BOOL *pHit, // True if any faces were intersected
  564. DWORD *pFaceIndex, // index of closest face intersected
  565. FLOAT *pU, // Barycentric Hit Coordinates
  566. FLOAT *pV, // Barycentric Hit Coordinates
  567. FLOAT *pDist, // Ray-Intersection Parameter Distance
  568. LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest)
  569. DWORD *pCountOfHits); // Number of entries in AllHits array
  570. HRESULT WINAPI D3DXSplitMesh
  571. (
  572. CONST LPD3DXMESH pMeshIn,
  573. CONST DWORD *pAdjacencyIn,
  574. CONST DWORD MaxSize,
  575. CONST DWORD Options,
  576. DWORD *pMeshesOut,
  577. LPD3DXBUFFER *ppMeshArrayOut,
  578. LPD3DXBUFFER *ppAdjacencyArrayOut,
  579. LPD3DXBUFFER *ppFaceRemapArrayOut,
  580. LPD3DXBUFFER *ppVertRemapArrayOut
  581. );
  582. BOOL D3DXIntersectTri
  583. (
  584. CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position
  585. CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position
  586. CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position
  587. CONST D3DXVECTOR3 *pRayPos, // Ray origin
  588. CONST D3DXVECTOR3 *pRayDir, // Ray direction
  589. FLOAT *pU, // Barycentric Hit Coordinates
  590. FLOAT *pV, // Barycentric Hit Coordinates
  591. FLOAT *pDist); // Ray-Intersection Parameter Distance
  592. BOOL WINAPI
  593. D3DXSphereBoundProbe(
  594. CONST D3DXVECTOR3 *pCenter,
  595. FLOAT Radius,
  596. CONST D3DXVECTOR3 *pRayPosition,
  597. CONST D3DXVECTOR3 *pRayDirection);
  598. BOOL WINAPI
  599. D3DXBoxBoundProbe(
  600. CONST D3DXVECTOR3 *pMin,
  601. CONST D3DXVECTOR3 *pMax,
  602. CONST D3DXVECTOR3 *pRayPosition,
  603. CONST D3DXVECTOR3 *pRayDirection);
  604. enum _D3DXERR {
  605. D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900),
  606. D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901),
  607. D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902),
  608. D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903),
  609. D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904),
  610. D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905),
  611. D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906),
  612. };
  613. #define D3DX_COMP_TANGENT_NONE 0xFFFFFFFF
  614. HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH InMesh,
  615. DWORD TexStage,
  616. LPD3DXMESH OutMesh,
  617. DWORD TexStageUVec,
  618. DWORD TexStageVVec,
  619. DWORD Wrap,
  620. DWORD *Adjacency);
  621. HRESULT WINAPI
  622. D3DXConvertMeshSubsetToSingleStrip
  623. (
  624. LPD3DXBASEMESH MeshIn,
  625. DWORD AttribId,
  626. DWORD IBOptions,
  627. LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer,
  628. DWORD *pNumIndices
  629. );
  630. HRESULT WINAPI
  631. D3DXConvertMeshSubsetToStrips
  632. (
  633. LPD3DXBASEMESH MeshIn,
  634. DWORD AttribId,
  635. DWORD IBOptions,
  636. LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer,
  637. DWORD *pNumIndices,
  638. LPD3DXBUFFER *ppStripLengths,
  639. DWORD *pNumStrips
  640. );
  641. #ifdef __cplusplus
  642. }
  643. #endif //__cplusplus
  644. #endif //__D3DX8MESH_H__