PageRenderTime 56ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/common/dx9/include/d3dx9mesh.h

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