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.

3007 lines
122 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: d3dx9mesh.h
  6. // Content: D3DX mesh types and functions
  7. //
  8. //////////////////////////////////////////////////////////////////////////////
  9. #include "d3dx9.h"
  10. #ifndef __D3DX9MESH_H__
  11. #define __D3DX9MESH_H__
  12. // {7ED943DD-52E8-40b5-A8D8-76685C406330}
  13. DEFINE_GUID(IID_ID3DXBaseMesh,
  14. 0x7ed943dd, 0x52e8, 0x40b5, 0xa8, 0xd8, 0x76, 0x68, 0x5c, 0x40, 0x63, 0x30);
  15. // {4020E5C2-1403-4929-883F-E2E849FAC195}
  16. DEFINE_GUID(IID_ID3DXMesh,
  17. 0x4020e5c2, 0x1403, 0x4929, 0x88, 0x3f, 0xe2, 0xe8, 0x49, 0xfa, 0xc1, 0x95);
  18. // {8875769A-D579-4088-AAEB-534D1AD84E96}
  19. DEFINE_GUID(IID_ID3DXPMesh,
  20. 0x8875769a, 0xd579, 0x4088, 0xaa, 0xeb, 0x53, 0x4d, 0x1a, 0xd8, 0x4e, 0x96);
  21. // {667EA4C7-F1CD-4386-B523-7C0290B83CC5}
  22. DEFINE_GUID(IID_ID3DXSPMesh,
  23. 0x667ea4c7, 0xf1cd, 0x4386, 0xb5, 0x23, 0x7c, 0x2, 0x90, 0xb8, 0x3c, 0xc5);
  24. // {11EAA540-F9A6-4d49-AE6A-E19221F70CC4}
  25. DEFINE_GUID(IID_ID3DXSkinInfo,
  26. 0x11eaa540, 0xf9a6, 0x4d49, 0xae, 0x6a, 0xe1, 0x92, 0x21, 0xf7, 0xc, 0xc4);
  27. // {3CE6CC22-DBF2-44f4-894D-F9C34A337139}
  28. DEFINE_GUID(IID_ID3DXPatchMesh,
  29. 0x3ce6cc22, 0xdbf2, 0x44f4, 0x89, 0x4d, 0xf9, 0xc3, 0x4a, 0x33, 0x71, 0x39);
  30. //patch mesh can be quads or tris
  31. typedef enum _D3DXPATCHMESHTYPE {
  32. D3DXPATCHMESH_RECT = 0x001,
  33. D3DXPATCHMESH_TRI = 0x002,
  34. D3DXPATCHMESH_NPATCH = 0x003,
  35. D3DXPATCHMESH_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  36. } D3DXPATCHMESHTYPE;
  37. // Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags
  38. enum _D3DXMESH {
  39. D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices.
  40. D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB.
  41. D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB.
  42. D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB.
  43. D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB.
  44. D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER
  45. D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB.
  46. D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB.
  47. D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB.
  48. D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB.
  49. D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER
  50. D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB.
  51. D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB.
  52. D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB.
  53. D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB.
  54. D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer
  55. D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinInfo::ConvertToBlendedMesh
  56. // Helper options
  57. D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM
  58. D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED
  59. D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY
  60. D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC
  61. D3DXMESH_SOFTWAREPROCESSING = 0x18000, // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING
  62. };
  63. //patch mesh options
  64. enum _D3DXPATCHMESH {
  65. D3DXPATCHMESH_DEFAULT = 000,
  66. };
  67. // option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh
  68. enum _D3DXMESHSIMP
  69. {
  70. D3DXMESHSIMP_VERTEX = 0x1,
  71. D3DXMESHSIMP_FACE = 0x2,
  72. };
  73. typedef enum _D3DXCLEANTYPE {
  74. D3DXCLEAN_BACKFACING = 0x00000001,
  75. D3DXCLEAN_BOWTIES = 0x00000002,
  76. // Helper options
  77. D3DXCLEAN_SKINNING = D3DXCLEAN_BACKFACING, // Bowtie cleaning modifies geometry and breaks skinning
  78. D3DXCLEAN_OPTIMIZATION = D3DXCLEAN_BACKFACING,
  79. D3DXCLEAN_SIMPLIFICATION= D3DXCLEAN_BACKFACING | D3DXCLEAN_BOWTIES,
  80. } D3DXCLEANTYPE;
  81. enum _MAX_FVF_DECL_SIZE
  82. {
  83. MAX_FVF_DECL_SIZE = MAXD3DDECLLENGTH + 1 // +1 for END
  84. };
  85. typedef enum _D3DXTANGENT
  86. {
  87. D3DXTANGENT_WRAP_U = 0x01,
  88. D3DXTANGENT_WRAP_V = 0x02,
  89. D3DXTANGENT_WRAP_UV = 0x03,
  90. D3DXTANGENT_DONT_NORMALIZE_PARTIALS = 0x04,
  91. D3DXTANGENT_DONT_ORTHOGONALIZE = 0x08,
  92. D3DXTANGENT_ORTHOGONALIZE_FROM_V = 0x010,
  93. D3DXTANGENT_ORTHOGONALIZE_FROM_U = 0x020,
  94. D3DXTANGENT_WEIGHT_BY_AREA = 0x040,
  95. D3DXTANGENT_WEIGHT_EQUAL = 0x080,
  96. D3DXTANGENT_WIND_CW = 0x0100,
  97. D3DXTANGENT_CALCULATE_NORMALS = 0x0200,
  98. D3DXTANGENT_GENERATE_IN_PLACE = 0x0400,
  99. } D3DXTANGENT;
  100. // D3DXIMT_WRAP_U means the texture wraps in the U direction
  101. // D3DXIMT_WRAP_V means the texture wraps in the V direction
  102. // D3DXIMT_WRAP_UV means the texture wraps in both directions
  103. typedef enum _D3DXIMT
  104. {
  105. D3DXIMT_WRAP_U = 0x01,
  106. D3DXIMT_WRAP_V = 0x02,
  107. D3DXIMT_WRAP_UV = 0x03,
  108. } D3DXIMT;
  109. // These options are only valid for UVAtlasCreate and UVAtlasPartition, we may add more for UVAtlasPack if necessary
  110. // D3DXUVATLAS_DEFAULT - Meshes with more than 25k faces go through fast, meshes with fewer than 25k faces go through quality
  111. // D3DXUVATLAS_GEODESIC_FAST - Uses approximations to improve charting speed at the cost of added stretch or more charts.
  112. // D3DXUVATLAS_GEODESIC_QUALITY - Provides better quality charts, but requires more time and memory than fast.
  113. typedef enum _D3DXUVATLAS
  114. {
  115. D3DXUVATLAS_DEFAULT = 0x00,
  116. D3DXUVATLAS_GEODESIC_FAST = 0x01,
  117. D3DXUVATLAS_GEODESIC_QUALITY = 0x02,
  118. } D3DXUVATLAS;
  119. typedef struct ID3DXBaseMesh *LPD3DXBASEMESH;
  120. typedef struct ID3DXMesh *LPD3DXMESH;
  121. typedef struct ID3DXPMesh *LPD3DXPMESH;
  122. typedef struct ID3DXSPMesh *LPD3DXSPMESH;
  123. typedef struct ID3DXSkinInfo *LPD3DXSKININFO;
  124. typedef struct ID3DXPatchMesh *LPD3DXPATCHMESH;
  125. typedef interface ID3DXTextureGutterHelper *LPD3DXTEXTUREGUTTERHELPER;
  126. typedef interface ID3DXPRTBuffer *LPD3DXPRTBUFFER;
  127. typedef struct _D3DXATTRIBUTERANGE
  128. {
  129. DWORD AttribId;
  130. DWORD FaceStart;
  131. DWORD FaceCount;
  132. DWORD VertexStart;
  133. DWORD VertexCount;
  134. } D3DXATTRIBUTERANGE;
  135. typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE;
  136. typedef struct _D3DXMATERIAL
  137. {
  138. D3DMATERIAL9 MatD3D;
  139. LPSTR pTextureFilename;
  140. } D3DXMATERIAL;
  141. typedef D3DXMATERIAL *LPD3DXMATERIAL;
  142. typedef enum _D3DXEFFECTDEFAULTTYPE
  143. {
  144. D3DXEDT_STRING = 0x1, // pValue points to a null terminated ASCII string
  145. D3DXEDT_FLOATS = 0x2, // pValue points to an array of floats - number of floats is NumBytes / sizeof(float)
  146. D3DXEDT_DWORD = 0x3, // pValue points to a DWORD
  147. D3DXEDT_FORCEDWORD = 0x7fffffff
  148. } D3DXEFFECTDEFAULTTYPE;
  149. typedef struct _D3DXEFFECTDEFAULT
  150. {
  151. LPSTR pParamName;
  152. D3DXEFFECTDEFAULTTYPE Type; // type of the data pointed to by pValue
  153. DWORD NumBytes; // size in bytes of the data pointed to by pValue
  154. LPVOID pValue; // data for the default of the effect
  155. } D3DXEFFECTDEFAULT, *LPD3DXEFFECTDEFAULT;
  156. typedef struct _D3DXEFFECTINSTANCE
  157. {
  158. LPSTR pEffectFilename;
  159. DWORD NumDefaults;
  160. LPD3DXEFFECTDEFAULT pDefaults;
  161. } D3DXEFFECTINSTANCE, *LPD3DXEFFECTINSTANCE;
  162. typedef struct _D3DXATTRIBUTEWEIGHTS
  163. {
  164. FLOAT Position;
  165. FLOAT Boundary;
  166. FLOAT Normal;
  167. FLOAT Diffuse;
  168. FLOAT Specular;
  169. FLOAT Texcoord[8];
  170. FLOAT Tangent;
  171. FLOAT Binormal;
  172. } D3DXATTRIBUTEWEIGHTS, *LPD3DXATTRIBUTEWEIGHTS;
  173. enum _D3DXWELDEPSILONSFLAGS
  174. {
  175. D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping
  176. D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched
  177. // vertices so that both components identical AND if all components "equal"
  178. // remove one of the vertices
  179. D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal
  180. // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set
  181. // useful to modify vertices to be equal, but not allow vertices to be removed
  182. D3DXWELDEPSILONS_DONOTSPLIT = 0x8, // instructs weld to specify the D3DXMESHOPT_DONOTSPLIT flag when doing an Optimize(ATTR_SORT)
  183. // if this flag is not set, all vertices that are in separate attribute groups
  184. // will remain split and not welded. Setting this flag can slow down software vertex processing
  185. };
  186. typedef struct _D3DXWELDEPSILONS
  187. {
  188. FLOAT Position; // NOTE: This does NOT replace the epsilon in GenerateAdjacency
  189. // in general, it should be the same value or greater than the one passed to GeneratedAdjacency
  190. FLOAT BlendWeights;
  191. FLOAT Normal;
  192. FLOAT PSize;
  193. FLOAT Specular;
  194. FLOAT Diffuse;
  195. FLOAT Texcoord[8];
  196. FLOAT Tangent;
  197. FLOAT Binormal;
  198. FLOAT TessFactor;
  199. } D3DXWELDEPSILONS;
  200. typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS;
  201. #undef INTERFACE
  202. #define INTERFACE ID3DXBaseMesh
  203. DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown)
  204. {
  205. // IUnknown
  206. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  207. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  208. STDMETHOD_(ULONG, Release)(THIS) PURE;
  209. // ID3DXBaseMesh
  210. STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE;
  211. STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE;
  212. STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE;
  213. STDMETHOD_(DWORD, GetFVF)(THIS) PURE;
  214. STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE;
  215. STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE;
  216. STDMETHOD_(DWORD, GetOptions)(THIS) PURE;
  217. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE;
  218. STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options,
  219. DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE;
  220. STDMETHOD(CloneMesh)(THIS_ DWORD Options,
  221. CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE;
  222. STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE;
  223. STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE;
  224. STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE;
  225. STDMETHOD(UnlockVertexBuffer)(THIS) PURE;
  226. STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE;
  227. STDMETHOD(UnlockIndexBuffer)(THIS) PURE;
  228. STDMETHOD(GetAttributeTable)(
  229. THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE;
  230. STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE;
  231. STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE;
  232. STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE;
  233. STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE;
  234. };
  235. #undef INTERFACE
  236. #define INTERFACE ID3DXMesh
  237. DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh)
  238. {
  239. // IUnknown
  240. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  241. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  242. STDMETHOD_(ULONG, Release)(THIS) PURE;
  243. // ID3DXBaseMesh
  244. STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE;
  245. STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE;
  246. STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE;
  247. STDMETHOD_(DWORD, GetFVF)(THIS) PURE;
  248. STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE;
  249. STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE;
  250. STDMETHOD_(DWORD, GetOptions)(THIS) PURE;
  251. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE;
  252. STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options,
  253. DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE;
  254. STDMETHOD(CloneMesh)(THIS_ DWORD Options,
  255. CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE;
  256. STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE;
  257. STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE;
  258. STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE;
  259. STDMETHOD(UnlockVertexBuffer)(THIS) PURE;
  260. STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE;
  261. STDMETHOD(UnlockIndexBuffer)(THIS) PURE;
  262. STDMETHOD(GetAttributeTable)(
  263. THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE;
  264. STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE;
  265. STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE;
  266. STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE;
  267. STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE;
  268. // ID3DXMesh
  269. STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE;
  270. STDMETHOD(UnlockAttributeBuffer)(THIS) PURE;
  271. STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut,
  272. DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap,
  273. LPD3DXMESH* ppOptMesh) PURE;
  274. STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut,
  275. DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE;
  276. STDMETHOD(SetAttributeTable)(THIS_ CONST D3DXATTRIBUTERANGE *pAttribTable, DWORD cAttribTableSize) PURE;
  277. };
  278. #undef INTERFACE
  279. #define INTERFACE ID3DXPMesh
  280. DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh)
  281. {
  282. // IUnknown
  283. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  284. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  285. STDMETHOD_(ULONG, Release)(THIS) PURE;
  286. // ID3DXBaseMesh
  287. STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE;
  288. STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE;
  289. STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE;
  290. STDMETHOD_(DWORD, GetFVF)(THIS) PURE;
  291. STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE;
  292. STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE;
  293. STDMETHOD_(DWORD, GetOptions)(THIS) PURE;
  294. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE;
  295. STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options,
  296. DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE;
  297. STDMETHOD(CloneMesh)(THIS_ DWORD Options,
  298. CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE;
  299. STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE;
  300. STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE;
  301. STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE;
  302. STDMETHOD(UnlockVertexBuffer)(THIS) PURE;
  303. STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, LPVOID *ppData) PURE;
  304. STDMETHOD(UnlockIndexBuffer)(THIS) PURE;
  305. STDMETHOD(GetAttributeTable)(
  306. THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE;
  307. STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE;
  308. STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE;
  309. STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE;
  310. STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE;
  311. // ID3DXPMesh
  312. STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options,
  313. DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh) PURE;
  314. STDMETHOD(ClonePMesh)(THIS_ DWORD Options,
  315. CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh) PURE;
  316. STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE;
  317. STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE;
  318. STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE;
  319. STDMETHOD_(DWORD, GetMinFaces)(THIS) PURE;
  320. STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE;
  321. STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE;
  322. STDMETHOD(Save)(THIS_ IStream *pStream, CONST D3DXMATERIAL* pMaterials, CONST D3DXEFFECTINSTANCE* pEffectInstances, DWORD NumMaterials) PURE;
  323. STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut,
  324. DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap,
  325. LPD3DXMESH* ppOptMesh) PURE;
  326. STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE;
  327. STDMETHOD(TrimByFaces)(THIS_ DWORD NewFacesMin, DWORD NewFacesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE;
  328. STDMETHOD(TrimByVertices)(THIS_ DWORD NewVerticesMin, DWORD NewVerticesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE;
  329. STDMETHOD(GetAdjacency)(THIS_ DWORD* pAdjacency) PURE;
  330. // Used to generate the immediate "ancestor" for each vertex when it is removed by a vsplit. Allows generation of geomorphs
  331. // Vertex buffer must be equal to or greater than the maximum number of vertices in the pmesh
  332. STDMETHOD(GenerateVertexHistory)(THIS_ DWORD* pVertexHistory) PURE;
  333. };
  334. #undef INTERFACE
  335. #define INTERFACE ID3DXSPMesh
  336. DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown)
  337. {
  338. // IUnknown
  339. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  340. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  341. STDMETHOD_(ULONG, Release)(THIS) PURE;
  342. // ID3DXSPMesh
  343. STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE;
  344. STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE;
  345. STDMETHOD_(DWORD, GetFVF)(THIS) PURE;
  346. STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE;
  347. STDMETHOD_(DWORD, GetOptions)(THIS) PURE;
  348. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE;
  349. STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options,
  350. DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE;
  351. STDMETHOD(CloneMesh)(THIS_ DWORD Options,
  352. CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE;
  353. STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options,
  354. DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pVertexRemapOut, FLOAT *pErrorsByFace, LPD3DXPMESH* ppCloneMesh) PURE;
  355. STDMETHOD(ClonePMesh)(THIS_ DWORD Options,
  356. CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pVertexRemapOut, FLOAT *pErrorsbyFace, LPD3DXPMESH* ppCloneMesh) PURE;
  357. STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE;
  358. STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE;
  359. STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE;
  360. STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE;
  361. STDMETHOD(GetVertexAttributeWeights)(THIS_ LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights) PURE;
  362. STDMETHOD(GetVertexWeights)(THIS_ FLOAT *pVertexWeights) PURE;
  363. };
  364. #define UNUSED16 (0xffff)
  365. #define UNUSED32 (0xffffffff)
  366. // ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags
  367. enum _D3DXMESHOPT {
  368. D3DXMESHOPT_COMPACT = 0x01000000,
  369. D3DXMESHOPT_ATTRSORT = 0x02000000,
  370. D3DXMESHOPT_VERTEXCACHE = 0x04000000,
  371. D3DXMESHOPT_STRIPREORDER = 0x08000000,
  372. D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices
  373. D3DXMESHOPT_DONOTSPLIT = 0x20000000, // do not split vertices shared between attribute groups when attribute sorting
  374. D3DXMESHOPT_DEVICEINDEPENDENT = 0x00400000, // Only affects VCache. uses a static known good cache size for all cards
  375. // D3DXMESHOPT_SHAREVB has been removed, please use D3DXMESH_VB_SHARE instead
  376. };
  377. // Subset of the mesh that has the same attribute and bone combination.
  378. // This subset can be rendered in a single draw call
  379. typedef struct _D3DXBONECOMBINATION
  380. {
  381. DWORD AttribId;
  382. DWORD FaceStart;
  383. DWORD FaceCount;
  384. DWORD VertexStart;
  385. DWORD VertexCount;
  386. DWORD* BoneId;
  387. } D3DXBONECOMBINATION, *LPD3DXBONECOMBINATION;
  388. // The following types of patch combinations are supported:
  389. // Patch type Basis Degree
  390. // Rect Bezier 2,3,5
  391. // Rect B-Spline 2,3,5
  392. // Rect Catmull-Rom 3
  393. // Tri Bezier 2,3,5
  394. // N-Patch N/A 3
  395. typedef struct _D3DXPATCHINFO
  396. {
  397. D3DXPATCHMESHTYPE PatchType;
  398. D3DDEGREETYPE Degree;
  399. D3DBASISTYPE Basis;
  400. } D3DXPATCHINFO, *LPD3DXPATCHINFO;
  401. #undef INTERFACE
  402. #define INTERFACE ID3DXPatchMesh
  403. DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown)
  404. {
  405. // IUnknown
  406. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  407. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  408. STDMETHOD_(ULONG, Release)(THIS) PURE;
  409. // ID3DXPatchMesh
  410. // Return creation parameters
  411. STDMETHOD_(DWORD, GetNumPatches)(THIS) PURE;
  412. STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE;
  413. STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE;
  414. STDMETHOD_(DWORD, GetControlVerticesPerPatch)(THIS) PURE;
  415. STDMETHOD_(DWORD, GetOptions)(THIS) PURE;
  416. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9 *ppDevice) PURE;
  417. STDMETHOD(GetPatchInfo)(THIS_ LPD3DXPATCHINFO PatchInfo) PURE;
  418. // Control mesh access
  419. STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE;
  420. STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE;
  421. STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, LPVOID *ppData) PURE;
  422. STDMETHOD(UnlockVertexBuffer)(THIS) PURE;
  423. STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, LPVOID *ppData) PURE;
  424. STDMETHOD(UnlockIndexBuffer)(THIS) PURE;
  425. STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE;
  426. STDMETHOD(UnlockAttributeBuffer)(THIS) PURE;
  427. // This function returns the size of the tessellated mesh given a tessellation level.
  428. // This assumes uniform tessellation. For adaptive tessellation the Adaptive parameter must
  429. // be set to TRUE and TessellationLevel should be the max tessellation.
  430. // This will result in the max mesh size necessary for adaptive tessellation.
  431. STDMETHOD(GetTessSize)(THIS_ FLOAT fTessLevel,DWORD Adaptive, DWORD *NumTriangles,DWORD *NumVertices) PURE;
  432. //GenerateAdjacency determines which patches are adjacent with provided tolerance
  433. //this information is used internally to optimize tessellation
  434. STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Tolerance) PURE;
  435. //CloneMesh Creates a new patchmesh with the specified decl, and converts the vertex buffer
  436. //to the new decl. Entries in the new decl which are new are set to 0. If the current mesh
  437. //has adjacency, the new mesh will also have adjacency
  438. STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDecl, LPD3DXPATCHMESH *pMesh) PURE;
  439. // Optimizes the patchmesh for efficient tessellation. This function is designed
  440. // to perform one time optimization for patch meshes that need to be tessellated
  441. // repeatedly by calling the Tessellate() method. The optimization performed is
  442. // independent of the actual tessellation level used.
  443. // Currently Flags is unused.
  444. // If vertices are changed, Optimize must be called again
  445. STDMETHOD(Optimize)(THIS_ DWORD flags) PURE;
  446. //gets and sets displacement parameters
  447. //displacement maps can only be 2D textures MIP-MAPPING is ignored for non adapative tessellation
  448. STDMETHOD(SetDisplaceParam)(THIS_ LPDIRECT3DBASETEXTURE9 Texture,
  449. D3DTEXTUREFILTERTYPE MinFilter,
  450. D3DTEXTUREFILTERTYPE MagFilter,
  451. D3DTEXTUREFILTERTYPE MipFilter,
  452. D3DTEXTUREADDRESS Wrap,
  453. DWORD dwLODBias) PURE;
  454. STDMETHOD(GetDisplaceParam)(THIS_ LPDIRECT3DBASETEXTURE9 *Texture,
  455. D3DTEXTUREFILTERTYPE *MinFilter,
  456. D3DTEXTUREFILTERTYPE *MagFilter,
  457. D3DTEXTUREFILTERTYPE *MipFilter,
  458. D3DTEXTUREADDRESS *Wrap,
  459. DWORD *dwLODBias) PURE;
  460. // Performs the uniform tessellation based on the tessellation level.
  461. // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call.
  462. STDMETHOD(Tessellate)(THIS_ FLOAT fTessLevel,LPD3DXMESH pMesh) PURE;
  463. // Performs adaptive tessellation based on the Z based adaptive tessellation criterion.
  464. // pTrans specifies a 4D vector that is dotted with the vertices to get the per vertex
  465. // adaptive tessellation amount. Each edge is tessellated to the average of the criterion
  466. // at the 2 vertices it connects.
  467. // MaxTessLevel specifies the upper limit for adaptive tesselation.
  468. // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call.
  469. STDMETHOD(TessellateAdaptive)(THIS_
  470. CONST D3DXVECTOR4 *pTrans,
  471. DWORD dwMaxTessLevel,
  472. DWORD dwMinTessLevel,
  473. LPD3DXMESH pMesh) PURE;
  474. };
  475. #undef INTERFACE
  476. #define INTERFACE ID3DXSkinInfo
  477. DECLARE_INTERFACE_(ID3DXSkinInfo, IUnknown)
  478. {
  479. // IUnknown
  480. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  481. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  482. STDMETHOD_(ULONG, Release)(THIS) PURE;
  483. // Specify the which vertices do each bones influence and by how much
  484. STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE;
  485. STDMETHOD(SetBoneVertexInfluence)(THIS_ DWORD boneNum, DWORD influenceNum, float weight) PURE;
  486. STDMETHOD_(DWORD, GetNumBoneInfluences)(THIS_ DWORD bone) PURE;
  487. STDMETHOD(GetBoneInfluence)(THIS_ DWORD bone, DWORD* vertices, FLOAT* weights) PURE;
  488. STDMETHOD(GetBoneVertexInfluence)(THIS_ DWORD boneNum, DWORD influenceNum, float *pWeight, DWORD *pVertexNum) PURE;
  489. STDMETHOD(GetMaxVertexInfluences)(THIS_ DWORD* maxVertexInfluences) PURE;
  490. STDMETHOD_(DWORD, GetNumBones)(THIS) PURE;
  491. STDMETHOD(FindBoneVertexInfluenceIndex)(THIS_ DWORD boneNum, DWORD vertexNum, DWORD *pInfluenceIndex) PURE;
  492. // This gets the max face influences based on a triangle mesh with the specified index buffer
  493. STDMETHOD(GetMaxFaceInfluences)(THIS_ LPDIRECT3DINDEXBUFFER9 pIB, DWORD NumFaces, DWORD* maxFaceInfluences) PURE;
  494. // Set min bone influence. Bone influences that are smaller than this are ignored
  495. STDMETHOD(SetMinBoneInfluence)(THIS_ FLOAT MinInfl) PURE;
  496. // Get min bone influence.
  497. STDMETHOD_(FLOAT, GetMinBoneInfluence)(THIS) PURE;
  498. // Bone names are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object
  499. STDMETHOD(SetBoneName)(THIS_ DWORD Bone, LPCSTR pName) PURE; // pName is copied to an internal string buffer
  500. STDMETHOD_(LPCSTR, GetBoneName)(THIS_ DWORD Bone) PURE; // A pointer to an internal string buffer is returned. Do not free this.
  501. // Bone offset matrices are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object
  502. STDMETHOD(SetBoneOffsetMatrix)(THIS_ DWORD Bone, CONST D3DXMATRIX *pBoneTransform) PURE; // pBoneTransform is copied to an internal buffer
  503. STDMETHOD_(LPD3DXMATRIX, GetBoneOffsetMatrix)(THIS_ DWORD Bone) PURE; // A pointer to an internal matrix is returned. Do not free this.
  504. // Clone a skin info object
  505. STDMETHOD(Clone)(THIS_ LPD3DXSKININFO* ppSkinInfo) PURE;
  506. // Update bone influence information to match vertices after they are reordered. This should be called
  507. // if the target vertex buffer has been reordered externally.
  508. STDMETHOD(Remap)(THIS_ DWORD NumVertices, DWORD* pVertexRemap) PURE;
  509. // These methods enable the modification of the vertex layout of the vertices that will be skinned
  510. STDMETHOD(SetFVF)(THIS_ DWORD FVF) PURE;
  511. STDMETHOD(SetDeclaration)(THIS_ CONST D3DVERTEXELEMENT9 *pDeclaration) PURE;
  512. STDMETHOD_(DWORD, GetFVF)(THIS) PURE;
  513. STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE;
  514. // Apply SW skinning based on current pose matrices to the target vertices.
  515. STDMETHOD(UpdateSkinnedMesh)(THIS_
  516. CONST D3DXMATRIX* pBoneTransforms,
  517. CONST D3DXMATRIX* pBoneInvTransposeTransforms,
  518. LPCVOID pVerticesSrc,
  519. PVOID pVerticesDst) PURE;
  520. // Takes a mesh and returns a new mesh with per vertex blend weights and a bone combination
  521. // table that describes which bones affect which subsets of the mesh
  522. STDMETHOD(ConvertToBlendedMesh)(THIS_
  523. LPD3DXMESH pMesh,
  524. DWORD Options,
  525. CONST DWORD *pAdjacencyIn,
  526. LPDWORD pAdjacencyOut,
  527. DWORD* pFaceRemap,
  528. LPD3DXBUFFER *ppVertexRemap,
  529. DWORD* pMaxFaceInfl,
  530. DWORD* pNumBoneCombinations,
  531. LPD3DXBUFFER* ppBoneCombinationTable,
  532. LPD3DXMESH* ppMesh) PURE;
  533. // Takes a mesh and returns a new mesh with per vertex blend weights and indices
  534. // and a bone combination table that describes which bones palettes affect which subsets of the mesh
  535. STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_
  536. LPD3DXMESH pMesh,
  537. DWORD Options,
  538. DWORD paletteSize,
  539. CONST DWORD *pAdjacencyIn,
  540. LPDWORD pAdjacencyOut,
  541. DWORD* pFaceRemap,
  542. LPD3DXBUFFER *ppVertexRemap,
  543. DWORD* pMaxVertexInfl,
  544. DWORD* pNumBoneCombinations,
  545. LPD3DXBUFFER* ppBoneCombinationTable,
  546. LPD3DXMESH* ppMesh) PURE;
  547. };
  548. #ifdef __cplusplus
  549. extern "C" {
  550. #endif //__cplusplus
  551. HRESULT WINAPI
  552. D3DXCreateMesh(
  553. DWORD NumFaces,
  554. DWORD NumVertices,
  555. DWORD Options,
  556. CONST D3DVERTEXELEMENT9 *pDeclaration,
  557. LPDIRECT3DDEVICE9 pD3DDevice,
  558. LPD3DXMESH* ppMesh);
  559. HRESULT WINAPI
  560. D3DXCreateMeshFVF(
  561. DWORD NumFaces,
  562. DWORD NumVertices,
  563. DWORD Options,
  564. DWORD FVF,
  565. LPDIRECT3DDEVICE9 pD3DDevice,
  566. LPD3DXMESH* ppMesh);
  567. HRESULT WINAPI
  568. D3DXCreateSPMesh(
  569. LPD3DXMESH pMesh,
  570. CONST DWORD* pAdjacency,
  571. CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights,
  572. CONST FLOAT *pVertexWeights,
  573. LPD3DXSPMESH* ppSMesh);
  574. // clean a mesh up for simplification, try to make manifold
  575. HRESULT WINAPI
  576. D3DXCleanMesh(
  577. D3DXCLEANTYPE CleanType,
  578. LPD3DXMESH pMeshIn,
  579. CONST DWORD* pAdjacencyIn,
  580. LPD3DXMESH* ppMeshOut,
  581. DWORD* pAdjacencyOut,
  582. LPD3DXBUFFER* ppErrorsAndWarnings);
  583. HRESULT WINAPI
  584. D3DXValidMesh(
  585. LPD3DXMESH pMeshIn,
  586. CONST DWORD* pAdjacency,
  587. LPD3DXBUFFER* ppErrorsAndWarnings);
  588. HRESULT WINAPI
  589. D3DXGeneratePMesh(
  590. LPD3DXMESH pMesh,
  591. CONST DWORD* pAdjacency,
  592. CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights,
  593. CONST FLOAT *pVertexWeights,
  594. DWORD MinValue,
  595. DWORD Options,
  596. LPD3DXPMESH* ppPMesh);
  597. HRESULT WINAPI
  598. D3DXSimplifyMesh(
  599. LPD3DXMESH pMesh,
  600. CONST DWORD* pAdjacency,
  601. CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights,
  602. CONST FLOAT *pVertexWeights,
  603. DWORD MinValue,
  604. DWORD Options,
  605. LPD3DXMESH* ppMesh);
  606. HRESULT WINAPI
  607. D3DXComputeBoundingSphere(
  608. CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position
  609. DWORD NumVertices,
  610. DWORD dwStride, // count in bytes to subsequent position vectors
  611. D3DXVECTOR3 *pCenter,
  612. FLOAT *pRadius);
  613. HRESULT WINAPI
  614. D3DXComputeBoundingBox(
  615. CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position
  616. DWORD NumVertices,
  617. DWORD dwStride, // count in bytes to subsequent position vectors
  618. D3DXVECTOR3 *pMin,
  619. D3DXVECTOR3 *pMax);
  620. HRESULT WINAPI
  621. D3DXComputeNormals(
  622. LPD3DXBASEMESH pMesh,
  623. CONST DWORD *pAdjacency);
  624. HRESULT WINAPI
  625. D3DXCreateBuffer(
  626. DWORD NumBytes,
  627. LPD3DXBUFFER *ppBuffer);
  628. HRESULT WINAPI
  629. D3DXLoadMeshFromXA(
  630. LPCSTR pFilename,
  631. DWORD Options,
  632. LPDIRECT3DDEVICE9 pD3DDevice,
  633. LPD3DXBUFFER *ppAdjacency,
  634. LPD3DXBUFFER *ppMaterials,
  635. LPD3DXBUFFER *ppEffectInstances,
  636. DWORD *pNumMaterials,
  637. LPD3DXMESH *ppMesh);
  638. HRESULT WINAPI
  639. D3DXLoadMeshFromXW(
  640. LPCWSTR pFilename,
  641. DWORD Options,
  642. LPDIRECT3DDEVICE9 pD3DDevice,
  643. LPD3DXBUFFER *ppAdjacency,
  644. LPD3DXBUFFER *ppMaterials,
  645. LPD3DXBUFFER *ppEffectInstances,
  646. DWORD *pNumMaterials,
  647. LPD3DXMESH *ppMesh);
  648. #ifdef UNICODE
  649. #define D3DXLoadMeshFromX D3DXLoadMeshFromXW
  650. #else
  651. #define D3DXLoadMeshFromX D3DXLoadMeshFromXA
  652. #endif
  653. HRESULT WINAPI
  654. D3DXLoadMeshFromXInMemory(
  655. LPCVOID Memory,
  656. DWORD SizeOfMemory,
  657. DWORD Options,
  658. LPDIRECT3DDEVICE9 pD3DDevice,
  659. LPD3DXBUFFER *ppAdjacency,
  660. LPD3DXBUFFER *ppMaterials,
  661. LPD3DXBUFFER *ppEffectInstances,
  662. DWORD *pNumMaterials,
  663. LPD3DXMESH *ppMesh);
  664. HRESULT WINAPI
  665. D3DXLoadMeshFromXResource(
  666. HMODULE Module,
  667. LPCSTR Name,
  668. LPCSTR Type,
  669. DWORD Options,
  670. LPDIRECT3DDEVICE9 pD3DDevice,
  671. LPD3DXBUFFER *ppAdjacency,
  672. LPD3DXBUFFER *ppMaterials,
  673. LPD3DXBUFFER *ppEffectInstances,
  674. DWORD *pNumMaterials,
  675. LPD3DXMESH *ppMesh);
  676. HRESULT WINAPI
  677. D3DXSaveMeshToXA(
  678. LPCSTR pFilename,
  679. LPD3DXMESH pMesh,
  680. CONST DWORD* pAdjacency,
  681. CONST D3DXMATERIAL* pMaterials,
  682. CONST D3DXEFFECTINSTANCE* pEffectInstances,
  683. DWORD NumMaterials,
  684. DWORD Format
  685. );
  686. HRESULT WINAPI
  687. D3DXSaveMeshToXW(
  688. LPCWSTR pFilename,
  689. LPD3DXMESH pMesh,
  690. CONST DWORD* pAdjacency,
  691. CONST D3DXMATERIAL* pMaterials,
  692. CONST D3DXEFFECTINSTANCE* pEffectInstances,
  693. DWORD NumMaterials,
  694. DWORD Format
  695. );
  696. #ifdef UNICODE
  697. #define D3DXSaveMeshToX D3DXSaveMeshToXW
  698. #else
  699. #define D3DXSaveMeshToX D3DXSaveMeshToXA
  700. #endif
  701. HRESULT WINAPI
  702. D3DXCreatePMeshFromStream(
  703. IStream *pStream,
  704. DWORD Options,
  705. LPDIRECT3DDEVICE9 pD3DDevice,
  706. LPD3DXBUFFER *ppMaterials,
  707. LPD3DXBUFFER *ppEffectInstances,
  708. DWORD* pNumMaterials,
  709. LPD3DXPMESH *ppPMesh);
  710. // Creates a skin info object based on the number of vertices, number of bones, and a declaration describing the vertex layout of the target vertices
  711. // The bone names and initial bone transforms are not filled in the skin info object by this method.
  712. HRESULT WINAPI
  713. D3DXCreateSkinInfo(
  714. DWORD NumVertices,
  715. CONST D3DVERTEXELEMENT9 *pDeclaration,
  716. DWORD NumBones,
  717. LPD3DXSKININFO* ppSkinInfo);
  718. // Creates a skin info object based on the number of vertices, number of bones, and a FVF describing the vertex layout of the target vertices
  719. // The bone names and initial bone transforms are not filled in the skin info object by this method.
  720. HRESULT WINAPI
  721. D3DXCreateSkinInfoFVF(
  722. DWORD NumVertices,
  723. DWORD FVF,
  724. DWORD NumBones,
  725. LPD3DXSKININFO* ppSkinInfo);
  726. #ifdef __cplusplus
  727. }
  728. extern "C" {
  729. #endif //__cplusplus
  730. HRESULT WINAPI
  731. D3DXLoadMeshFromXof(
  732. LPD3DXFILEDATA pxofMesh,
  733. DWORD Options,
  734. LPDIRECT3DDEVICE9 pD3DDevice,
  735. LPD3DXBUFFER *ppAdjacency,
  736. LPD3DXBUFFER *ppMaterials,
  737. LPD3DXBUFFER *ppEffectInstances,
  738. DWORD *pNumMaterials,
  739. LPD3DXMESH *ppMesh);
  740. // This similar to D3DXLoadMeshFromXof, except also returns skinning info if present in the file
  741. // If skinning info is not present, ppSkinInfo will be NULL
  742. HRESULT WINAPI
  743. D3DXLoadSkinMeshFromXof(
  744. LPD3DXFILEDATA pxofMesh,
  745. DWORD Options,
  746. LPDIRECT3DDEVICE9 pD3DDevice,
  747. LPD3DXBUFFER* ppAdjacency,
  748. LPD3DXBUFFER* ppMaterials,
  749. LPD3DXBUFFER *ppEffectInstances,
  750. DWORD *pMatOut,
  751. LPD3DXSKININFO* ppSkinInfo,
  752. LPD3DXMESH* ppMesh);
  753. // The inverse of D3DXConvertTo{Indexed}BlendedMesh() functions. It figures out the skinning info from
  754. // the mesh and the bone combination table and populates a skin info object with that data. The bone
  755. // names and initial bone transforms are not filled in the skin info object by this method. This works
  756. // with either a non-indexed or indexed blended mesh. It examines the FVF or declarator of the mesh to
  757. // determine what type it is.
  758. HRESULT WINAPI
  759. D3DXCreateSkinInfoFromBlendedMesh(
  760. LPD3DXBASEMESH pMesh,
  761. DWORD NumBones,
  762. CONST D3DXBONECOMBINATION *pBoneCombinationTable,
  763. LPD3DXSKININFO* ppSkinInfo);
  764. HRESULT WINAPI
  765. D3DXTessellateNPatches(
  766. LPD3DXMESH pMeshIn,
  767. CONST DWORD* pAdjacencyIn,
  768. FLOAT NumSegs,
  769. BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic
  770. LPD3DXMESH *ppMeshOut,
  771. LPD3DXBUFFER *ppAdjacencyOut);
  772. //generates implied outputdecl from input decl
  773. //the decl generated from this should be used to generate the output decl for
  774. //the tessellator subroutines.
  775. HRESULT WINAPI
  776. D3DXGenerateOutputDecl(
  777. D3DVERTEXELEMENT9 *pOutput,
  778. CONST D3DVERTEXELEMENT9 *pInput);
  779. //loads patches from an XFileData
  780. //since an X file can have up to 6 different patch meshes in it,
  781. //returns them in an array - pNumPatches will contain the number of
  782. //meshes in the actual file.
  783. HRESULT WINAPI
  784. D3DXLoadPatchMeshFromXof(
  785. LPD3DXFILEDATA pXofObjMesh,
  786. DWORD Options,
  787. LPDIRECT3DDEVICE9 pD3DDevice,
  788. LPD3DXBUFFER *ppMaterials,
  789. LPD3DXBUFFER *ppEffectInstances,
  790. PDWORD pNumMaterials,
  791. LPD3DXPATCHMESH *ppMesh);
  792. //computes the size a single rect patch.
  793. HRESULT WINAPI
  794. D3DXRectPatchSize(
  795. CONST FLOAT *pfNumSegs, //segments for each edge (4)
  796. DWORD *pdwTriangles, //output number of triangles
  797. DWORD *pdwVertices); //output number of vertices
  798. //computes the size of a single triangle patch
  799. HRESULT WINAPI
  800. D3DXTriPatchSize(
  801. CONST FLOAT *pfNumSegs, //segments for each edge (3)
  802. DWORD *pdwTriangles, //output number of triangles
  803. DWORD *pdwVertices); //output number of vertices
  804. //tessellates a patch into a created mesh
  805. //similar to D3D RT patch
  806. HRESULT WINAPI
  807. D3DXTessellateRectPatch(
  808. LPDIRECT3DVERTEXBUFFER9 pVB,
  809. CONST FLOAT *pNumSegs,
  810. CONST D3DVERTEXELEMENT9 *pdwInDecl,
  811. CONST D3DRECTPATCH_INFO *pRectPatchInfo,
  812. LPD3DXMESH pMesh);
  813. HRESULT WINAPI
  814. D3DXTessellateTriPatch(
  815. LPDIRECT3DVERTEXBUFFER9 pVB,
  816. CONST FLOAT *pNumSegs,
  817. CONST D3DVERTEXELEMENT9 *pInDecl,
  818. CONST D3DTRIPATCH_INFO *pTriPatchInfo,
  819. LPD3DXMESH pMesh);
  820. //creates an NPatch PatchMesh from a D3DXMESH
  821. HRESULT WINAPI
  822. D3DXCreateNPatchMesh(
  823. LPD3DXMESH pMeshSysMem,
  824. LPD3DXPATCHMESH *pPatchMesh);
  825. //creates a patch mesh
  826. HRESULT WINAPI
  827. D3DXCreatePatchMesh(
  828. CONST D3DXPATCHINFO *pInfo, //patch type
  829. DWORD dwNumPatches, //number of patches
  830. DWORD dwNumVertices, //number of control vertices
  831. DWORD dwOptions, //options
  832. CONST D3DVERTEXELEMENT9 *pDecl, //format of control vertices
  833. LPDIRECT3DDEVICE9 pD3DDevice,
  834. LPD3DXPATCHMESH *pPatchMesh);
  835. //returns the number of degenerates in a patch mesh -
  836. //text output put in string.
  837. HRESULT WINAPI
  838. D3DXValidPatchMesh(LPD3DXPATCHMESH pMesh,
  839. DWORD *dwcDegenerateVertices,
  840. DWORD *dwcDegeneratePatches,
  841. LPD3DXBUFFER *ppErrorsAndWarnings);
  842. UINT WINAPI
  843. D3DXGetFVFVertexSize(DWORD FVF);
  844. UINT WINAPI
  845. D3DXGetDeclVertexSize(CONST D3DVERTEXELEMENT9 *pDecl,DWORD Stream);
  846. UINT WINAPI
  847. D3DXGetDeclLength(CONST D3DVERTEXELEMENT9 *pDecl);
  848. HRESULT WINAPI
  849. D3DXDeclaratorFromFVF(
  850. DWORD FVF,
  851. D3DVERTEXELEMENT9 pDeclarator[MAX_FVF_DECL_SIZE]);
  852. HRESULT WINAPI
  853. D3DXFVFFromDeclarator(
  854. CONST D3DVERTEXELEMENT9 *pDeclarator,
  855. DWORD *pFVF);
  856. HRESULT WINAPI
  857. D3DXWeldVertices(
  858. LPD3DXMESH pMesh,
  859. DWORD Flags,
  860. CONST D3DXWELDEPSILONS *pEpsilons,
  861. CONST DWORD *pAdjacencyIn,
  862. DWORD *pAdjacencyOut,
  863. DWORD *pFaceRemap,
  864. LPD3DXBUFFER *ppVertexRemap);
  865. typedef struct _D3DXINTERSECTINFO
  866. {
  867. DWORD FaceIndex; // index of face intersected
  868. FLOAT U; // Barycentric Hit Coordinates
  869. FLOAT V; // Barycentric Hit Coordinates
  870. FLOAT Dist; // Ray-Intersection Parameter Distance
  871. } D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO;
  872. HRESULT WINAPI
  873. D3DXIntersect(
  874. LPD3DXBASEMESH pMesh,
  875. CONST D3DXVECTOR3 *pRayPos,
  876. CONST D3DXVECTOR3 *pRayDir,
  877. BOOL *pHit, // True if any faces were intersected
  878. DWORD *pFaceIndex, // index of closest face intersected
  879. FLOAT *pU, // Barycentric Hit Coordinates
  880. FLOAT *pV, // Barycentric Hit Coordinates
  881. FLOAT *pDist, // Ray-Intersection Parameter Distance
  882. LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest)
  883. DWORD *pCountOfHits); // Number of entries in AllHits array
  884. HRESULT WINAPI
  885. D3DXIntersectSubset(
  886. LPD3DXBASEMESH pMesh,
  887. DWORD AttribId,
  888. CONST D3DXVECTOR3 *pRayPos,
  889. CONST D3DXVECTOR3 *pRayDir,
  890. BOOL *pHit, // True if any faces were intersected
  891. DWORD *pFaceIndex, // index of closest face intersected
  892. FLOAT *pU, // Barycentric Hit Coordinates
  893. FLOAT *pV, // Barycentric Hit Coordinates
  894. FLOAT *pDist, // Ray-Intersection Parameter Distance
  895. LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest)
  896. DWORD *pCountOfHits); // Number of entries in AllHits array
  897. HRESULT WINAPI D3DXSplitMesh
  898. (
  899. LPD3DXMESH pMeshIn,
  900. CONST DWORD *pAdjacencyIn,
  901. CONST DWORD MaxSize,
  902. CONST DWORD Options,
  903. DWORD *pMeshesOut,
  904. LPD3DXBUFFER *ppMeshArrayOut,
  905. LPD3DXBUFFER *ppAdjacencyArrayOut,
  906. LPD3DXBUFFER *ppFaceRemapArrayOut,
  907. LPD3DXBUFFER *ppVertRemapArrayOut
  908. );
  909. BOOL WINAPI D3DXIntersectTri
  910. (
  911. CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position
  912. CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position
  913. CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position
  914. CONST D3DXVECTOR3 *pRayPos, // Ray origin
  915. CONST D3DXVECTOR3 *pRayDir, // Ray direction
  916. FLOAT *pU, // Barycentric Hit Coordinates
  917. FLOAT *pV, // Barycentric Hit Coordinates
  918. FLOAT *pDist); // Ray-Intersection Parameter Distance
  919. BOOL WINAPI
  920. D3DXSphereBoundProbe(
  921. CONST D3DXVECTOR3 *pCenter,
  922. FLOAT Radius,
  923. CONST D3DXVECTOR3 *pRayPosition,
  924. CONST D3DXVECTOR3 *pRayDirection);
  925. BOOL WINAPI
  926. D3DXBoxBoundProbe(
  927. CONST D3DXVECTOR3 *pMin,
  928. CONST D3DXVECTOR3 *pMax,
  929. CONST D3DXVECTOR3 *pRayPosition,
  930. CONST D3DXVECTOR3 *pRayDirection);
  931. HRESULT WINAPI D3DXComputeTangentFrame(ID3DXMesh *pMesh,
  932. DWORD dwOptions);
  933. HRESULT WINAPI D3DXComputeTangentFrameEx(ID3DXMesh *pMesh,
  934. DWORD dwTextureInSemantic,
  935. DWORD dwTextureInIndex,
  936. DWORD dwUPartialOutSemantic,
  937. DWORD dwUPartialOutIndex,
  938. DWORD dwVPartialOutSemantic,
  939. DWORD dwVPartialOutIndex,
  940. DWORD dwNormalOutSemantic,
  941. DWORD dwNormalOutIndex,
  942. DWORD dwOptions,
  943. CONST DWORD *pdwAdjacency,
  944. FLOAT fPartialEdgeThreshold,
  945. FLOAT fSingularPointThreshold,
  946. FLOAT fNormalEdgeThreshold,
  947. ID3DXMesh **ppMeshOut,
  948. ID3DXBuffer **ppVertexMapping);
  949. //D3DXComputeTangent
  950. //
  951. //Computes the Tangent vectors for the TexStage texture coordinates
  952. //and places the results in the TANGENT[TangentIndex] specified in the meshes' DECL
  953. //puts the binorm in BINORM[BinormIndex] also specified in the decl.
  954. //
  955. //If neither the binorm or the tangnet are in the meshes declaration,
  956. //the function will fail.
  957. //
  958. //If a tangent or Binorm field is in the Decl, but the user does not
  959. //wish D3DXComputeTangent to replace them, then D3DX_DEFAULT specified
  960. //in the TangentIndex or BinormIndex will cause it to ignore the specified
  961. //semantic.
  962. //
  963. //Wrap should be specified if the texture coordinates wrap.
  964. HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH Mesh,
  965. DWORD TexStage,
  966. DWORD TangentIndex,
  967. DWORD BinormIndex,
  968. DWORD Wrap,
  969. CONST DWORD *pAdjacency);
  970. //============================================================================
  971. //
  972. // UVAtlas apis
  973. //
  974. //============================================================================
  975. typedef HRESULT (WINAPI *LPD3DXUVATLASCB)(FLOAT fPercentDone, LPVOID lpUserContext);
  976. // This function creates atlases for meshes. There are two modes of operation,
  977. // either based on the number of charts, or the maximum allowed stretch. If the
  978. // maximum allowed stretch is 0, then each triangle will likely be in its own
  979. // chart.
  980. //
  981. // The parameters are as follows:
  982. // pMesh - Input mesh to calculate an atlas for. This must have a position
  983. // channel and at least a 2-d texture channel.
  984. // uMaxChartNumber - The maximum number of charts required for the atlas.
  985. // If this is 0, it will be parameterized based solely on
  986. // stretch.
  987. // fMaxStretch - The maximum amount of stretch, if 0, no stretching is allowed,
  988. // if 1, then any amount of stretching is allowed.
  989. // uWidth - The width of the texture the atlas will be used on.
  990. // uHeight - The height of the texture the atlas will be used on.
  991. // fGutter - The minimum distance, in texels between two charts on the atlas.
  992. // this gets scaled by the width, so if fGutter is 2.5, and it is
  993. // used on a 512x512 texture, then the minimum distance will be
  994. // 2.5 / 512 in u-v space.
  995. // dwTextureIndex - Specifies which texture coordinate to write to in the
  996. // output mesh (which is cloned from the input mesh). Useful
  997. // if your vertex has multiple texture coordinates.
  998. // pdwAdjacency - a pointer to an array with 3 DWORDs per face, indicating
  999. // which triangles are adjacent to each other.
  1000. // pdwFalseEdgeAdjacency - a pointer to an array with 3 DWORDS per face, indicating
  1001. // at each face, whether an edge is a false edge or not (using
  1002. // the same ordering as the adjacency data structure). If this
  1003. // is NULL, then it is assumed that there are no false edges. If
  1004. // not NULL, then a non-false edge is indicated by -1 and a false
  1005. // edge is indicated by any other value (it is not required, but
  1006. // it may be useful for the caller to use the original adjacency
  1007. // value). This allows you to parameterize a mesh of quads, and
  1008. // the edges down the middle of each quad will not be cut when
  1009. // parameterizing the mesh.
  1010. // pfIMTArray - a pointer to an array with 3 FLOATs per face, describing the
  1011. // integrated metric tensor for that face. This lets you control
  1012. // the way this triangle may be stretched in the atlas. The IMT
  1013. // passed in will be 3 floats (a,b,c) and specify a symmetric
  1014. // matrix (a b) that, given a vector (s,t), specifies the
  1015. // (b c)
  1016. // distance between a vector v1 and a vector v2 = v1 + (s,t) as
  1017. // sqrt((s, t) * M * (s, t)^T).
  1018. // In other words, this lets one specify the magnitude of the
  1019. // stretch in an arbitrary direction in u-v space. For example
  1020. // if a = b = c = 1, then this scales the vector (1,1) by 2, and
  1021. // the vector (1,-1) by 0. Note that this is multiplying the edge
  1022. // length by the square of the matrix, so if you want the face to
  1023. // stretch to twice its
  1024. // size with no shearing, the IMT value should be (2, 0, 2), which
  1025. // is just the identity matrix times 2.
  1026. // Note that this assumes you have an orientation for the triangle
  1027. // in some 2-D space. For D3DXUVAtlas, this space is created by
  1028. // letting S be the direction from the first to the second
  1029. // vertex, and T be the cross product between the normal and S.
  1030. //
  1031. // pStatusCallback - Since the atlas creation process can be very CPU intensive,
  1032. // this allows the programmer to specify a function to be called
  1033. // periodically, similarly to how it is done in the PRT simulation
  1034. // engine.
  1035. // fCallbackFrequency - This lets you specify how often the callback will be
  1036. // called. A decent default should be 0.0001f.
  1037. // pUserContext - a void pointer to be passed back to the callback function
  1038. // dwOptions - A combination of flags in the D3DXUVATLAS enum
  1039. // ppMeshOut - A pointer to a location to store a pointer for the newly created
  1040. // mesh.
  1041. // ppFacePartitioning - A pointer to a location to store a pointer for an array,
  1042. // one DWORD per face, giving the final partitioning
  1043. // created by the atlasing algorithm.
  1044. // ppVertexRemapArray - A pointer to a location to store a pointer for an array,
  1045. // one DWORD per vertex, giving the vertex it was copied
  1046. // from, if any vertices needed to be split.
  1047. // pfMaxStretchOut - A location to store the maximum stretch resulting from the
  1048. // atlasing algorithm.
  1049. // puNumChartsOut - A location to store the number of charts created, or if the
  1050. // maximum number of charts was too low, this gives the minimum
  1051. // number of charts needed to create an atlas.
  1052. HRESULT WINAPI D3DXUVAtlasCreate(LPD3DXMESH pMesh,
  1053. UINT uMaxChartNumber,
  1054. FLOAT fMaxStretch,
  1055. UINT uWidth,
  1056. UINT uHeight,
  1057. FLOAT fGutter,
  1058. DWORD dwTextureIndex,
  1059. CONST DWORD *pdwAdjacency,
  1060. CONST DWORD *pdwFalseEdgeAdjacency,
  1061. CONST FLOAT *pfIMTArray,
  1062. LPD3DXUVATLASCB pStatusCallback,
  1063. FLOAT fCallbackFrequency,
  1064. LPVOID pUserContext,
  1065. DWORD dwOptions,
  1066. LPD3DXMESH *ppMeshOut,
  1067. LPD3DXBUFFER *ppFacePartitioning,
  1068. LPD3DXBUFFER *ppVertexRemapArray,
  1069. FLOAT *pfMaxStretchOut,
  1070. UINT *puNumChartsOut);
  1071. // This has the same exact arguments as Create, except that it does not perform the
  1072. // final packing step. This method allows one to get a partitioning out, and possibly
  1073. // modify it before sending it to be repacked. Note that if you change the
  1074. // partitioning, you'll also need to calculate new texture coordinates for any faces
  1075. // that have switched charts.
  1076. //
  1077. // The partition result adjacency output parameter is meant to be passed to the
  1078. // UVAtlasPack function, this adjacency cuts edges that are between adjacent
  1079. // charts, and also can include cuts inside of a chart in order to make it
  1080. // equivalent to a disc. For example:
  1081. //
  1082. // _______
  1083. // | ___ |
  1084. // | |_| |
  1085. // |_____|
  1086. //
  1087. // In order to make this equivalent to a disc, we would need to add a cut, and it
  1088. // Would end up looking like:
  1089. // _______
  1090. // | ___ |
  1091. // | |_|_|
  1092. // |_____|
  1093. //
  1094. // The resulting partition adjacency parameter cannot be NULL, because it is
  1095. // required for the packing step.
  1096. HRESULT WINAPI D3DXUVAtlasPartition(LPD3DXMESH pMesh,
  1097. UINT uMaxChartNumber,
  1098. FLOAT fMaxStretch,
  1099. DWORD dwTextureIndex,
  1100. CONST DWORD *pdwAdjacency,
  1101. CONST DWORD *pdwFalseEdgeAdjacency,
  1102. CONST FLOAT *pfIMTArray,
  1103. LPD3DXUVATLASCB pStatusCallback,
  1104. FLOAT fCallbackFrequency,
  1105. LPVOID pUserContext,
  1106. DWORD dwOptions,
  1107. LPD3DXMESH *ppMeshOut,
  1108. LPD3DXBUFFER *ppFacePartitioning,
  1109. LPD3DXBUFFER *ppVertexRemapArray,
  1110. LPD3DXBUFFER *ppPartitionResultAdjacency,
  1111. FLOAT *pfMaxStretchOut,
  1112. UINT *puNumChartsOut);
  1113. // This takes the face partitioning result from Partition and packs it into an
  1114. // atlas of the given size. pdwPartitionResultAdjacency should be derived from
  1115. // the adjacency returned from the partition step. This value cannot be NULL
  1116. // because Pack needs to know where charts were cut in the partition step in
  1117. // order to find the edges of each chart.
  1118. // The options parameter is currently reserved.
  1119. HRESULT WINAPI D3DXUVAtlasPack(ID3DXMesh *pMesh,
  1120. UINT uWidth,
  1121. UINT uHeight,
  1122. FLOAT fGutter,
  1123. DWORD dwTextureIndex,
  1124. CONST DWORD *pdwPartitionResultAdjacency,
  1125. LPD3DXUVATLASCB pStatusCallback,
  1126. FLOAT fCallbackFrequency,
  1127. LPVOID pUserContext,
  1128. DWORD dwOptions,
  1129. LPD3DXBUFFER pFacePartitioning);
  1130. //============================================================================
  1131. //
  1132. // IMT Calculation apis
  1133. //
  1134. // These functions all compute the Integrated Metric Tensor for use in the
  1135. // UVAtlas API. They all calculate the IMT with respect to the canonical
  1136. // triangle, where the coordinate system is set up so that the u axis goes
  1137. // from vertex 0 to 1 and the v axis is N x u. So, for example, the second
  1138. // vertex's canonical uv coordinates are (d,0) where d is the distance between
  1139. // vertices 0 and 1. This way the IMT does not depend on the parameterization
  1140. // of the mesh, and if the signal over the surface doesn't change, then
  1141. // the IMT doesn't need to be recalculated.
  1142. //============================================================================
  1143. // This callback is used by D3DXComputeIMTFromSignal.
  1144. //
  1145. // uv - The texture coordinate for the vertex.
  1146. // uPrimitiveID - Face ID of the triangle on which to compute the signal.
  1147. // uSignalDimension - The number of floats to store in pfSignalOut.
  1148. // pUserData - The pUserData pointer passed in to ComputeIMTFromSignal.
  1149. // pfSignalOut - A pointer to where to store the signal data.
  1150. typedef HRESULT (WINAPI* LPD3DXIMTSIGNALCALLBACK)
  1151. (CONST D3DXVECTOR2 *uv,
  1152. UINT uPrimitiveID,
  1153. UINT uSignalDimension,
  1154. VOID *pUserData,
  1155. FLOAT *pfSignalOut);
  1156. // This function is used to calculate the IMT from per vertex data. It sets
  1157. // up a linear system over the triangle, solves for the jacobian J, then
  1158. // constructs the IMT from that (J^TJ).
  1159. // This function allows you to calculate the IMT based off of any value in a
  1160. // mesh (color, normal, etc) by specifying the correct stride of the array.
  1161. // The IMT computed will cause areas of the mesh that have similar values to
  1162. // take up less space in the texture.
  1163. //
  1164. // pMesh - The mesh to calculate the IMT for.
  1165. // pVertexSignal - A float array of size uSignalStride * v, where v is the
  1166. // number of vertices in the mesh.
  1167. // uSignalDimension - How many floats per vertex to use in calculating the IMT.
  1168. // uSignalStride - The number of bytes per vertex in the array. This must be
  1169. // a multiple of sizeof(float)
  1170. // ppIMTData - Where to store the buffer holding the IMT data
  1171. HRESULT WINAPI D3DXComputeIMTFromPerVertexSignal (
  1172. LPD3DXMESH pMesh,
  1173. CONST FLOAT *pfVertexSignal, // uSignalDimension floats per vertex
  1174. UINT uSignalDimension,
  1175. UINT uSignalStride, // stride of signal in bytes
  1176. DWORD dwOptions, // reserved for future use
  1177. LPD3DXUVATLASCB pStatusCallback,
  1178. LPVOID pUserContext,
  1179. LPD3DXBUFFER *ppIMTData);
  1180. // This function is used to calculate the IMT from data that varies over the
  1181. // surface of the mesh (generally at a higher frequency than vertex data).
  1182. // This function requires the mesh to already be parameterized (so it already
  1183. // has texture coordinates). It allows the user to define a signal arbitrarily
  1184. // over the surface of the mesh.
  1185. //
  1186. // pMesh - The mesh to calculate the IMT for.
  1187. // dwTextureIndex - This describes which set of texture coordinates in the
  1188. // mesh to use.
  1189. // uSignalDimension - How many components there are in the signal.
  1190. // fMaxUVDistance - The subdivision will continue until the distance between
  1191. // all vertices is at most fMaxUVDistance.
  1192. // dwOptions - reserved for future use
  1193. // pSignalCallback - The callback to use to get the signal.
  1194. // pUserData - A pointer that will be passed in to the callback.
  1195. // ppIMTData - Where to store the buffer holding the IMT data
  1196. HRESULT WINAPI D3DXComputeIMTFromSignal(
  1197. LPD3DXMESH pMesh,
  1198. DWORD dwTextureIndex,
  1199. UINT uSignalDimension,
  1200. FLOAT fMaxUVDistance,
  1201. DWORD dwOptions, // reserved for future use
  1202. LPD3DXIMTSIGNALCALLBACK pSignalCallback,
  1203. VOID *pUserData,
  1204. LPD3DXUVATLASCB pStatusCallback,
  1205. LPVOID pUserContext,
  1206. LPD3DXBUFFER *ppIMTData);
  1207. // This function is used to calculate the IMT from texture data. Given a texture
  1208. // that maps over the surface of the mesh, the algorithm computes the IMT for
  1209. // each face. This will cause large areas that are very similar to take up less
  1210. // room when parameterized with UVAtlas. The texture is assumed to be
  1211. // interpolated over the mesh bilinearly.
  1212. //
  1213. // pMesh - The mesh to calculate the IMT for.
  1214. // pTexture - The texture to load data from.
  1215. // dwTextureIndex - This describes which set of texture coordinates in the
  1216. // mesh to use.
  1217. // dwOptions - Combination of one or more D3DXIMT flags.
  1218. // ppIMTData - Where to store the buffer holding the IMT data
  1219. HRESULT WINAPI D3DXComputeIMTFromTexture (
  1220. LPD3DXMESH pMesh,
  1221. LPDIRECT3DTEXTURE9 pTexture,
  1222. DWORD dwTextureIndex,
  1223. DWORD dwOptions,
  1224. LPD3DXUVATLASCB pStatusCallback,
  1225. LPVOID pUserContext,
  1226. LPD3DXBUFFER *ppIMTData);
  1227. // This function is very similar to ComputeIMTFromTexture, but it uses a
  1228. // float array to pass in the data, and it can calculate higher dimensional
  1229. // values than 4.
  1230. //
  1231. // pMesh - The mesh to calculate the IMT for.
  1232. // dwTextureIndex - This describes which set of texture coordinates in the
  1233. // mesh to use.
  1234. // pfFloatArray - a pointer to a float array of size
  1235. // uWidth*uHeight*uComponents
  1236. // uWidth - The width of the texture
  1237. // uHeight - The height of the texture
  1238. // uSignalDimension - The number of floats per texel in the signal
  1239. // uComponents - The number of floats in each texel
  1240. // dwOptions - Combination of one or more D3DXIMT flags
  1241. // ppIMTData - Where to store the buffer holding the IMT data
  1242. HRESULT WINAPI D3DXComputeIMTFromPerTexelSignal(
  1243. LPD3DXMESH pMesh,
  1244. DWORD dwTextureIndex,
  1245. FLOAT *pfTexelSignal,
  1246. UINT uWidth,
  1247. UINT uHeight,
  1248. UINT uSignalDimension,
  1249. UINT uComponents,
  1250. DWORD dwOptions,
  1251. LPD3DXUVATLASCB pStatusCallback,
  1252. LPVOID pUserContext,
  1253. LPD3DXBUFFER *ppIMTData);
  1254. HRESULT WINAPI
  1255. D3DXConvertMeshSubsetToSingleStrip(
  1256. LPD3DXBASEMESH MeshIn,
  1257. DWORD AttribId,
  1258. DWORD IBOptions,
  1259. LPDIRECT3DINDEXBUFFER9 *ppIndexBuffer,
  1260. DWORD *pNumIndices);
  1261. HRESULT WINAPI
  1262. D3DXConvertMeshSubsetToStrips(
  1263. LPD3DXBASEMESH MeshIn,
  1264. DWORD AttribId,
  1265. DWORD IBOptions,
  1266. LPDIRECT3DINDEXBUFFER9 *ppIndexBuffer,
  1267. DWORD *pNumIndices,
  1268. LPD3DXBUFFER *ppStripLengths,
  1269. DWORD *pNumStrips);
  1270. //============================================================================
  1271. //
  1272. // D3DXOptimizeFaces:
  1273. // --------------------
  1274. // Generate a face remapping for a triangle list that more effectively utilizes
  1275. // vertex caches. This optimization is identical to the one provided
  1276. // by ID3DXMesh::Optimize with the hardware independent option enabled.
  1277. //
  1278. // Parameters:
  1279. // pbIndices
  1280. // Triangle list indices to use for generating a vertex ordering
  1281. // NumFaces
  1282. // Number of faces in the triangle list
  1283. // NumVertices
  1284. // Number of vertices referenced by the triangle list
  1285. // b32BitIndices
  1286. // TRUE if indices are 32 bit, FALSE if indices are 16 bit
  1287. // pFaceRemap
  1288. // Destination buffer to store face ordering
  1289. // The number stored for a given element is where in the new ordering
  1290. // the face will have come from. See ID3DXMesh::Optimize for more info.
  1291. //
  1292. //============================================================================
  1293. HRESULT WINAPI
  1294. D3DXOptimizeFaces(
  1295. LPCVOID pbIndices,
  1296. UINT cFaces,
  1297. UINT cVertices,
  1298. BOOL b32BitIndices,
  1299. DWORD* pFaceRemap);
  1300. //============================================================================
  1301. //
  1302. // D3DXOptimizeVertices:
  1303. // --------------------
  1304. // Generate a vertex remapping to optimize for in order use of vertices for
  1305. // a given set of indices. This is commonly used after applying the face
  1306. // remap generated by D3DXOptimizeFaces
  1307. //
  1308. // Parameters:
  1309. // pbIndices
  1310. // Triangle list indices to use for generating a vertex ordering
  1311. // NumFaces
  1312. // Number of faces in the triangle list
  1313. // NumVertices
  1314. // Number of vertices referenced by the triangle list
  1315. // b32BitIndices
  1316. // TRUE if indices are 32 bit, FALSE if indices are 16 bit
  1317. // pVertexRemap
  1318. // Destination buffer to store vertex ordering
  1319. // The number stored for a given element is where in the new ordering
  1320. // the vertex will have come from. See ID3DXMesh::Optimize for more info.
  1321. //
  1322. //============================================================================
  1323. HRESULT WINAPI
  1324. D3DXOptimizeVertices(
  1325. LPCVOID pbIndices,
  1326. UINT cFaces,
  1327. UINT cVertices,
  1328. BOOL b32BitIndices,
  1329. DWORD* pVertexRemap);
  1330. #ifdef __cplusplus
  1331. }
  1332. #endif //__cplusplus
  1333. //===========================================================================
  1334. //
  1335. // Data structures for Spherical Harmonic Precomputation
  1336. //
  1337. //
  1338. //============================================================================
  1339. typedef enum _D3DXSHCOMPRESSQUALITYTYPE {
  1340. D3DXSHCQUAL_FASTLOWQUALITY = 1,
  1341. D3DXSHCQUAL_SLOWHIGHQUALITY = 2,
  1342. D3DXSHCQUAL_FORCE_DWORD = 0x7fffffff
  1343. } D3DXSHCOMPRESSQUALITYTYPE;
  1344. typedef enum _D3DXSHGPUSIMOPT {
  1345. D3DXSHGPUSIMOPT_SHADOWRES256 = 1,
  1346. D3DXSHGPUSIMOPT_SHADOWRES512 = 0,
  1347. D3DXSHGPUSIMOPT_SHADOWRES1024 = 2,
  1348. D3DXSHGPUSIMOPT_SHADOWRES2048 = 3,
  1349. D3DXSHGPUSIMOPT_HIGHQUALITY = 4,
  1350. D3DXSHGPUSIMOPT_FORCE_DWORD = 0x7fffffff
  1351. } D3DXSHGPUSIMOPT;
  1352. // for all properties that are colors the luminance is computed
  1353. // if the simulator is run with a single channel using the following
  1354. // formula: R * 0.2125 + G * 0.7154 + B * 0.0721
  1355. typedef struct _D3DXSHMATERIAL {
  1356. D3DCOLORVALUE Diffuse; // Diffuse albedo of the surface. (Ignored if object is a Mirror)
  1357. BOOL bMirror; // Must be set to FALSE. bMirror == TRUE not currently supported
  1358. BOOL bSubSurf; // true if the object does subsurface scattering - can't do this and be a mirror
  1359. // subsurface scattering parameters
  1360. FLOAT RelativeIndexOfRefraction;
  1361. D3DCOLORVALUE Absorption;
  1362. D3DCOLORVALUE ReducedScattering;
  1363. } D3DXSHMATERIAL;
  1364. // allocated in D3DXSHPRTCompSplitMeshSC
  1365. // vertices are duplicated into multiple super clusters but
  1366. // only have a valid status in one super cluster (fill in the rest)
  1367. typedef struct _D3DXSHPRTSPLITMESHVERTDATA {
  1368. UINT uVertRemap; // vertex in original mesh this corresponds to
  1369. UINT uSubCluster; // cluster index relative to super cluster
  1370. UCHAR ucVertStatus; // 1 if vertex has valid data, 0 if it is "fill"
  1371. } D3DXSHPRTSPLITMESHVERTDATA;
  1372. // used in D3DXSHPRTCompSplitMeshSC
  1373. // information for each super cluster that maps into face/vert arrays
  1374. typedef struct _D3DXSHPRTSPLITMESHCLUSTERDATA {
  1375. UINT uVertStart; // initial index into remapped vertex array
  1376. UINT uVertLength; // number of vertices in this super cluster
  1377. UINT uFaceStart; // initial index into face array
  1378. UINT uFaceLength; // number of faces in this super cluster
  1379. UINT uClusterStart; // initial index into cluster array
  1380. UINT uClusterLength; // number of clusters in this super cluster
  1381. } D3DXSHPRTSPLITMESHCLUSTERDATA;
  1382. // call back function for simulator
  1383. // return S_OK to keep running the simulator - anything else represents
  1384. // failure and the simulator will abort.
  1385. typedef HRESULT (WINAPI *LPD3DXSHPRTSIMCB)(float fPercentDone, LPVOID lpUserContext);
  1386. // interfaces for PRT buffers/simulator
  1387. // GUIDs
  1388. // {F1827E47-00A8-49cd-908C-9D11955F8728}
  1389. DEFINE_GUID(IID_ID3DXPRTBuffer,
  1390. 0xf1827e47, 0xa8, 0x49cd, 0x90, 0x8c, 0x9d, 0x11, 0x95, 0x5f, 0x87, 0x28);
  1391. // {A758D465-FE8D-45ad-9CF0-D01E56266A07}
  1392. DEFINE_GUID(IID_ID3DXPRTCompBuffer,
  1393. 0xa758d465, 0xfe8d, 0x45ad, 0x9c, 0xf0, 0xd0, 0x1e, 0x56, 0x26, 0x6a, 0x7);
  1394. // {838F01EC-9729-4527-AADB-DF70ADE7FEA9}
  1395. DEFINE_GUID(IID_ID3DXTextureGutterHelper,
  1396. 0x838f01ec, 0x9729, 0x4527, 0xaa, 0xdb, 0xdf, 0x70, 0xad, 0xe7, 0xfe, 0xa9);
  1397. // {683A4278-CD5F-4d24-90AD-C4E1B6855D53}
  1398. DEFINE_GUID(IID_ID3DXPRTEngine,
  1399. 0x683a4278, 0xcd5f, 0x4d24, 0x90, 0xad, 0xc4, 0xe1, 0xb6, 0x85, 0x5d, 0x53);
  1400. // interface defenitions
  1401. typedef interface ID3DXTextureGutterHelper ID3DXTextureGutterHelper;
  1402. typedef interface ID3DXPRTBuffer ID3DXPRTBuffer;
  1403. #undef INTERFACE
  1404. #define INTERFACE ID3DXPRTBuffer
  1405. // Buffer interface - contains "NumSamples" samples
  1406. // each sample in memory is stored as NumCoeffs scalars per channel (1 or 3)
  1407. // Same interface is used for both Vertex and Pixel PRT buffers
  1408. DECLARE_INTERFACE_(ID3DXPRTBuffer, IUnknown)
  1409. {
  1410. // IUnknown
  1411. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  1412. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  1413. STDMETHOD_(ULONG, Release)(THIS) PURE;
  1414. // ID3DXPRTBuffer
  1415. STDMETHOD_(UINT, GetNumSamples)(THIS) PURE;
  1416. STDMETHOD_(UINT, GetNumCoeffs)(THIS) PURE;
  1417. STDMETHOD_(UINT, GetNumChannels)(THIS) PURE;
  1418. STDMETHOD_(BOOL, IsTexture)(THIS) PURE;
  1419. STDMETHOD_(UINT, GetWidth)(THIS) PURE;
  1420. STDMETHOD_(UINT, GetHeight)(THIS) PURE;
  1421. // changes the number of samples allocated in the buffer
  1422. STDMETHOD(Resize)(THIS_ UINT NewSize) PURE;
  1423. // ppData will point to the memory location where sample Start begins
  1424. // pointer is valid for at least NumSamples samples
  1425. STDMETHOD(LockBuffer)(THIS_ UINT Start, UINT NumSamples, FLOAT **ppData) PURE;
  1426. STDMETHOD(UnlockBuffer)(THIS) PURE;
  1427. // every scalar in buffer is multiplied by Scale
  1428. STDMETHOD(ScaleBuffer)(THIS_ FLOAT Scale) PURE;
  1429. // every scalar contains the sum of this and pBuffers values
  1430. // pBuffer must have the same storage class/dimensions
  1431. STDMETHOD(AddBuffer)(THIS_ LPD3DXPRTBUFFER pBuffer) PURE;
  1432. // GutterHelper (described below) will fill in the gutter
  1433. // regions of a texture by interpolating "internal" values
  1434. STDMETHOD(AttachGH)(THIS_ LPD3DXTEXTUREGUTTERHELPER) PURE;
  1435. STDMETHOD(ReleaseGH)(THIS) PURE;
  1436. // Evaluates attached gutter helper on the contents of this buffer
  1437. STDMETHOD(EvalGH)(THIS) PURE;
  1438. // extracts a given channel into texture pTexture
  1439. // NumCoefficients starting from StartCoefficient are copied
  1440. STDMETHOD(ExtractTexture)(THIS_ UINT Channel, UINT StartCoefficient,
  1441. UINT NumCoefficients, LPDIRECT3DTEXTURE9 pTexture) PURE;
  1442. // extracts NumCoefficients coefficients into mesh - only applicable on single channel
  1443. // buffers, otherwise just lockbuffer and copy data. With SHPRT data NumCoefficients
  1444. // should be Order^2
  1445. STDMETHOD(ExtractToMesh)(THIS_ UINT NumCoefficients, D3DDECLUSAGE Usage, UINT UsageIndexStart,
  1446. LPD3DXMESH pScene) PURE;
  1447. };
  1448. typedef interface ID3DXPRTCompBuffer ID3DXPRTCompBuffer;
  1449. typedef interface ID3DXPRTCompBuffer *LPD3DXPRTCOMPBUFFER;
  1450. #undef INTERFACE
  1451. #define INTERFACE ID3DXPRTCompBuffer
  1452. // compressed buffers stored a compressed version of a PRTBuffer
  1453. DECLARE_INTERFACE_(ID3DXPRTCompBuffer, IUnknown)
  1454. {
  1455. // IUnknown
  1456. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  1457. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  1458. STDMETHOD_(ULONG, Release)(THIS) PURE;
  1459. // ID3DPRTCompBuffer
  1460. // NumCoeffs and NumChannels are properties of input buffer
  1461. STDMETHOD_(UINT, GetNumSamples)(THIS) PURE;
  1462. STDMETHOD_(UINT, GetNumCoeffs)(THIS) PURE;
  1463. STDMETHOD_(UINT, GetNumChannels)(THIS) PURE;
  1464. STDMETHOD_(BOOL, IsTexture)(THIS) PURE;
  1465. STDMETHOD_(UINT, GetWidth)(THIS) PURE;
  1466. STDMETHOD_(UINT, GetHeight)(THIS) PURE;
  1467. // number of clusters, and PCA vectors per-cluster
  1468. STDMETHOD_(UINT, GetNumClusters)(THIS) PURE;
  1469. STDMETHOD_(UINT, GetNumPCA)(THIS) PURE;
  1470. // normalizes PCA weights so that they are between [-1,1]
  1471. // basis vectors are modified to reflect this
  1472. STDMETHOD(NormalizeData)(THIS) PURE;
  1473. // copies basis vectors for cluster "Cluster" into pClusterBasis
  1474. // (NumPCA+1)*NumCoeffs*NumChannels floats
  1475. STDMETHOD(ExtractBasis)(THIS_ UINT Cluster, FLOAT *pClusterBasis) PURE;
  1476. // UINT per sample - which cluster it belongs to
  1477. STDMETHOD(ExtractClusterIDs)(THIS_ UINT *pClusterIDs) PURE;
  1478. // copies NumExtract PCA projection coefficients starting at StartPCA
  1479. // into pPCACoefficients - NumSamples*NumExtract floats copied
  1480. STDMETHOD(ExtractPCA)(THIS_ UINT StartPCA, UINT NumExtract, FLOAT *pPCACoefficients) PURE;
  1481. // copies NumPCA projection coefficients starting at StartPCA
  1482. // into pTexture - should be able to cope with signed formats
  1483. STDMETHOD(ExtractTexture)(THIS_ UINT StartPCA, UINT NumpPCA,
  1484. LPDIRECT3DTEXTURE9 pTexture) PURE;
  1485. // copies NumPCA projection coefficients into mesh pScene
  1486. // Usage is D3DDECLUSAGE where coefficients are to be stored
  1487. // UsageIndexStart is starting index
  1488. STDMETHOD(ExtractToMesh)(THIS_ UINT NumPCA, D3DDECLUSAGE Usage, UINT UsageIndexStart,
  1489. LPD3DXMESH pScene) PURE;
  1490. };
  1491. #undef INTERFACE
  1492. #define INTERFACE ID3DXTextureGutterHelper
  1493. // ID3DXTextureGutterHelper will build and manage
  1494. // "gutter" regions in a texture - this will allow for
  1495. // bi-linear interpolation to not have artifacts when rendering
  1496. // It generates a map (in texture space) where each texel
  1497. // is in one of 3 states:
  1498. // 0 Invalid - not used at all
  1499. // 1 Inside triangle
  1500. // 2 Gutter texel
  1501. // 4 represents a gutter texel that will be computed during PRT
  1502. // For each Inside/Gutter texel it stores the face it
  1503. // belongs to and barycentric coordinates for the 1st two
  1504. // vertices of that face. Gutter vertices are assigned to
  1505. // the closest edge in texture space.
  1506. //
  1507. // When used with PRT this requires a unique parameterization
  1508. // of the model - every texel must correspond to a single point
  1509. // on the surface of the model and vice versa
  1510. DECLARE_INTERFACE_(ID3DXTextureGutterHelper, IUnknown)
  1511. {
  1512. // IUnknown
  1513. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  1514. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  1515. STDMETHOD_(ULONG, Release)(THIS) PURE;
  1516. // ID3DXTextureGutterHelper
  1517. // dimensions of texture this is bound too
  1518. STDMETHOD_(UINT, GetWidth)(THIS) PURE;
  1519. STDMETHOD_(UINT, GetHeight)(THIS) PURE;
  1520. // Applying gutters recomputes all of the gutter texels of class "2"
  1521. // based on texels of class "1" or "4"
  1522. // Applies gutters to a raw float buffer - each texel is NumCoeffs floats
  1523. // Width and Height must match GutterHelper
  1524. STDMETHOD(ApplyGuttersFloat)(THIS_ FLOAT *pDataIn, UINT NumCoeffs, UINT Width, UINT Height);
  1525. // Applies gutters to pTexture
  1526. // Dimensions must match GutterHelper
  1527. STDMETHOD(ApplyGuttersTex)(THIS_ LPDIRECT3DTEXTURE9 pTexture);
  1528. // Applies gutters to a D3DXPRTBuffer
  1529. // Dimensions must match GutterHelper
  1530. STDMETHOD(ApplyGuttersPRT)(THIS_ LPD3DXPRTBUFFER pBuffer);
  1531. // Resamples a texture from a mesh onto this gutterhelpers
  1532. // parameterization. It is assumed that the UV coordinates
  1533. // for this gutter helper are in TEXTURE 0 (usage/usage index)
  1534. // and the texture coordinates should all be within [0,1] for
  1535. // both sets.
  1536. //
  1537. // pTextureIn - texture represented using parameterization in pMeshIn
  1538. // pMeshIn - Mesh with texture coordinates that represent pTextureIn
  1539. // pTextureOut texture coordinates are assumed to be in
  1540. // TEXTURE 0
  1541. // Usage - field in DECL for pMeshIn that stores texture coordinates
  1542. // for pTextureIn
  1543. // UsageIndex - which index for Usage above for pTextureIn
  1544. // pTextureOut- Resampled texture
  1545. //
  1546. // Usage would generally be D3DDECLUSAGE_TEXCOORD and UsageIndex other than zero
  1547. STDMETHOD(ResampleTex)(THIS_ LPDIRECT3DTEXTURE9 pTextureIn,
  1548. LPD3DXMESH pMeshIn,
  1549. D3DDECLUSAGE Usage, UINT UsageIndex,
  1550. LPDIRECT3DTEXTURE9 pTextureOut);
  1551. // the routines below provide access to the data structures
  1552. // used by the Apply functions
  1553. // face map is a UINT per texel that represents the
  1554. // face of the mesh that texel belongs too -
  1555. // only valid if same texel is valid in pGutterData
  1556. // pFaceData must be allocated by the user
  1557. STDMETHOD(GetFaceMap)(THIS_ UINT *pFaceData) PURE;
  1558. // BaryMap is a D3DXVECTOR2 per texel
  1559. // the 1st two barycentric coordinates for the corresponding
  1560. // face (3rd weight is always 1-sum of first two)
  1561. // only valid if same texel is valid in pGutterData
  1562. // pBaryData must be allocated by the user
  1563. STDMETHOD(GetBaryMap)(THIS_ D3DXVECTOR2 *pBaryData) PURE;
  1564. // TexelMap is a D3DXVECTOR2 per texel that
  1565. // stores the location in pixel coordinates where the
  1566. // corresponding texel is mapped
  1567. // pTexelData must be allocated by the user
  1568. STDMETHOD(GetTexelMap)(THIS_ D3DXVECTOR2 *pTexelData) PURE;
  1569. // GutterMap is a BYTE per texel
  1570. // 0/1/2 for Invalid/Internal/Gutter texels
  1571. // 4 represents a gutter texel that will be computed
  1572. // during PRT
  1573. // pGutterData must be allocated by the user
  1574. STDMETHOD(GetGutterMap)(THIS_ BYTE *pGutterData) PURE;
  1575. // face map is a UINT per texel that represents the
  1576. // face of the mesh that texel belongs too -
  1577. // only valid if same texel is valid in pGutterData
  1578. STDMETHOD(SetFaceMap)(THIS_ UINT *pFaceData) PURE;
  1579. // BaryMap is a D3DXVECTOR2 per texel
  1580. // the 1st two barycentric coordinates for the corresponding
  1581. // face (3rd weight is always 1-sum of first two)
  1582. // only valid if same texel is valid in pGutterData
  1583. STDMETHOD(SetBaryMap)(THIS_ D3DXVECTOR2 *pBaryData) PURE;
  1584. // TexelMap is a D3DXVECTOR2 per texel that
  1585. // stores the location in pixel coordinates where the
  1586. // corresponding texel is mapped
  1587. STDMETHOD(SetTexelMap)(THIS_ D3DXVECTOR2 *pTexelData) PURE;
  1588. // GutterMap is a BYTE per texel
  1589. // 0/1/2 for Invalid/Internal/Gutter texels
  1590. // 4 represents a gutter texel that will be computed
  1591. // during PRT
  1592. STDMETHOD(SetGutterMap)(THIS_ BYTE *pGutterData) PURE;
  1593. };
  1594. typedef interface ID3DXPRTEngine ID3DXPRTEngine;
  1595. typedef interface ID3DXPRTEngine *LPD3DXPRTENGINE;
  1596. #undef INTERFACE
  1597. #define INTERFACE ID3DXPRTEngine
  1598. // ID3DXPRTEngine is used to compute a PRT simulation
  1599. // Use the following steps to compute PRT for SH
  1600. // (1) create an interface (which includes a scene)
  1601. // (2) call SetSamplingInfo
  1602. // (3) [optional] Set MeshMaterials/albedo's (required if doing bounces)
  1603. // (4) call ComputeDirectLightingSH
  1604. // (5) [optional] call ComputeBounce
  1605. // repeat step 5 for as many bounces as wanted.
  1606. // if you want to model subsurface scattering you
  1607. // need to call ComputeSS after direct lighting and
  1608. // each bounce.
  1609. // If you want to bake the albedo into the PRT signal, you
  1610. // must call MutliplyAlbedo, otherwise the user has to multiply
  1611. // the albedo themselves. Not multiplying the albedo allows you
  1612. // to model albedo variation at a finer scale then illumination, and
  1613. // can result in better compression results.
  1614. // Luminance values are computed from RGB values using the following
  1615. // formula: R * 0.2125 + G * 0.7154 + B * 0.0721
  1616. DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown)
  1617. {
  1618. // IUnknown
  1619. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  1620. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  1621. STDMETHOD_(ULONG, Release)(THIS) PURE;
  1622. // ID3DXPRTEngine
  1623. // This sets a material per attribute in the scene mesh and it is
  1624. // the only way to specify subsurface scattering parameters. if
  1625. // bSetAlbedo is FALSE, NumChannels must match the current
  1626. // configuration of the PRTEngine. If you intend to change
  1627. // NumChannels (through some other SetAlbedo function) it must
  1628. // happen before SetMeshMaterials is called.
  1629. //
  1630. // NumChannels 1 implies "grayscale" materials, set this to 3 to enable
  1631. // color bleeding effects
  1632. // bSetAlbedo sets albedo from material if TRUE - which clobbers per texel/vertex
  1633. // albedo that might have been set before. FALSE won't clobber.
  1634. // fLengthScale is used for subsurface scattering - scene is mapped into a 1mm unit cube
  1635. // and scaled by this amount
  1636. STDMETHOD(SetMeshMaterials)(THIS_ CONST D3DXSHMATERIAL **ppMaterials, UINT NumMeshes,
  1637. UINT NumChannels, BOOL bSetAlbedo, FLOAT fLengthScale) PURE;
  1638. // setting albedo per-vertex or per-texel over rides the albedos stored per mesh
  1639. // but it does not over ride any other settings
  1640. // sets an albedo to be used per vertex - the albedo is represented as a float
  1641. // pDataIn input pointer (pointint to albedo of 1st sample)
  1642. // NumChannels 1 implies "grayscale" materials, set this to 3 to enable
  1643. // color bleeding effects
  1644. // Stride - stride in bytes to get to next samples albedo
  1645. STDMETHOD(SetPerVertexAlbedo)(THIS_ CONST VOID *pDataIn, UINT NumChannels, UINT Stride) PURE;
  1646. // represents the albedo per-texel instead of per-vertex (even if per-vertex PRT is used)
  1647. // pAlbedoTexture - texture that stores the albedo (dimension arbitrary)
  1648. // NumChannels 1 implies "grayscale" materials, set this to 3 to enable
  1649. // color bleeding effects
  1650. // pGH - optional gutter helper, otherwise one is constructed in computation routines and
  1651. // destroyed (if not attached to buffers)
  1652. STDMETHOD(SetPerTexelAlbedo)(THIS_ LPDIRECT3DTEXTURE9 pAlbedoTexture,
  1653. UINT NumChannels,
  1654. LPD3DXTEXTUREGUTTERHELPER pGH) PURE;
  1655. // gets the per-vertex albedo
  1656. STDMETHOD(GetVertexAlbedo)(THIS_ D3DXCOLOR *pVertColors, UINT NumVerts) PURE;
  1657. // If pixel PRT is being computed normals default to ones that are interpolated
  1658. // from the vertex normals. This specifies a texture that stores an object
  1659. // space normal map instead (must use a texture format that can represent signed values)
  1660. // pNormalTexture - normal map, must be same dimensions as PRTBuffers, signed
  1661. STDMETHOD(SetPerTexelNormal)(THIS_ LPDIRECT3DTEXTURE9 pNormalTexture) PURE;
  1662. // Copies per-vertex albedo from mesh
  1663. // pMesh - mesh that represents the scene. It must have the same
  1664. // properties as the mesh used to create the PRTEngine
  1665. // Usage - D3DDECLUSAGE to extract albedos from
  1666. // NumChannels 1 implies "grayscale" materials, set this to 3 to enable
  1667. // color bleeding effects
  1668. STDMETHOD(ExtractPerVertexAlbedo)(THIS_ LPD3DXMESH pMesh,
  1669. D3DDECLUSAGE Usage,
  1670. UINT NumChannels) PURE;
  1671. // Resamples the input buffer into the output buffer
  1672. // can be used to move between per-vertex and per-texel buffers. This can also be used
  1673. // to convert single channel buffers to 3-channel buffers and vice-versa.
  1674. STDMETHOD(ResampleBuffer)(THIS_ LPD3DXPRTBUFFER pBufferIn, LPD3DXPRTBUFFER pBufferOut) PURE;
  1675. // Returns the scene mesh - including modifications from adaptive spatial sampling
  1676. // The returned mesh only has positions, normals and texture coordinates (if defined)
  1677. // pD3DDevice - d3d device that will be used to allocate the mesh
  1678. // pFaceRemap - each face has a pointer back to the face on the original mesh that it comes from
  1679. // if the face hasn't been subdivided this will be an identity mapping
  1680. // pVertRemap - each vertex contains 3 vertices that this is a linear combination of
  1681. // pVertWeights - weights for each of above indices (sum to 1.0f)
  1682. // ppMesh - mesh that will be allocated and filled
  1683. STDMETHOD(GetAdaptedMesh)(THIS_ LPDIRECT3DDEVICE9 pD3DDevice,UINT *pFaceRemap, UINT *pVertRemap, FLOAT *pfVertWeights, LPD3DXMESH *ppMesh) PURE;
  1684. // Number of vertices currently allocated (includes new vertices from adaptive sampling)
  1685. STDMETHOD_(UINT, GetNumVerts)(THIS) PURE;
  1686. // Number of faces currently allocated (includes new faces)
  1687. STDMETHOD_(UINT, GetNumFaces)(THIS) PURE;
  1688. // Sets the Minimum/Maximum intersection distances, this can be used to control
  1689. // maximum distance that objects can shadow/reflect light, and help with "bad"
  1690. // art that might have near features that you don't want to shadow. This does not
  1691. // apply for GPU simulations.
  1692. // fMin - minimum intersection distance, must be positive and less than fMax
  1693. // fMax - maximum intersection distance, if 0.0f use the previous value, otherwise
  1694. // must be strictly greater than fMin
  1695. STDMETHOD(SetMinMaxIntersection)(THIS_ FLOAT fMin, FLOAT fMax) PURE;
  1696. // This will subdivide faces on a mesh so that adaptively simulations can
  1697. // use a more conservative threshold (it won't miss features.)
  1698. // MinEdgeLength - minimum edge length that will be generated, if 0.0f a
  1699. // reasonable default will be used
  1700. // MaxSubdiv - maximum level of subdivision, if 0 is specified a default
  1701. // value will be used (5)
  1702. STDMETHOD(RobustMeshRefine)(THIS_ FLOAT MinEdgeLength, UINT MaxSubdiv) PURE;
  1703. // This sets to sampling information used by the simulator. Adaptive sampling
  1704. // parameters are currently ignored.
  1705. // NumRays - number of rays to shoot per sample
  1706. // UseSphere - if TRUE uses spherical samples, otherwise samples over
  1707. // the hemisphere. Should only be used with GPU and Vol computations
  1708. // UseCosine - if TRUE uses a cosine weighting - not used for Vol computations
  1709. // or if only the visiblity function is desired
  1710. // Adaptive - if TRUE adaptive sampling (angular) is used
  1711. // AdaptiveThresh - threshold used to terminate adaptive angular sampling
  1712. // ignored if adaptive sampling is not set
  1713. STDMETHOD(SetSamplingInfo)(THIS_ UINT NumRays,
  1714. BOOL UseSphere,
  1715. BOOL UseCosine,
  1716. BOOL Adaptive,
  1717. FLOAT AdaptiveThresh) PURE;
  1718. // Methods that compute the direct lighting contribution for objects
  1719. // always represente light using spherical harmonics (SH)
  1720. // the albedo is not multiplied by the signal - it just integrates
  1721. // incoming light. If NumChannels is not 1 the vector is replicated
  1722. //
  1723. // SHOrder - order of SH to use
  1724. // pDataOut - PRT buffer that is generated. Can be single channel
  1725. STDMETHOD(ComputeDirectLightingSH)(THIS_ UINT SHOrder,
  1726. LPD3DXPRTBUFFER pDataOut) PURE;
  1727. // Adaptive variant of above function. This will refine the mesh
  1728. // generating new vertices/faces to approximate the PRT signal
  1729. // more faithfully.
  1730. // SHOrder - order of SH to use
  1731. // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error)
  1732. // if value is less then 1e-6f, 1e-6f is specified
  1733. // MinEdgeLength - minimum edge length that will be generated
  1734. // if value is too small a fairly conservative model dependent value
  1735. // is used
  1736. // MaxSubdiv - maximum subdivision level, if 0 is specified it
  1737. // will default to 4
  1738. // pDataOut - PRT buffer that is generated. Can be single channel.
  1739. STDMETHOD(ComputeDirectLightingSHAdaptive)(THIS_ UINT SHOrder,
  1740. FLOAT AdaptiveThresh,
  1741. FLOAT MinEdgeLength,
  1742. UINT MaxSubdiv,
  1743. LPD3DXPRTBUFFER pDataOut) PURE;
  1744. // Function that computes the direct lighting contribution for objects
  1745. // light is always represented using spherical harmonics (SH)
  1746. // This is done on the GPU and is much faster then using the CPU.
  1747. // The albedo is not multiplied by the signal - it just integrates
  1748. // incoming light. If NumChannels is not 1 the vector is replicated.
  1749. // ZBias/ZAngleBias are akin to parameters used with shadow zbuffers.
  1750. // A reasonable default for both values is 0.005, but the user should
  1751. // experiment (ZAngleBias can be zero, ZBias should not be.)
  1752. // Callbacks should not use the Direct3D9Device the simulator is using.
  1753. // SetSamplingInfo must be called with TRUE for UseSphere and
  1754. // FALSE for UseCosine before this method is called.
  1755. //
  1756. // pD3DDevice - device used to run GPU simulator - must support PS2.0
  1757. // and FP render targets
  1758. // Flags - parameters for the GPU simulator, combination of one or more
  1759. // D3DXSHGPUSIMOPT flags. Only one SHADOWRES setting should be set and
  1760. // the defaults is 512
  1761. // SHOrder - order of SH to use
  1762. // ZBias - bias in normal direction (for depth test)
  1763. // ZAngleBias - scaled by one minus cosine of angle with light (offset in depth)
  1764. // pDataOut - PRT buffer that is filled in. Can be single channel
  1765. STDMETHOD(ComputeDirectLightingSHGPU)(THIS_ LPDIRECT3DDEVICE9 pD3DDevice,
  1766. UINT Flags,
  1767. UINT SHOrder,
  1768. FLOAT ZBias,
  1769. FLOAT ZAngleBias,
  1770. LPD3DXPRTBUFFER pDataOut) PURE;
  1771. // Functions that computes subsurface scattering (using material properties)
  1772. // Albedo is not multiplied by result. This only works for per-vertex data
  1773. // use ResampleBuffer to move per-vertex data into a texture and back.
  1774. //
  1775. // pDataIn - input data (previous bounce)
  1776. // pDataOut - result of subsurface scattering simulation
  1777. // pDataTotal - [optional] results can be summed into this buffer
  1778. STDMETHOD(ComputeSS)(THIS_ LPD3DXPRTBUFFER pDataIn,
  1779. LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE;
  1780. // Adaptive version of ComputeSS.
  1781. //
  1782. // pDataIn - input data (previous bounce)
  1783. // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error)
  1784. // if value is less then 1e-6f, 1e-6f is specified
  1785. // MinEdgeLength - minimum edge length that will be generated
  1786. // if value is too small a fairly conservative model dependent value
  1787. // is used
  1788. // MaxSubdiv - maximum subdivision level, if 0 is specified it
  1789. // will default to 4
  1790. // pDataOut - result of subsurface scattering simulation
  1791. // pDataTotal - [optional] results can be summed into this buffer
  1792. STDMETHOD(ComputeSSAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn,
  1793. FLOAT AdaptiveThresh,
  1794. FLOAT MinEdgeLength,
  1795. UINT MaxSubdiv,
  1796. LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE;
  1797. // computes a single bounce of inter-reflected light
  1798. // works for SH based PRT or generic lighting
  1799. // Albedo is not multiplied by result
  1800. //
  1801. // pDataIn - previous bounces data
  1802. // pDataOut - PRT buffer that is generated
  1803. // pDataTotal - [optional] can be used to keep a running sum
  1804. STDMETHOD(ComputeBounce)(THIS_ LPD3DXPRTBUFFER pDataIn,
  1805. LPD3DXPRTBUFFER pDataOut,
  1806. LPD3DXPRTBUFFER pDataTotal) PURE;
  1807. // Adaptive version of above function.
  1808. //
  1809. // pDataIn - previous bounces data, can be single channel
  1810. // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error)
  1811. // if value is less then 1e-6f, 1e-6f is specified
  1812. // MinEdgeLength - minimum edge length that will be generated
  1813. // if value is too small a fairly conservative model dependent value
  1814. // is used
  1815. // MaxSubdiv - maximum subdivision level, if 0 is specified it
  1816. // will default to 4
  1817. // pDataOut - PRT buffer that is generated
  1818. // pDataTotal - [optional] can be used to keep a running sum
  1819. STDMETHOD(ComputeBounceAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn,
  1820. FLOAT AdaptiveThresh,
  1821. FLOAT MinEdgeLength,
  1822. UINT MaxSubdiv,
  1823. LPD3DXPRTBUFFER pDataOut,
  1824. LPD3DXPRTBUFFER pDataTotal) PURE;
  1825. // Computes projection of distant SH radiance into a local SH radiance
  1826. // function. This models how direct lighting is attenuated by the
  1827. // scene and is a form of "neighborhood transfer." The result is
  1828. // a linear operator (matrix) at every sample point, if you multiply
  1829. // this matrix by the distant SH lighting coefficients you get an
  1830. // approximation of the local incident radiance function from
  1831. // direct lighting. These resulting lighting coefficients can
  1832. // than be projected into another basis or used with any rendering
  1833. // technique that uses spherical harmonics as input.
  1834. // SetSamplingInfo must be called with TRUE for UseSphere and
  1835. // FALSE for UseCosine before this method is called.
  1836. // Generates SHOrderIn*SHOrderIn*SHOrderOut*SHOrderOut scalars
  1837. // per channel at each sample location.
  1838. //
  1839. // SHOrderIn - Order of the SH representation of distant lighting
  1840. // SHOrderOut - Order of the SH representation of local lighting
  1841. // NumVolSamples - Number of sample locations
  1842. // pSampleLocs - position of sample locations
  1843. // pDataOut - PRT Buffer that will store output results
  1844. STDMETHOD(ComputeVolumeSamplesDirectSH)(THIS_ UINT SHOrderIn,
  1845. UINT SHOrderOut,
  1846. UINT NumVolSamples,
  1847. CONST D3DXVECTOR3 *pSampleLocs,
  1848. LPD3DXPRTBUFFER pDataOut) PURE;
  1849. // At each sample location computes a linear operator (matrix) that maps
  1850. // the representation of source radiance (NumCoeffs in pSurfDataIn)
  1851. // into a local incident radiance function approximated with spherical
  1852. // harmonics. For example if a light map data is specified in pSurfDataIn
  1853. // the result is an SH representation of the flow of light at each sample
  1854. // point. If PRT data for an outdoor scene is used, each sample point
  1855. // contains a matrix that models how distant lighting bounces of the objects
  1856. // in the scene and arrives at the given sample point. Combined with
  1857. // ComputeVolumeSamplesDirectSH this gives the complete representation for
  1858. // how light arrives at each sample point parameterized by distant lighting.
  1859. // SetSamplingInfo must be called with TRUE for UseSphere and
  1860. // FALSE for UseCosine before this method is called.
  1861. // Generates pSurfDataIn->NumCoeffs()*SHOrder*SHOrder scalars
  1862. // per channel at each sample location.
  1863. //
  1864. // pSurfDataIn - previous bounce data
  1865. // SHOrder - order of SH to generate projection with
  1866. // NumVolSamples - Number of sample locations
  1867. // pSampleLocs - position of sample locations
  1868. // pDataOut - PRT Buffer that will store output results
  1869. STDMETHOD(ComputeVolumeSamples)(THIS_ LPD3DXPRTBUFFER pSurfDataIn,
  1870. UINT SHOrder,
  1871. UINT NumVolSamples,
  1872. CONST D3DXVECTOR3 *pSampleLocs,
  1873. LPD3DXPRTBUFFER pDataOut) PURE;
  1874. // Computes direct lighting (SH) for a point not on the mesh
  1875. // with a given normal - cannot use texture buffers.
  1876. //
  1877. // SHOrder - order of SH to use
  1878. // NumSamples - number of sample locations
  1879. // pSampleLocs - position for each sample
  1880. // pSampleNorms - normal for each sample
  1881. // pDataOut - PRT Buffer that will store output results
  1882. STDMETHOD(ComputeSurfSamplesDirectSH)(THIS_ UINT SHOrder,
  1883. UINT NumSamples,
  1884. CONST D3DXVECTOR3 *pSampleLocs,
  1885. CONST D3DXVECTOR3 *pSampleNorms,
  1886. LPD3DXPRTBUFFER pDataOut) PURE;
  1887. // given the solution for PRT or light maps, computes transfer vector at arbitrary
  1888. // position/normal pairs in space
  1889. //
  1890. // pSurfDataIn - input data
  1891. // NumSamples - number of sample locations
  1892. // pSampleLocs - position for each sample
  1893. // pSampleNorms - normal for each sample
  1894. // pDataOut - PRT Buffer that will store output results
  1895. // pDataTotal - optional buffer to sum results into - can be NULL
  1896. STDMETHOD(ComputeSurfSamplesBounce)(THIS_ LPD3DXPRTBUFFER pSurfDataIn,
  1897. UINT NumSamples,
  1898. CONST D3DXVECTOR3 *pSampleLocs,
  1899. CONST D3DXVECTOR3 *pSampleNorms,
  1900. LPD3DXPRTBUFFER pDataOut,
  1901. LPD3DXPRTBUFFER pDataTotal) PURE;
  1902. // Frees temporary data structures that can be created for subsurface scattering
  1903. // this data is freed when the PRTComputeEngine is freed and is lazily created
  1904. STDMETHOD(FreeSSData)(THIS) PURE;
  1905. // Frees temporary data structures that can be created for bounce simulations
  1906. // this data is freed when the PRTComputeEngine is freed and is lazily created
  1907. STDMETHOD(FreeBounceData)(THIS) PURE;
  1908. // This computes the Local Deformable PRT (LDPRT) coefficients relative to the
  1909. // per sample normals that minimize error in a least squares sense with respect
  1910. // to the input PRT data set. These coefficients can be used with skinned/transformed
  1911. // normals to model global effects with dynamic objects. Shading normals can
  1912. // optionally be solved for - these normals (along with the LDPRT coefficients) can
  1913. // more accurately represent the PRT signal. The coefficients are for zonal
  1914. // harmonics oriented in the normal/shading normal direction.
  1915. //
  1916. // pDataIn - SH PRT dataset that is input
  1917. // SHOrder - Order of SH to compute conv coefficients for
  1918. // pNormOut - Optional array of vectors (passed in) that will be filled with
  1919. // "shading normals", LDPRT coefficients are optimized for
  1920. // these normals. This array must be the same size as the number of
  1921. // samples in pDataIn
  1922. // pDataOut - Output buffer (SHOrder zonal harmonic coefficients per channel per sample)
  1923. STDMETHOD(ComputeLDPRTCoeffs)(THIS_ LPD3DXPRTBUFFER pDataIn,
  1924. UINT SHOrder,
  1925. D3DXVECTOR3 *pNormOut,
  1926. LPD3DXPRTBUFFER pDataOut) PURE;
  1927. // scales all the samples associated with a given sub mesh
  1928. // can be useful when using subsurface scattering
  1929. // fScale - value to scale each vector in submesh by
  1930. STDMETHOD(ScaleMeshChunk)(THIS_ UINT uMeshChunk, FLOAT fScale, LPD3DXPRTBUFFER pDataOut) PURE;
  1931. // mutliplies each PRT vector by the albedo - can be used if you want to have the albedo
  1932. // burned into the dataset, often better not to do this. If this is not done the user
  1933. // must mutliply the albedo themselves when rendering - just multiply the albedo times
  1934. // the result of the PRT dot product.
  1935. // If pDataOut is a texture simulation result and there is an albedo texture it
  1936. // must be represented at the same resolution as the simulation buffer. You can use
  1937. // LoadSurfaceFromSurface and set a new albedo texture if this is an issue - but must
  1938. // be careful about how the gutters are handled.
  1939. //
  1940. // pDataOut - dataset that will get albedo pushed into it
  1941. STDMETHOD(MultiplyAlbedo)(THIS_ LPD3DXPRTBUFFER pDataOut) PURE;
  1942. // Sets a pointer to an optional call back function that reports back to the
  1943. // user percentage done and gives them the option of quitting
  1944. // pCB - pointer to call back function, return S_OK for the simulation
  1945. // to continue
  1946. // Frequency - 1/Frequency is roughly the number of times the call back
  1947. // will be invoked
  1948. // lpUserContext - will be passed back to the users call back
  1949. STDMETHOD(SetCallBack)(THIS_ LPD3DXSHPRTSIMCB pCB, FLOAT Frequency, LPVOID lpUserContext) PURE;
  1950. // Returns TRUE if the ray intersects the mesh, FALSE if it does not. This function
  1951. // takes into account settings from SetMinMaxIntersection. If the closest intersection
  1952. // is not needed this function is more efficient compared to the ClosestRayIntersection
  1953. // method.
  1954. // pRayPos - origin of ray
  1955. // pRayDir - normalized ray direction (normalization required for SetMinMax to be meaningful)
  1956. STDMETHOD_(BOOL, ShadowRayIntersects)(THIS_ CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir) PURE;
  1957. // Returns TRUE if the ray intersects the mesh, FALSE if it does not. If there is an
  1958. // intersection the closest face that was intersected and its first two barycentric coordinates
  1959. // are returned. This function takes into account settings from SetMinMaxIntersection.
  1960. // This is a slower function compared to ShadowRayIntersects and should only be used where
  1961. // needed. The third vertices barycentric coordinates will be 1 - pU - pV.
  1962. // pRayPos - origin of ray
  1963. // pRayDir - normalized ray direction (normalization required for SetMinMax to be meaningful)
  1964. // pFaceIndex - Closest face that intersects. This index is based on stacking the pBlockerMesh
  1965. // faces before the faces from pMesh
  1966. // pU - Barycentric coordinate for vertex 0
  1967. // pV - Barycentric coordinate for vertex 1
  1968. // pDist - Distance along ray where the intersection occured
  1969. STDMETHOD_(BOOL, ClosestRayIntersects)(THIS_ CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir,
  1970. DWORD *pFaceIndex, FLOAT *pU, FLOAT *pV, FLOAT *pDist) PURE;
  1971. };
  1972. // API functions for creating interfaces
  1973. #ifdef __cplusplus
  1974. extern "C" {
  1975. #endif //__cplusplus
  1976. //============================================================================
  1977. //
  1978. // D3DXCreatePRTBuffer:
  1979. // --------------------
  1980. // Generates a PRT Buffer that can be compressed or filled by a simulator
  1981. // This function should be used to create per-vertex or volume buffers.
  1982. // When buffers are created all values are initialized to zero.
  1983. //
  1984. // Parameters:
  1985. // NumSamples
  1986. // Number of sample locations represented
  1987. // NumCoeffs
  1988. // Number of coefficients per sample location (order^2 for SH)
  1989. // NumChannels
  1990. // Number of color channels to represent (1 or 3)
  1991. // ppBuffer
  1992. // Buffer that will be allocated
  1993. //
  1994. //============================================================================
  1995. HRESULT WINAPI
  1996. D3DXCreatePRTBuffer(
  1997. UINT NumSamples,
  1998. UINT NumCoeffs,
  1999. UINT NumChannels,
  2000. LPD3DXPRTBUFFER* ppBuffer);
  2001. //============================================================================
  2002. //
  2003. // D3DXCreatePRTBufferTex:
  2004. // --------------------
  2005. // Generates a PRT Buffer that can be compressed or filled by a simulator
  2006. // This function should be used to create per-pixel buffers.
  2007. // When buffers are created all values are initialized to zero.
  2008. //
  2009. // Parameters:
  2010. // Width
  2011. // Width of texture
  2012. // Height
  2013. // Height of texture
  2014. // NumCoeffs
  2015. // Number of coefficients per sample location (order^2 for SH)
  2016. // NumChannels
  2017. // Number of color channels to represent (1 or 3)
  2018. // ppBuffer
  2019. // Buffer that will be allocated
  2020. //
  2021. //============================================================================
  2022. HRESULT WINAPI
  2023. D3DXCreatePRTBufferTex(
  2024. UINT Width,
  2025. UINT Height,
  2026. UINT NumCoeffs,
  2027. UINT NumChannels,
  2028. LPD3DXPRTBUFFER* ppBuffer);
  2029. //============================================================================
  2030. //
  2031. // D3DXLoadPRTBufferFromFile:
  2032. // --------------------
  2033. // Loads a PRT buffer that has been saved to disk.
  2034. //
  2035. // Parameters:
  2036. // pFilename
  2037. // Name of the file to load
  2038. // ppBuffer
  2039. // Buffer that will be allocated
  2040. //
  2041. //============================================================================
  2042. HRESULT WINAPI
  2043. D3DXLoadPRTBufferFromFileA(
  2044. LPCSTR pFilename,
  2045. LPD3DXPRTBUFFER* ppBuffer);
  2046. HRESULT WINAPI
  2047. D3DXLoadPRTBufferFromFileW(
  2048. LPCWSTR pFilename,
  2049. LPD3DXPRTBUFFER* ppBuffer);
  2050. #ifdef UNICODE
  2051. #define D3DXLoadPRTBufferFromFile D3DXLoadPRTBufferFromFileW
  2052. #else
  2053. #define D3DXLoadPRTBufferFromFile D3DXLoadPRTBufferFromFileA
  2054. #endif
  2055. //============================================================================
  2056. //
  2057. // D3DXSavePRTBufferToFile:
  2058. // --------------------
  2059. // Saves a PRTBuffer to disk.
  2060. //
  2061. // Parameters:
  2062. // pFilename
  2063. // Name of the file to save
  2064. // pBuffer
  2065. // Buffer that will be saved
  2066. //
  2067. //============================================================================
  2068. HRESULT WINAPI
  2069. D3DXSavePRTBufferToFileA(
  2070. LPCSTR pFileName,
  2071. LPD3DXPRTBUFFER pBuffer);
  2072. HRESULT WINAPI
  2073. D3DXSavePRTBufferToFileW(
  2074. LPCWSTR pFileName,
  2075. LPD3DXPRTBUFFER pBuffer);
  2076. #ifdef UNICODE
  2077. #define D3DXSavePRTBufferToFile D3DXSavePRTBufferToFileW
  2078. #else
  2079. #define D3DXSavePRTBufferToFile D3DXSavePRTBufferToFileA
  2080. #endif
  2081. //============================================================================
  2082. //
  2083. // D3DXLoadPRTCompBufferFromFile:
  2084. // --------------------
  2085. // Loads a PRTComp buffer that has been saved to disk.
  2086. //
  2087. // Parameters:
  2088. // pFilename
  2089. // Name of the file to load
  2090. // ppBuffer
  2091. // Buffer that will be allocated
  2092. //
  2093. //============================================================================
  2094. HRESULT WINAPI
  2095. D3DXLoadPRTCompBufferFromFileA(
  2096. LPCSTR pFilename,
  2097. LPD3DXPRTCOMPBUFFER* ppBuffer);
  2098. HRESULT WINAPI
  2099. D3DXLoadPRTCompBufferFromFileW(
  2100. LPCWSTR pFilename,
  2101. LPD3DXPRTCOMPBUFFER* ppBuffer);
  2102. #ifdef UNICODE
  2103. #define D3DXLoadPRTCompBufferFromFile D3DXLoadPRTCompBufferFromFileW
  2104. #else
  2105. #define D3DXLoadPRTCompBufferFromFile D3DXLoadPRTCompBufferFromFileA
  2106. #endif
  2107. //============================================================================
  2108. //
  2109. // D3DXSavePRTCompBufferToFile:
  2110. // --------------------
  2111. // Saves a PRTCompBuffer to disk.
  2112. //
  2113. // Parameters:
  2114. // pFilename
  2115. // Name of the file to save
  2116. // pBuffer
  2117. // Buffer that will be saved
  2118. //
  2119. //============================================================================
  2120. HRESULT WINAPI
  2121. D3DXSavePRTCompBufferToFileA(
  2122. LPCSTR pFileName,
  2123. LPD3DXPRTCOMPBUFFER pBuffer);
  2124. HRESULT WINAPI
  2125. D3DXSavePRTCompBufferToFileW(
  2126. LPCWSTR pFileName,
  2127. LPD3DXPRTCOMPBUFFER pBuffer);
  2128. #ifdef UNICODE
  2129. #define D3DXSavePRTCompBufferToFile D3DXSavePRTCompBufferToFileW
  2130. #else
  2131. #define D3DXSavePRTCompBufferToFile D3DXSavePRTCompBufferToFileA
  2132. #endif
  2133. //============================================================================
  2134. //
  2135. // D3DXCreatePRTCompBuffer:
  2136. // --------------------
  2137. // Compresses a PRT buffer (vertex or texel)
  2138. //
  2139. // Parameters:
  2140. // D3DXSHCOMPRESSQUALITYTYPE
  2141. // Quality of compression - low is faster (computes PCA per voronoi cluster)
  2142. // high is slower but better quality (clusters based on distance to affine subspace)
  2143. // NumClusters
  2144. // Number of clusters to compute
  2145. // NumPCA
  2146. // Number of basis vectors to compute
  2147. // pCB
  2148. // Optional Callback function
  2149. // lpUserContext
  2150. // Optional user context
  2151. // pBufferIn
  2152. // Buffer that will be compressed
  2153. // ppBufferOut
  2154. // Compressed buffer that will be created
  2155. //
  2156. //============================================================================
  2157. HRESULT WINAPI
  2158. D3DXCreatePRTCompBuffer(
  2159. D3DXSHCOMPRESSQUALITYTYPE Quality,
  2160. UINT NumClusters,
  2161. UINT NumPCA,
  2162. LPD3DXSHPRTSIMCB pCB,
  2163. LPVOID lpUserContext,
  2164. LPD3DXPRTBUFFER pBufferIn,
  2165. LPD3DXPRTCOMPBUFFER *ppBufferOut
  2166. );
  2167. //============================================================================
  2168. //
  2169. // D3DXCreateTextureGutterHelper:
  2170. // --------------------
  2171. // Generates a "GutterHelper" for a given set of meshes and texture
  2172. // resolution
  2173. //
  2174. // Parameters:
  2175. // Width
  2176. // Width of texture
  2177. // Height
  2178. // Height of texture
  2179. // pMesh
  2180. // Mesh that represents the scene
  2181. // GutterSize
  2182. // Number of texels to over rasterize in texture space
  2183. // this should be at least 1.0
  2184. // ppBuffer
  2185. // GutterHelper that will be created
  2186. //
  2187. //============================================================================
  2188. HRESULT WINAPI
  2189. D3DXCreateTextureGutterHelper(
  2190. UINT Width,
  2191. UINT Height,
  2192. LPD3DXMESH pMesh,
  2193. FLOAT GutterSize,
  2194. LPD3DXTEXTUREGUTTERHELPER* ppBuffer);
  2195. //============================================================================
  2196. //
  2197. // D3DXCreatePRTEngine:
  2198. // --------------------
  2199. // Computes a PRTEngine which can efficiently generate PRT simulations
  2200. // of a scene
  2201. //
  2202. // Parameters:
  2203. // pMesh
  2204. // Mesh that represents the scene - must have an AttributeTable
  2205. // where vertices are in a unique attribute.
  2206. // pAdjacency
  2207. // Optional adjacency information
  2208. // ExtractUVs
  2209. // Set this to true if textures are going to be used for albedos
  2210. // or to store PRT vectors
  2211. // pBlockerMesh
  2212. // Optional mesh that just blocks the scene
  2213. // ppEngine
  2214. // PRTEngine that will be created
  2215. //
  2216. //============================================================================
  2217. HRESULT WINAPI
  2218. D3DXCreatePRTEngine(
  2219. LPD3DXMESH pMesh,
  2220. DWORD *pAdjacency,
  2221. BOOL ExtractUVs,
  2222. LPD3DXMESH pBlockerMesh,
  2223. LPD3DXPRTENGINE* ppEngine);
  2224. //============================================================================
  2225. //
  2226. // D3DXConcatenateMeshes:
  2227. // --------------------
  2228. // Concatenates a group of meshes into one common mesh. This can optionaly transform
  2229. // each sub mesh or its texture coordinates. If no DECL is given it will
  2230. // generate a union of all of the DECL's of the sub meshes, promoting channels
  2231. // and types if neccesary. It will create an AttributeTable if possible, one can
  2232. // call OptimizeMesh with attribute sort and compacting enabled to ensure this.
  2233. //
  2234. // Parameters:
  2235. // ppMeshes
  2236. // Array of pointers to meshes that can store PRT vectors
  2237. // NumMeshes
  2238. // Number of meshes
  2239. // Options
  2240. // Passed through to D3DXCreateMesh
  2241. // pGeomXForms
  2242. // [optional] Each sub mesh is transformed by the corresponding
  2243. // matrix if this array is supplied
  2244. // pTextureXForms
  2245. // [optional] UV coordinates for each sub mesh are transformed
  2246. // by corresponding matrix if supplied
  2247. // pDecl
  2248. // [optional] Only information in this DECL is used when merging
  2249. // data
  2250. // pD3DDevice
  2251. // D3D device that is used to create the new mesh
  2252. // ppMeshOut
  2253. // Mesh that will be created
  2254. //
  2255. //============================================================================
  2256. HRESULT WINAPI
  2257. D3DXConcatenateMeshes(
  2258. LPD3DXMESH *ppMeshes,
  2259. UINT NumMeshes,
  2260. DWORD Options,
  2261. CONST D3DXMATRIX *pGeomXForms,
  2262. CONST D3DXMATRIX *pTextureXForms,
  2263. CONST D3DVERTEXELEMENT9 *pDecl,
  2264. LPDIRECT3DDEVICE9 pD3DDevice,
  2265. LPD3DXMESH *ppMeshOut);
  2266. //============================================================================
  2267. //
  2268. // D3DXSHPRTCompSuperCluster:
  2269. // --------------------------
  2270. // Used with compressed results of D3DXSHPRTSimulation.
  2271. // Generates "super clusters" - groups of clusters that can be drawn in
  2272. // the same draw call. A greedy algorithm that minimizes overdraw is used
  2273. // to group the clusters.
  2274. //
  2275. // Parameters:
  2276. // pClusterIDs
  2277. // NumVerts cluster ID's (extracted from a compressed buffer)
  2278. // pScene
  2279. // Mesh that represents composite scene passed to the simulator
  2280. // MaxNumClusters
  2281. // Maximum number of clusters allocated per super cluster
  2282. // NumClusters
  2283. // Number of clusters computed in the simulator
  2284. // pSuperClusterIDs
  2285. // Array of length NumClusters, contains index of super cluster
  2286. // that corresponding cluster was assigned to
  2287. // pNumSuperClusters
  2288. // Returns the number of super clusters allocated
  2289. //
  2290. //============================================================================
  2291. HRESULT WINAPI
  2292. D3DXSHPRTCompSuperCluster(
  2293. UINT *pClusterIDs,
  2294. LPD3DXMESH pScene,
  2295. UINT MaxNumClusters,
  2296. UINT NumClusters,
  2297. UINT *pSuperClusterIDs,
  2298. UINT *pNumSuperClusters);
  2299. //============================================================================
  2300. //
  2301. // D3DXSHPRTCompSplitMeshSC:
  2302. // -------------------------
  2303. // Used with compressed results of the vertex version of the PRT simulator.
  2304. // After D3DXSHRTCompSuperCluster has been called this function can be used
  2305. // to split the mesh into a group of faces/vertices per super cluster.
  2306. // Each super cluster contains all of the faces that contain any vertex
  2307. // classified in one of its clusters. All of the vertices connected to this
  2308. // set of faces are also included with the returned array ppVertStatus
  2309. // indicating whether or not the vertex belongs to the supercluster.
  2310. //
  2311. // Parameters:
  2312. // pClusterIDs
  2313. // NumVerts cluster ID's (extracted from a compressed buffer)
  2314. // NumVertices
  2315. // Number of vertices in original mesh
  2316. // NumClusters
  2317. // Number of clusters (input parameter to compression)
  2318. // pSuperClusterIDs
  2319. // Array of size NumClusters that will contain super cluster ID's (from
  2320. // D3DXSHCompSuerCluster)
  2321. // NumSuperClusters
  2322. // Number of superclusters allocated in D3DXSHCompSuerCluster
  2323. // pInputIB
  2324. // Raw index buffer for mesh - format depends on bInputIBIs32Bit
  2325. // InputIBIs32Bit
  2326. // Indicates whether the input index buffer is 32-bit (otherwise 16-bit
  2327. // is assumed)
  2328. // NumFaces
  2329. // Number of faces in the original mesh (pInputIB is 3 times this length)
  2330. // ppIBData
  2331. // LPD3DXBUFFER holds raw index buffer that will contain the resulting split faces.
  2332. // Format determined by bIBIs32Bit. Allocated by function
  2333. // pIBDataLength
  2334. // Length of ppIBData, assigned in function
  2335. // OutputIBIs32Bit
  2336. // Indicates whether the output index buffer is to be 32-bit (otherwise
  2337. // 16-bit is assumed)
  2338. // ppFaceRemap
  2339. // LPD3DXBUFFER mapping of each face in ppIBData to original faces. Length is
  2340. // *pIBDataLength/3. Optional paramter, allocated in function
  2341. // ppVertData
  2342. // LPD3DXBUFFER contains new vertex data structure. Size of pVertDataLength
  2343. // pVertDataLength
  2344. // Number of new vertices in split mesh. Assigned in function
  2345. // pSCClusterList
  2346. // Array of length NumClusters which pSCData indexes into (Cluster* fields)
  2347. // for each SC, contains clusters sorted by super cluster
  2348. // pSCData
  2349. // Structure per super cluster - contains indices into ppIBData,
  2350. // pSCClusterList and ppVertData
  2351. //
  2352. //============================================================================
  2353. HRESULT WINAPI
  2354. D3DXSHPRTCompSplitMeshSC(
  2355. UINT *pClusterIDs,
  2356. UINT NumVertices,
  2357. UINT NumClusters,
  2358. UINT *pSuperClusterIDs,
  2359. UINT NumSuperClusters,
  2360. LPVOID pInputIB,
  2361. BOOL InputIBIs32Bit,
  2362. UINT NumFaces,
  2363. LPD3DXBUFFER *ppIBData,
  2364. UINT *pIBDataLength,
  2365. BOOL OutputIBIs32Bit,
  2366. LPD3DXBUFFER *ppFaceRemap,
  2367. LPD3DXBUFFER *ppVertData,
  2368. UINT *pVertDataLength,
  2369. UINT *pSCClusterList,
  2370. D3DXSHPRTSPLITMESHCLUSTERDATA *pSCData);
  2371. #ifdef __cplusplus
  2372. }
  2373. #endif //__cplusplus
  2374. //////////////////////////////////////////////////////////////////////////////
  2375. //
  2376. // Definitions of .X file templates used by mesh load/save functions
  2377. // that are not RM standard
  2378. //
  2379. //////////////////////////////////////////////////////////////////////////////
  2380. // {3CF169CE-FF7C-44ab-93C0-F78F62D172E2}
  2381. DEFINE_GUID(DXFILEOBJ_XSkinMeshHeader,
  2382. 0x3cf169ce, 0xff7c, 0x44ab, 0x93, 0xc0, 0xf7, 0x8f, 0x62, 0xd1, 0x72, 0xe2);
  2383. // {B8D65549-D7C9-4995-89CF-53A9A8B031E3}
  2384. DEFINE_GUID(DXFILEOBJ_VertexDuplicationIndices,
  2385. 0xb8d65549, 0xd7c9, 0x4995, 0x89, 0xcf, 0x53, 0xa9, 0xa8, 0xb0, 0x31, 0xe3);
  2386. // {A64C844A-E282-4756-8B80-250CDE04398C}
  2387. DEFINE_GUID(DXFILEOBJ_FaceAdjacency,
  2388. 0xa64c844a, 0xe282, 0x4756, 0x8b, 0x80, 0x25, 0xc, 0xde, 0x4, 0x39, 0x8c);
  2389. // {6F0D123B-BAD2-4167-A0D0-80224F25FABB}
  2390. DEFINE_GUID(DXFILEOBJ_SkinWeights,
  2391. 0x6f0d123b, 0xbad2, 0x4167, 0xa0, 0xd0, 0x80, 0x22, 0x4f, 0x25, 0xfa, 0xbb);
  2392. // {A3EB5D44-FC22-429d-9AFB-3221CB9719A6}
  2393. DEFINE_GUID(DXFILEOBJ_Patch,
  2394. 0xa3eb5d44, 0xfc22, 0x429d, 0x9a, 0xfb, 0x32, 0x21, 0xcb, 0x97, 0x19, 0xa6);
  2395. // {D02C95CC-EDBA-4305-9B5D-1820D7704BBF}
  2396. DEFINE_GUID(DXFILEOBJ_PatchMesh,
  2397. 0xd02c95cc, 0xedba, 0x4305, 0x9b, 0x5d, 0x18, 0x20, 0xd7, 0x70, 0x4b, 0xbf);
  2398. // {B9EC94E1-B9A6-4251-BA18-94893F02C0EA}
  2399. DEFINE_GUID(DXFILEOBJ_PatchMesh9,
  2400. 0xb9ec94e1, 0xb9a6, 0x4251, 0xba, 0x18, 0x94, 0x89, 0x3f, 0x2, 0xc0, 0xea);
  2401. // {B6C3E656-EC8B-4b92-9B62-681659522947}
  2402. DEFINE_GUID(DXFILEOBJ_PMInfo,
  2403. 0xb6c3e656, 0xec8b, 0x4b92, 0x9b, 0x62, 0x68, 0x16, 0x59, 0x52, 0x29, 0x47);
  2404. // {917E0427-C61E-4a14-9C64-AFE65F9E9844}
  2405. DEFINE_GUID(DXFILEOBJ_PMAttributeRange,
  2406. 0x917e0427, 0xc61e, 0x4a14, 0x9c, 0x64, 0xaf, 0xe6, 0x5f, 0x9e, 0x98, 0x44);
  2407. // {574CCC14-F0B3-4333-822D-93E8A8A08E4C}
  2408. DEFINE_GUID(DXFILEOBJ_PMVSplitRecord,
  2409. 0x574ccc14, 0xf0b3, 0x4333, 0x82, 0x2d, 0x93, 0xe8, 0xa8, 0xa0, 0x8e, 0x4c);
  2410. // {B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897}
  2411. DEFINE_GUID(DXFILEOBJ_FVFData,
  2412. 0xb6e70a0e, 0x8ef9, 0x4e83, 0x94, 0xad, 0xec, 0xc8, 0xb0, 0xc0, 0x48, 0x97);
  2413. // {F752461C-1E23-48f6-B9F8-8350850F336F}
  2414. DEFINE_GUID(DXFILEOBJ_VertexElement,
  2415. 0xf752461c, 0x1e23, 0x48f6, 0xb9, 0xf8, 0x83, 0x50, 0x85, 0xf, 0x33, 0x6f);
  2416. // {BF22E553-292C-4781-9FEA-62BD554BDD93}
  2417. DEFINE_GUID(DXFILEOBJ_DeclData,
  2418. 0xbf22e553, 0x292c, 0x4781, 0x9f, 0xea, 0x62, 0xbd, 0x55, 0x4b, 0xdd, 0x93);
  2419. // {F1CFE2B3-0DE3-4e28-AFA1-155A750A282D}
  2420. DEFINE_GUID(DXFILEOBJ_EffectFloats,
  2421. 0xf1cfe2b3, 0xde3, 0x4e28, 0xaf, 0xa1, 0x15, 0x5a, 0x75, 0xa, 0x28, 0x2d);
  2422. // {D55B097E-BDB6-4c52-B03D-6051C89D0E42}
  2423. DEFINE_GUID(DXFILEOBJ_EffectString,
  2424. 0xd55b097e, 0xbdb6, 0x4c52, 0xb0, 0x3d, 0x60, 0x51, 0xc8, 0x9d, 0xe, 0x42);
  2425. // {622C0ED0-956E-4da9-908A-2AF94F3CE716}
  2426. DEFINE_GUID(DXFILEOBJ_EffectDWord,
  2427. 0x622c0ed0, 0x956e, 0x4da9, 0x90, 0x8a, 0x2a, 0xf9, 0x4f, 0x3c, 0xe7, 0x16);
  2428. // {3014B9A0-62F5-478c-9B86-E4AC9F4E418B}
  2429. DEFINE_GUID(DXFILEOBJ_EffectParamFloats,
  2430. 0x3014b9a0, 0x62f5, 0x478c, 0x9b, 0x86, 0xe4, 0xac, 0x9f, 0x4e, 0x41, 0x8b);
  2431. // {1DBC4C88-94C1-46ee-9076-2C28818C9481}
  2432. DEFINE_GUID(DXFILEOBJ_EffectParamString,
  2433. 0x1dbc4c88, 0x94c1, 0x46ee, 0x90, 0x76, 0x2c, 0x28, 0x81, 0x8c, 0x94, 0x81);
  2434. // {E13963BC-AE51-4c5d-B00F-CFA3A9D97CE5}
  2435. DEFINE_GUID(DXFILEOBJ_EffectParamDWord,
  2436. 0xe13963bc, 0xae51, 0x4c5d, 0xb0, 0xf, 0xcf, 0xa3, 0xa9, 0xd9, 0x7c, 0xe5);
  2437. // {E331F7E4-0559-4cc2-8E99-1CEC1657928F}
  2438. DEFINE_GUID(DXFILEOBJ_EffectInstance,
  2439. 0xe331f7e4, 0x559, 0x4cc2, 0x8e, 0x99, 0x1c, 0xec, 0x16, 0x57, 0x92, 0x8f);
  2440. // {9E415A43-7BA6-4a73-8743-B73D47E88476}
  2441. DEFINE_GUID(DXFILEOBJ_AnimTicksPerSecond,
  2442. 0x9e415a43, 0x7ba6, 0x4a73, 0x87, 0x43, 0xb7, 0x3d, 0x47, 0xe8, 0x84, 0x76);
  2443. // {7F9B00B3-F125-4890-876E-1CFFBF697C4D}
  2444. DEFINE_GUID(DXFILEOBJ_CompressedAnimationSet,
  2445. 0x7f9b00b3, 0xf125, 0x4890, 0x87, 0x6e, 0x1c, 0x42, 0xbf, 0x69, 0x7c, 0x4d);
  2446. #pragma pack(push, 1)
  2447. typedef struct _XFILECOMPRESSEDANIMATIONSET
  2448. {
  2449. DWORD CompressedBlockSize;
  2450. FLOAT TicksPerSec;
  2451. DWORD PlaybackType;
  2452. DWORD BufferLength;
  2453. } XFILECOMPRESSEDANIMATIONSET;
  2454. #pragma pack(pop)
  2455. #define XSKINEXP_TEMPLATES \
  2456. "xof 0303txt 0032\
  2457. template XSkinMeshHeader \
  2458. { \
  2459. <3CF169CE-FF7C-44ab-93C0-F78F62D172E2> \
  2460. WORD nMaxSkinWeightsPerVertex; \
  2461. WORD nMaxSkinWeightsPerFace; \
  2462. WORD nBones; \
  2463. } \
  2464. template VertexDuplicationIndices \
  2465. { \
  2466. <B8D65549-D7C9-4995-89CF-53A9A8B031E3> \
  2467. DWORD nIndices; \
  2468. DWORD nOriginalVertices; \
  2469. array DWORD indices[nIndices]; \
  2470. } \
  2471. template FaceAdjacency \
  2472. { \
  2473. <A64C844A-E282-4756-8B80-250CDE04398C> \
  2474. DWORD nIndices; \
  2475. array DWORD indices[nIndices]; \
  2476. } \
  2477. template SkinWeights \
  2478. { \
  2479. <6F0D123B-BAD2-4167-A0D0-80224F25FABB> \
  2480. STRING transformNodeName; \
  2481. DWORD nWeights; \
  2482. array DWORD vertexIndices[nWeights]; \
  2483. array float weights[nWeights]; \
  2484. Matrix4x4 matrixOffset; \
  2485. } \
  2486. template Patch \
  2487. { \
  2488. <A3EB5D44-FC22-429D-9AFB-3221CB9719A6> \
  2489. DWORD nControlIndices; \
  2490. array DWORD controlIndices[nControlIndices]; \
  2491. } \
  2492. template PatchMesh \
  2493. { \
  2494. <D02C95CC-EDBA-4305-9B5D-1820D7704BBF> \
  2495. DWORD nVertices; \
  2496. array Vector vertices[nVertices]; \
  2497. DWORD nPatches; \
  2498. array Patch patches[nPatches]; \
  2499. [ ... ] \
  2500. } \
  2501. template PatchMesh9 \
  2502. { \
  2503. <B9EC94E1-B9A6-4251-BA18-94893F02C0EA> \
  2504. DWORD Type; \
  2505. DWORD Degree; \
  2506. DWORD Basis; \
  2507. DWORD nVertices; \
  2508. array Vector vertices[nVertices]; \
  2509. DWORD nPatches; \
  2510. array Patch patches[nPatches]; \
  2511. [ ... ] \
  2512. } " \
  2513. "template EffectFloats \
  2514. { \
  2515. <F1CFE2B3-0DE3-4e28-AFA1-155A750A282D> \
  2516. DWORD nFloats; \
  2517. array float Floats[nFloats]; \
  2518. } \
  2519. template EffectString \
  2520. { \
  2521. <D55B097E-BDB6-4c52-B03D-6051C89D0E42> \
  2522. STRING Value; \
  2523. } \
  2524. template EffectDWord \
  2525. { \
  2526. <622C0ED0-956E-4da9-908A-2AF94F3CE716> \
  2527. DWORD Value; \
  2528. } " \
  2529. "template EffectParamFloats \
  2530. { \
  2531. <3014B9A0-62F5-478c-9B86-E4AC9F4E418B> \
  2532. STRING ParamName; \
  2533. DWORD nFloats; \
  2534. array float Floats[nFloats]; \
  2535. } " \
  2536. "template EffectParamString \
  2537. { \
  2538. <1DBC4C88-94C1-46ee-9076-2C28818C9481> \
  2539. STRING ParamName; \
  2540. STRING Value; \
  2541. } \
  2542. template EffectParamDWord \
  2543. { \
  2544. <E13963BC-AE51-4c5d-B00F-CFA3A9D97CE5> \
  2545. STRING ParamName; \
  2546. DWORD Value; \
  2547. } \
  2548. template EffectInstance \
  2549. { \
  2550. <E331F7E4-0559-4cc2-8E99-1CEC1657928F> \
  2551. STRING EffectFilename; \
  2552. [ ... ] \
  2553. } " \
  2554. "template AnimTicksPerSecond \
  2555. { \
  2556. <9E415A43-7BA6-4a73-8743-B73D47E88476> \
  2557. DWORD AnimTicksPerSecond; \
  2558. } \
  2559. template CompressedAnimationSet \
  2560. { \
  2561. <7F9B00B3-F125-4890-876E-1C42BF697C4D> \
  2562. DWORD CompressedBlockSize; \
  2563. FLOAT TicksPerSec; \
  2564. DWORD PlaybackType; \
  2565. DWORD BufferLength; \
  2566. array DWORD CompressedData[BufferLength]; \
  2567. } "
  2568. #define XEXTENSIONS_TEMPLATES \
  2569. "xof 0303txt 0032\
  2570. template FVFData \
  2571. { \
  2572. <B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897> \
  2573. DWORD dwFVF; \
  2574. DWORD nDWords; \
  2575. array DWORD data[nDWords]; \
  2576. } \
  2577. template VertexElement \
  2578. { \
  2579. <F752461C-1E23-48f6-B9F8-8350850F336F> \
  2580. DWORD Type; \
  2581. DWORD Method; \
  2582. DWORD Usage; \
  2583. DWORD UsageIndex; \
  2584. } \
  2585. template DeclData \
  2586. { \
  2587. <BF22E553-292C-4781-9FEA-62BD554BDD93> \
  2588. DWORD nElements; \
  2589. array VertexElement Elements[nElements]; \
  2590. DWORD nDWords; \
  2591. array DWORD data[nDWords]; \
  2592. } \
  2593. template PMAttributeRange \
  2594. { \
  2595. <917E0427-C61E-4a14-9C64-AFE65F9E9844> \
  2596. DWORD iFaceOffset; \
  2597. DWORD nFacesMin; \
  2598. DWORD nFacesMax; \
  2599. DWORD iVertexOffset; \
  2600. DWORD nVerticesMin; \
  2601. DWORD nVerticesMax; \
  2602. } \
  2603. template PMVSplitRecord \
  2604. { \
  2605. <574CCC14-F0B3-4333-822D-93E8A8A08E4C> \
  2606. DWORD iFaceCLW; \
  2607. DWORD iVlrOffset; \
  2608. DWORD iCode; \
  2609. } \
  2610. template PMInfo \
  2611. { \
  2612. <B6C3E656-EC8B-4b92-9B62-681659522947> \
  2613. DWORD nAttributes; \
  2614. array PMAttributeRange attributeRanges[nAttributes]; \
  2615. DWORD nMaxValence; \
  2616. DWORD nMinLogicalVertices; \
  2617. DWORD nMaxLogicalVertices; \
  2618. DWORD nVSplits; \
  2619. array PMVSplitRecord splitRecords[nVSplits]; \
  2620. DWORD nAttributeMispredicts; \
  2621. array DWORD attributeMispredicts[nAttributeMispredicts]; \
  2622. } "
  2623. #endif //__D3DX9MESH_H__