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.

286 lines
10 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: d3dx10mesh.h
  6. // Content: D3DX10 mesh types and functions
  7. //
  8. //////////////////////////////////////////////////////////////////////////////
  9. #include "d3dx10.h"
  10. #ifndef __D3DX10MESH_H__
  11. #define __D3DX10MESH_H__
  12. // {7ED943DD-52E8-40b5-A8D8-76685C406330}
  13. DEFINE_GUID(IID_ID3DX10BaseMesh,
  14. 0x7ed943dd, 0x52e8, 0x40b5, 0xa8, 0xd8, 0x76, 0x68, 0x5c, 0x40, 0x63, 0x30);
  15. // {04B0D117-1041-46b1-AA8A-3952848BA22E}
  16. DEFINE_GUID(IID_ID3DX10MeshBuffer,
  17. 0x4b0d117, 0x1041, 0x46b1, 0xaa, 0x8a, 0x39, 0x52, 0x84, 0x8b, 0xa2, 0x2e);
  18. // {4020E5C2-1403-4929-883F-E2E849FAC195}
  19. DEFINE_GUID(IID_ID3DX10Mesh,
  20. 0x4020e5c2, 0x1403, 0x4929, 0x88, 0x3f, 0xe2, 0xe8, 0x49, 0xfa, 0xc1, 0x95);
  21. // {8875769A-D579-4088-AAEB-534D1AD84E96}
  22. DEFINE_GUID(IID_ID3DX10PMesh,
  23. 0x8875769a, 0xd579, 0x4088, 0xaa, 0xeb, 0x53, 0x4d, 0x1a, 0xd8, 0x4e, 0x96);
  24. // {667EA4C7-F1CD-4386-B523-7C0290B83CC5}
  25. DEFINE_GUID(IID_ID3DX10SPMesh,
  26. 0x667ea4c7, 0xf1cd, 0x4386, 0xb5, 0x23, 0x7c, 0x2, 0x90, 0xb8, 0x3c, 0xc5);
  27. // {3CE6CC22-DBF2-44f4-894D-F9C34A337139}
  28. DEFINE_GUID(IID_ID3DX10PatchMesh,
  29. 0x3ce6cc22, 0xdbf2, 0x44f4, 0x89, 0x4d, 0xf9, 0xc3, 0x4a, 0x33, 0x71, 0x39);
  30. // Mesh options - lower 3 bytes only, upper byte used by _D3DX10MESHOPT option flags
  31. enum _D3DX10_MESH {
  32. D3DX10_MESH_32_BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices.
  33. D3DX10_MESH_GS_ADJACENCY = 0x004, // If set, mesh contains GS adjacency info. Not valid on input.
  34. };
  35. typedef struct _D3DX10_ATTRIBUTE_RANGE
  36. {
  37. UINT AttribId;
  38. UINT FaceStart;
  39. UINT FaceCount;
  40. UINT VertexStart;
  41. UINT VertexCount;
  42. } D3DX10_ATTRIBUTE_RANGE;
  43. typedef D3DX10_ATTRIBUTE_RANGE* LPD3DX10_ATTRIBUTE_RANGE;
  44. typedef enum _D3DX10_MESH_DISCARD_FLAGS
  45. {
  46. D3DX10_MESH_DISCARD_ATTRIBUTE_BUFFER = 0x01,
  47. D3DX10_MESH_DISCARD_ATTRIBUTE_TABLE = 0x02,
  48. D3DX10_MESH_DISCARD_POINTREPS = 0x04,
  49. D3DX10_MESH_DISCARD_ADJACENCY = 0x08,
  50. D3DX10_MESH_DISCARD_DEVICE_BUFFERS = 0x10,
  51. } D3DX10_MESH_DISCARD_FLAGS;
  52. typedef struct _D3DX10_WELD_EPSILONS
  53. {
  54. FLOAT Position; // NOTE: This does NOT replace the epsilon in GenerateAdjacency
  55. // in general, it should be the same value or greater than the one passed to GeneratedAdjacency
  56. FLOAT BlendWeights;
  57. FLOAT Normal;
  58. FLOAT PSize;
  59. FLOAT Specular;
  60. FLOAT Diffuse;
  61. FLOAT Texcoord[8];
  62. FLOAT Tangent;
  63. FLOAT Binormal;
  64. FLOAT TessFactor;
  65. } D3DX10_WELD_EPSILONS;
  66. typedef D3DX10_WELD_EPSILONS* LPD3DX10_WELD_EPSILONS;
  67. typedef struct _D3DX10_INTERSECT_INFO
  68. {
  69. UINT FaceIndex; // index of face intersected
  70. FLOAT U; // Barycentric Hit Coordinates
  71. FLOAT V; // Barycentric Hit Coordinates
  72. FLOAT Dist; // Ray-Intersection Parameter Distance
  73. } D3DX10_INTERSECT_INFO, *LPD3DX10_INTERSECT_INFO;
  74. // ID3DX10MeshBuffer is used by D3DX10Mesh vertex and index buffers
  75. #undef INTERFACE
  76. #define INTERFACE ID3DX10MeshBuffer
  77. DECLARE_INTERFACE_(ID3DX10MeshBuffer, IUnknown)
  78. {
  79. // IUnknown
  80. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  81. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  82. STDMETHOD_(ULONG, Release)(THIS) PURE;
  83. // ID3DX10MeshBuffer
  84. STDMETHOD(Map)(THIS_ void **ppData, SIZE_T *pSize) PURE;
  85. STDMETHOD(Unmap)(THIS) PURE;
  86. STDMETHOD_(SIZE_T, GetSize)(THIS) PURE;
  87. };
  88. // D3DX10 Mesh interfaces
  89. #undef INTERFACE
  90. #define INTERFACE ID3DX10Mesh
  91. DECLARE_INTERFACE_(ID3DX10Mesh, IUnknown)
  92. {
  93. // IUnknown
  94. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  95. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  96. STDMETHOD_(ULONG, Release)(THIS) PURE;
  97. // ID3DX10Mesh
  98. STDMETHOD_(UINT, GetFaceCount)(THIS) PURE;
  99. STDMETHOD_(UINT, GetVertexCount)(THIS) PURE;
  100. STDMETHOD_(UINT, GetVertexBufferCount)(THIS) PURE;
  101. STDMETHOD_(UINT, GetFlags)(THIS) PURE;
  102. STDMETHOD(GetVertexDescription)(THIS_ CONST D3D10_INPUT_ELEMENT_DESC **ppDesc, UINT *pDeclCount) PURE;
  103. STDMETHOD(SetVertexData)(THIS_ UINT iBuffer, CONST void *pData) PURE;
  104. STDMETHOD(GetVertexBuffer)(THIS_ UINT iBuffer, ID3DX10MeshBuffer **ppVertexBuffer) PURE;
  105. STDMETHOD(SetIndexData)(THIS_ CONST void *pData, UINT cIndices) PURE;
  106. STDMETHOD(GetIndexBuffer)(THIS_ ID3DX10MeshBuffer **ppIndexBuffer) PURE;
  107. STDMETHOD(SetAttributeData)(THIS_ CONST UINT *pData) PURE;
  108. STDMETHOD(GetAttributeBuffer)(THIS_ ID3DX10MeshBuffer **ppAttributeBuffer) PURE;
  109. STDMETHOD(SetAttributeTable)(THIS_ CONST D3DX10_ATTRIBUTE_RANGE *pAttribTable, UINT cAttribTableSize) PURE;
  110. STDMETHOD(GetAttributeTable)(THIS_ D3DX10_ATTRIBUTE_RANGE *pAttribTable, UINT *pAttribTableSize) PURE;
  111. STDMETHOD(GenerateAdjacencyAndPointReps)(THIS_ FLOAT Epsilon) PURE;
  112. STDMETHOD(GenerateGSAdjacency)(THIS) PURE;
  113. STDMETHOD(SetAdjacencyData)(THIS_ CONST UINT *pAdjacency) PURE;
  114. STDMETHOD(GetAdjacencyBuffer)(THIS_ ID3DX10MeshBuffer **ppAdjacency) PURE;
  115. STDMETHOD(SetPointRepData)(THIS_ CONST UINT *pPointReps) PURE;
  116. STDMETHOD(GetPointRepBuffer)(THIS_ ID3DX10MeshBuffer **ppPointReps) PURE;
  117. STDMETHOD(Discard)(THIS_ D3DX10_MESH_DISCARD_FLAGS dwDiscard) PURE;
  118. STDMETHOD(CloneMesh)(THIS_ UINT Flags, LPCSTR pPosSemantic, CONST D3D10_INPUT_ELEMENT_DESC *pDesc, UINT DeclCount, ID3DX10Mesh** ppCloneMesh) PURE;
  119. STDMETHOD(Optimize)(THIS_ UINT Flags, UINT * pFaceRemap, LPD3D10BLOB *ppVertexRemap) PURE;
  120. STDMETHOD(GenerateAttributeBufferFromTable)(THIS) PURE;
  121. STDMETHOD(Intersect)(THIS_ D3DXVECTOR3 *pRayPos, D3DXVECTOR3 *pRayDir,
  122. UINT *pHitCount, UINT *pFaceIndex, float *pU, float *pV, float *pDist, ID3D10Blob **ppAllHits);
  123. STDMETHOD(IntersectSubset)(THIS_ UINT AttribId, D3DXVECTOR3 *pRayPos, D3DXVECTOR3 *pRayDir,
  124. UINT *pHitCount, UINT *pFaceIndex, float *pU, float *pV, float *pDist, ID3D10Blob **ppAllHits);
  125. // ID3DX10Mesh - Device functions
  126. STDMETHOD(CommitToDevice)(THIS) PURE;
  127. STDMETHOD(DrawSubset)(THIS_ UINT AttribId) PURE;
  128. STDMETHOD(DrawSubsetInstanced)(THIS_ UINT AttribId, UINT InstanceCount, UINT StartInstanceLocation) PURE;
  129. STDMETHOD(GetDeviceVertexBuffer)(THIS_ UINT iBuffer, ID3D10Buffer **ppVertexBuffer) PURE;
  130. STDMETHOD(GetDeviceIndexBuffer)(THIS_ ID3D10Buffer **ppIndexBuffer) PURE;
  131. };
  132. // Flat API
  133. #ifdef __cplusplus
  134. extern "C" {
  135. #endif //__cplusplus
  136. HRESULT WINAPI
  137. D3DX10CreateMesh(
  138. ID3D10Device *pDevice,
  139. CONST D3D10_INPUT_ELEMENT_DESC *pDeclaration,
  140. UINT DeclCount,
  141. LPCSTR pPositionSemantic,
  142. UINT VertexCount,
  143. UINT FaceCount,
  144. UINT Options,
  145. ID3DX10Mesh **ppMesh);
  146. #ifdef __cplusplus
  147. }
  148. #endif //__cplusplus
  149. // ID3DX10Mesh::Optimize options - upper byte only, lower 3 bytes used from _D3DX10MESH option flags
  150. enum _D3DX10_MESHOPT {
  151. D3DX10_MESHOPT_COMPACT = 0x01000000,
  152. D3DX10_MESHOPT_ATTR_SORT = 0x02000000,
  153. D3DX10_MESHOPT_VERTEX_CACHE = 0x04000000,
  154. D3DX10_MESHOPT_STRIP_REORDER = 0x08000000,
  155. D3DX10_MESHOPT_IGNORE_VERTS = 0x10000000, // optimize faces only, don't touch vertices
  156. D3DX10_MESHOPT_DO_NOT_SPLIT = 0x20000000, // do not split vertices shared between attribute groups when attribute sorting
  157. D3DX10_MESHOPT_DEVICE_INDEPENDENT = 0x00400000, // Only affects VCache. uses a static known good cache size for all cards
  158. // D3DX10_MESHOPT_SHAREVB has been removed, please use D3DX10MESH_VB_SHARE instead
  159. };
  160. //////////////////////////////////////////////////////////////////////////
  161. // ID3DXSkinInfo
  162. //////////////////////////////////////////////////////////////////////////
  163. // {420BD604-1C76-4a34-A466-E45D0658A32C}
  164. DEFINE_GUID(IID_ID3DX10SkinInfo,
  165. 0x420bd604, 0x1c76, 0x4a34, 0xa4, 0x66, 0xe4, 0x5d, 0x6, 0x58, 0xa3, 0x2c);
  166. // scaling modes for ID3DX10SkinInfo::Compact() & ID3DX10SkinInfo::UpdateMesh()
  167. #define D3DX10_SKININFO_NO_SCALING 0
  168. #define D3DX10_SKININFO_SCALE_TO_1 1
  169. #define D3DX10_SKININFO_SCALE_TO_TOTAL 2
  170. typedef struct _D3DX10_SKINNING_CHANNEL
  171. {
  172. UINT SrcOffset;
  173. UINT DestOffset;
  174. BOOL IsNormal;
  175. } D3DX10_SKINNING_CHANNEL;
  176. #undef INTERFACE
  177. #define INTERFACE ID3DX10SkinInfo
  178. typedef struct ID3DX10SkinInfo *LPD3DX10SKININFO;
  179. DECLARE_INTERFACE_(ID3DX10SkinInfo, IUnknown)
  180. {
  181. // IUnknown
  182. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  183. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  184. STDMETHOD_(ULONG, Release)(THIS) PURE;
  185. STDMETHOD_(UINT , GetNumVertices)(THIS) PURE;
  186. STDMETHOD_(UINT , GetNumBones)(THIS) PURE;
  187. STDMETHOD_(UINT , GetMaxBoneInfluences)(THIS) PURE;
  188. STDMETHOD(AddVertices)(THIS_ UINT Count) PURE;
  189. STDMETHOD(RemapVertices)(THIS_ UINT NewVertexCount, UINT *pVertexRemap) PURE;
  190. STDMETHOD(AddBones)(THIS_ UINT Count) PURE;
  191. STDMETHOD(RemoveBone)(THIS_ UINT Index) PURE;
  192. STDMETHOD(RemapBones)(THIS_ UINT NewBoneCount, UINT *pBoneRemap) PURE;
  193. STDMETHOD(AddBoneInfluences)(THIS_ UINT BoneIndex, UINT InfluenceCount, UINT *pIndices, float *pWeights) PURE;
  194. STDMETHOD(ClearBoneInfluences)(THIS_ UINT BoneIndex) PURE;
  195. STDMETHOD_(UINT , GetBoneInfluenceCount)(THIS_ UINT BoneIndex) PURE;
  196. STDMETHOD(GetBoneInfluences)(THIS_ UINT BoneIndex, UINT Offset, UINT Count, UINT *pDestIndices, float *pDestWeights) PURE;
  197. STDMETHOD(FindBoneInfluenceIndex)(THIS_ UINT BoneIndex, UINT VertexIndex, UINT *pInfluenceIndex) PURE;
  198. STDMETHOD(SetBoneInfluence)(THIS_ UINT BoneIndex, UINT InfluenceIndex, float Weight) PURE;
  199. STDMETHOD(GetBoneInfluence)(THIS_ UINT BoneIndex, UINT InfluenceIndex, float *pWeight) PURE;
  200. STDMETHOD(Compact)(THIS_ UINT MaxPerVertexInfluences, UINT ScaleMode, float MinWeight) PURE;
  201. STDMETHOD(DoSoftwareSkinning)(UINT StartVertex, UINT VertexCount, void *pSrcVertices, UINT SrcStride, void *pDestVertices, UINT DestStride, D3DXMATRIX *pBoneMatrices, D3DXMATRIX *pInverseTransposeBoneMatrices, D3DX10_SKINNING_CHANNEL *pChannelDescs, UINT NumChannels) PURE;
  202. };
  203. #ifdef __cplusplus
  204. extern "C" {
  205. #endif //__cplusplus
  206. HRESULT WINAPI
  207. D3DX10CreateSkinInfo(LPD3DX10SKININFO* ppSkinInfo);
  208. #ifdef __cplusplus
  209. }
  210. #endif //__cplusplus
  211. typedef struct _D3DX10_ATTRIBUTE_WEIGHTS
  212. {
  213. FLOAT Position;
  214. FLOAT Boundary;
  215. FLOAT Normal;
  216. FLOAT Diffuse;
  217. FLOAT Specular;
  218. FLOAT Texcoord[8];
  219. FLOAT Tangent;
  220. FLOAT Binormal;
  221. } D3DX10_ATTRIBUTE_WEIGHTS, *LPD3DX10_ATTRIBUTE_WEIGHTS;
  222. #endif //__D3DX10MESH_H__