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