Leaked source code of windows server 2003
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.

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