Counter Strike : Global Offensive Source Code
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.

760 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. // {2A835771-BF4D-43f4-8E14-82A809F17D8A}
  14. DEFINE_GUID(IID_ID3DXBaseMesh,
  15. 0x2a835771, 0xbf4d, 0x43f4, 0x8e, 0x14, 0x82, 0xa8, 0x9, 0xf1, 0x7d, 0x8a);
  16. // {CCAE5C3B-4DD1-4d0f-997E-4684CA64557F}
  17. DEFINE_GUID(IID_ID3DXMesh,
  18. 0xccae5c3b, 0x4dd1, 0x4d0f, 0x99, 0x7e, 0x46, 0x84, 0xca, 0x64, 0x55, 0x7f);
  19. // {19FBE386-C282-4659-97BD-CB869B084A6C}
  20. DEFINE_GUID(IID_ID3DXPMesh,
  21. 0x19fbe386, 0xc282, 0x4659, 0x97, 0xbd, 0xcb, 0x86, 0x9b, 0x8, 0x4a, 0x6c);
  22. // {4E3CA05C-D4FF-4d11-8A02-16459E08F6F4}
  23. DEFINE_GUID(IID_ID3DXSPMesh,
  24. 0x4e3ca05c, 0xd4ff, 0x4d11, 0x8a, 0x2, 0x16, 0x45, 0x9e, 0x8, 0xf6, 0xf4);
  25. // {8DB06ECC-EBFC-408a-9404-3074B4773515}
  26. DEFINE_GUID(IID_ID3DXSkinMesh,
  27. 0x8db06ecc, 0xebfc, 0x408a, 0x94, 0x4, 0x30, 0x74, 0xb4, 0x77, 0x35, 0x15);
  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 = 0x1000, // same as D3DXMESH_VB_SHARE
  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. CONST 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. D3DXLoadMeshFromXInMemory(
  440. PBYTE Memory,
  441. DWORD SizeOfMemory,
  442. DWORD Options,
  443. LPDIRECT3DDEVICE8 pD3D,
  444. LPD3DXBUFFER *ppAdjacency,
  445. LPD3DXBUFFER *ppMaterials,
  446. DWORD *pNumMaterials,
  447. LPD3DXMESH *ppMesh);
  448. HRESULT WINAPI
  449. D3DXLoadMeshFromXResource(
  450. HMODULE Module,
  451. LPCTSTR Name,
  452. LPCTSTR Type,
  453. DWORD Options,
  454. LPDIRECT3DDEVICE8 pD3D,
  455. LPD3DXBUFFER *ppAdjacency,
  456. LPD3DXBUFFER *ppMaterials,
  457. DWORD *pNumMaterials,
  458. LPD3DXMESH *ppMesh);
  459. HRESULT WINAPI
  460. D3DXSaveMeshToX(
  461. LPSTR pFilename,
  462. LPD3DXMESH pMesh,
  463. CONST DWORD* pAdjacency,
  464. CONST LPD3DXMATERIAL pMaterials,
  465. DWORD NumMaterials,
  466. DWORD Format
  467. );
  468. HRESULT WINAPI
  469. D3DXCreatePMeshFromStream(
  470. IStream *pStream,
  471. DWORD Options,
  472. LPDIRECT3DDEVICE8 pD3DDevice,
  473. LPD3DXBUFFER *ppMaterials,
  474. DWORD* pNumMaterials,
  475. LPD3DXPMESH *ppPMesh);
  476. HRESULT WINAPI
  477. D3DXCreateSkinMesh(
  478. DWORD NumFaces,
  479. DWORD NumVertices,
  480. DWORD NumBones,
  481. DWORD Options,
  482. CONST DWORD *pDeclaration,
  483. LPDIRECT3DDEVICE8 pD3D,
  484. LPD3DXSKINMESH* ppSkinMesh);
  485. HRESULT WINAPI
  486. D3DXCreateSkinMeshFVF(
  487. DWORD NumFaces,
  488. DWORD NumVertices,
  489. DWORD NumBones,
  490. DWORD Options,
  491. DWORD FVF,
  492. LPDIRECT3DDEVICE8 pD3D,
  493. LPD3DXSKINMESH* ppSkinMesh);
  494. HRESULT WINAPI
  495. D3DXCreateSkinMeshFromMesh(
  496. LPD3DXMESH pMesh,
  497. DWORD numBones,
  498. LPD3DXSKINMESH* ppSkinMesh);
  499. HRESULT WINAPI
  500. D3DXLoadMeshFromXof(
  501. LPDIRECTXFILEDATA pXofObjMesh,
  502. DWORD Options,
  503. LPDIRECT3DDEVICE8 pD3DDevice,
  504. LPD3DXBUFFER *ppAdjacency,
  505. LPD3DXBUFFER *ppMaterials,
  506. DWORD *pNumMaterials,
  507. LPD3DXMESH *ppMesh);
  508. HRESULT WINAPI
  509. D3DXLoadSkinMeshFromXof(
  510. LPDIRECTXFILEDATA pxofobjMesh,
  511. DWORD Options,
  512. LPDIRECT3DDEVICE8 pD3D,
  513. LPD3DXBUFFER* ppAdjacency,
  514. LPD3DXBUFFER* ppMaterials,
  515. DWORD *pMatOut,
  516. LPD3DXBUFFER* ppBoneNames,
  517. LPD3DXBUFFER* ppBoneTransforms,
  518. LPD3DXSKINMESH* ppMesh);
  519. HRESULT WINAPI
  520. D3DXTessellateNPatches(
  521. LPD3DXMESH pMeshIn,
  522. CONST DWORD* pAdjacencyIn,
  523. FLOAT NumSegs,
  524. BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic
  525. LPD3DXMESH *ppMeshOut,
  526. LPD3DXBUFFER *ppAdjacencyOut);
  527. UINT WINAPI
  528. D3DXGetFVFVertexSize(DWORD FVF);
  529. HRESULT WINAPI
  530. D3DXDeclaratorFromFVF(
  531. DWORD FVF,
  532. DWORD Declaration[MAX_FVF_DECL_SIZE]);
  533. HRESULT WINAPI
  534. D3DXFVFFromDeclarator(
  535. CONST DWORD *pDeclarator,
  536. DWORD *pFVF);
  537. HRESULT WINAPI
  538. D3DXWeldVertices(
  539. CONST LPD3DXMESH pMesh,
  540. LPD3DXWELDEPSILONS pEpsilons,
  541. CONST DWORD *pAdjacencyIn,
  542. DWORD *pAdjacencyOut,
  543. DWORD* pFaceRemap,
  544. LPD3DXBUFFER *ppVertexRemap);
  545. typedef struct _D3DXINTERSECTINFO
  546. {
  547. DWORD FaceIndex; // index of face intersected
  548. FLOAT U; // Barycentric Hit Coordinates
  549. FLOAT V; // Barycentric Hit Coordinates
  550. FLOAT Dist; // Ray-Intersection Parameter Distance
  551. } D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO;
  552. HRESULT WINAPI
  553. D3DXIntersect(
  554. LPD3DXBASEMESH pMesh,
  555. CONST D3DXVECTOR3 *pRayPos,
  556. CONST D3DXVECTOR3 *pRayDir,
  557. BOOL *pHit, // True if any faces were intersected
  558. DWORD *pFaceIndex, // index of closest face intersected
  559. FLOAT *pU, // Barycentric Hit Coordinates
  560. FLOAT *pV, // Barycentric Hit Coordinates
  561. FLOAT *pDist, // Ray-Intersection Parameter Distance
  562. LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest)
  563. DWORD *pCountOfHits); // Number of entries in AllHits array
  564. HRESULT WINAPI
  565. D3DXIntersectSubset(
  566. LPD3DXBASEMESH pMesh,
  567. DWORD AttribId,
  568. CONST D3DXVECTOR3 *pRayPos,
  569. CONST D3DXVECTOR3 *pRayDir,
  570. BOOL *pHit, // True if any faces were intersected
  571. DWORD *pFaceIndex, // index of closest face intersected
  572. FLOAT *pU, // Barycentric Hit Coordinates
  573. FLOAT *pV, // Barycentric Hit Coordinates
  574. FLOAT *pDist, // Ray-Intersection Parameter Distance
  575. LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest)
  576. DWORD *pCountOfHits); // Number of entries in AllHits array
  577. HRESULT WINAPI D3DXSplitMesh
  578. (
  579. CONST LPD3DXMESH pMeshIn,
  580. CONST DWORD *pAdjacencyIn,
  581. CONST DWORD MaxSize,
  582. CONST DWORD Options,
  583. DWORD *pMeshesOut,
  584. LPD3DXBUFFER *ppMeshArrayOut,
  585. LPD3DXBUFFER *ppAdjacencyArrayOut,
  586. LPD3DXBUFFER *ppFaceRemapArrayOut,
  587. LPD3DXBUFFER *ppVertRemapArrayOut
  588. );
  589. BOOL D3DXIntersectTri
  590. (
  591. CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position
  592. CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position
  593. CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position
  594. CONST D3DXVECTOR3 *pRayPos, // Ray origin
  595. CONST D3DXVECTOR3 *pRayDir, // Ray direction
  596. FLOAT *pU, // Barycentric Hit Coordinates
  597. FLOAT *pV, // Barycentric Hit Coordinates
  598. FLOAT *pDist); // Ray-Intersection Parameter Distance
  599. BOOL WINAPI
  600. D3DXSphereBoundProbe(
  601. CONST D3DXVECTOR3 *pCenter,
  602. FLOAT Radius,
  603. CONST D3DXVECTOR3 *pRayPosition,
  604. CONST D3DXVECTOR3 *pRayDirection);
  605. BOOL WINAPI
  606. D3DXBoxBoundProbe(
  607. CONST D3DXVECTOR3 *pMin,
  608. CONST D3DXVECTOR3 *pMax,
  609. CONST D3DXVECTOR3 *pRayPosition,
  610. CONST D3DXVECTOR3 *pRayDirection);
  611. enum _D3DXERR {
  612. D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900),
  613. D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901),
  614. D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902),
  615. D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903),
  616. D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904),
  617. D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905),
  618. D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906),
  619. };
  620. #define D3DX_COMP_TANGENT_NONE 0xFFFFFFFF
  621. HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH InMesh,
  622. DWORD TexStage,
  623. LPD3DXMESH OutMesh,
  624. DWORD TexStageUVec,
  625. DWORD TexStageVVec,
  626. DWORD Wrap,
  627. DWORD *Adjacency);
  628. HRESULT WINAPI
  629. D3DXConvertMeshSubsetToSingleStrip
  630. (
  631. LPD3DXBASEMESH MeshIn,
  632. DWORD AttribId,
  633. DWORD IBOptions,
  634. LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer,
  635. DWORD *pNumIndices
  636. );
  637. HRESULT WINAPI
  638. D3DXConvertMeshSubsetToStrips
  639. (
  640. LPD3DXBASEMESH MeshIn,
  641. DWORD AttribId,
  642. DWORD IBOptions,
  643. LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer,
  644. DWORD *pNumIndices,
  645. LPD3DXBUFFER *ppStripLengths,
  646. DWORD *pNumStrips
  647. );
  648. #ifdef __cplusplus
  649. }
  650. #endif //__cplusplus
  651. #endif //__D3DX8MESH_H__