' ########################################################################################
' Microsoft Windows
' File: d3dx9mesh.inc
' Contents: D3DX mesh types and functions
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_d3dx9mesh_PBI)
#DEFINE PBX_d3dx9mesh_PBI
%EQUATE `D3DX9MESH_INC = 1
#INCLUDE ONCE "Legacy/Graphics/d3dx9.inc"
$IID_ID3DXBaseMesh = GUID$("{7ED943DD-52E8-40b5-A8D8-76685C406330}")
$IID_ID3DXMesh = GUID$("{4020E5C2-1403-4929-883F-E2E849FAC195}")
$IID_ID3DXPMesh = GUID$("{8875769A-D579-4088-AAEB-534D1AD84E96}")
$IID_ID3DXSPMesh = GUID$("{667EA4C7-F1CD-4386-B523-7C0290B83CC5}")
$IID_ID3DXSkinInfo = GUID$("{11EAA540-F9A6-4d49-AE6A-E19221F70CC4}")
$IID_ID3DXPatchMesh = GUID$("{3CE6CC22-DBF2-44f4-894D-F9C34A337139}")
'// patch mesh can be quads or tris
'enum D3DXPATCHMESHTYPE
%EQUATE `D3DXPATCHMESH_RECT = &H001
%EQUATE `D3DXPATCHMESH_TRI = &H002
%EQUATE `D3DXPATCHMESH_NPATCH = &H003
%EQUATE `D3DXPATCHMESH_FORCE_DWORD = &H7FFFFFFF ' /* force 32-bit size enum */
'// Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags
' enum D3DXMESH
%EQUATE `D3DXMESH_32BIT = &H001 ' // If set, then use 32 bit indices, if not set use 16 bit indices.
%EQUATE `D3DXMESH_DONOTCLIP = &H002 ' // Use D3DUSAGE_DONOTCLIP for VB & IB.
%EQUATE `D3DXMESH_POINTS = &H004 ' // Use D3DUSAGE_POINTS for VB & IB.
%EQUATE `D3DXMESH_RTPATCHES = &H008 ' // Use D3DUSAGE_RTPATCHES for VB & IB.
%EQUATE `D3DXMESH_NPATCHES = &H4000 ' // Use D3DUSAGE_NPATCHES for VB & IB.
%EQUATE `D3DXMESH_VB_SYSTEMMEM = &H010 ' // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER
%EQUATE `D3DXMESH_VB_MANAGED = &H020 ' // Use D3DPOOL_MANAGED for VB.
%EQUATE `D3DXMESH_VB_WRITEONLY = &H040 ' // Use D3DUSAGE_WRITEONLY for VB.
%EQUATE `D3DXMESH_VB_DYNAMIC = &H080 ' // Use D3DUSAGE_DYNAMIC for VB.
%EQUATE `D3DXMESH_VB_SOFTWAREPROCESSING = &H8000 ' // Use D3DUSAGE_SOFTWAREPROCESSING for VB.
%EQUATE `D3DXMESH_IB_SYSTEMMEM = &H100 ' // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER
%EQUATE `D3DXMESH_IB_MANAGED = &H200 ' // Use D3DPOOL_MANAGED for IB.
%EQUATE `D3DXMESH_IB_WRITEONLY = &H400 ' // Use D3DUSAGE_WRITEONLY for IB.
%EQUATE `D3DXMESH_IB_DYNAMIC = &H800 ' // Use D3DUSAGE_DYNAMIC for IB.
%EQUATE `D3DXMESH_IB_SOFTWAREPROCESSING = &H10000 ' // Use D3DUSAGE_SOFTWAREPROCESSING for IB.
%EQUATE `D3DXMESH_VB_SHARE = &H1000 ' // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer
%EQUATE `D3DXMESH_USEHWONLY = &H2000 ' // Valid for ID3DXSkinInfo::ConvertToBlendedMesh
' // Helper options
%EQUATE `D3DXMESH_SYSTEMMEM = &H110 ' // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM
%EQUATE `D3DXMESH_MANAGED = &H220 ' // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED
%EQUATE `D3DXMESH_WRITEONLY = &H440 ' // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY
%EQUATE `D3DXMESH_DYNAMIC = &H880 ' // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC
%EQUATE `D3DXMESH_SOFTWAREPROCESSING = &H18000 ' // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING
'//patch mesh options
'enum D3DXPATCHMESH {
%EQUATE `D3DXPATCHMESH_DEFAULT = 0
'// option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh
'enum D3DXMESHSIMP
%EQUATE `D3DXMESHSIMP_VERTEX = &H1
%EQUATE `D3DXMESHSIMP_FACE = &H2
'enum D3DXCLEANTYPE {
%EQUATE `D3DXCLEAN_BACKFACING = &H00000001
%EQUATE `D3DXCLEAN_BOWTIES = &H00000002
 '// Helper options
%EQUATE `D3DXCLEAN_SKINNING = %D3DXCLEAN_BACKFACING ' // Bowtie cleaning modifies geometry and breaks skinning
%EQUATE `D3DXCLEAN_OPTIMIZATION = %D3DXCLEAN_BACKFACING
%EQUATE `D3DXCLEAN_SIMPLIFICATION = %D3DXCLEAN_BACKFACING OR %D3DXCLEAN_BOWTIES
'enum MAX_FVF_DECL_SIZE
%EQUATE `MAX_FVF_DECL_SIZE = %MAXD3DDECLLENGTH + 1 ' // +1 for END
' // Size = 20 bytes
TYPE D3DXATTRIBUTERANGE DWORD
 AttribId AS DWORD
 FaceStart AS DWORD
 FaceCount AS DWORD
 VertexStart AS DWORD
 VertexCount AS DWORD
END TYPE
' // Size = 272 bytes
TYPE D3DXMATERIAL DWORD
 MatD3D AS D3DMATERIAL9 ' D3DMATERIAL9
 pTextureFilename AS ASCIIZ PTR
END TYPE
'enum D3DXEFFECTDEFAULTTYPE
%EQUATE `D3DXEDT_STRING = &H1 ' // pValue points to a null terminated ASCII string
%EQUATE `D3DXEDT_FLOATS = &H2 ' // pValue points to an array of floats - number of floats is NumBytes / sizeof(float)
%EQUATE `D3DXEDT_DWORD = &H3 ' // pValue points to a DWORD
%EQUATE `D3DXEDT_FORCEDWORD = &H7FFFFFFF
' // Size = 16 bytes
TYPE D3DXEFFECTDEFAULT DWORD
 pParamName AS ASCIIZ PTR
 Type AS DWORD ' D3DXEFFECTDEFAULTTYPE // type of the data pointed to by pValue
 NumBytes AS DWORD ' DWORD // size in bytes of the data pointed to by pValue
 pValue AS DWORD ' LPVOID // data for the default of the effect
END TYPE
' // Size = 12 bytes
TYPE D3DXEFFECTINSTANCE DWORD
 pEffectFilename AS ASCIIZ PTR
 NumDefaults AS DWORD
 pDefaults AS DWORD ' LPD3DXEFFECTDEFAULT
END TYPE
' // Size = 60 bytes
TYPE D3DXATTRIBUTEWEIGHTS DWORD
 Position AS SINGLE ' FLOAT
 Boundary AS SINGLE ' FLOAT
 Normal AS SINGLE ' FLOAT
 Diffuse AS SINGLE ' FLOAT
 Specular AS SINGLE ' FLOAT
 Texcoord(7) AS SINGLE ' FLOAT[8]
 Tangent AS SINGLE ' FLOAT
 Binormal AS SINGLE ' FLOAT
END TYPE
'enum _D3DXWELDEPSILONSFLAGS
%EQUATE `D3DXWELDEPSILONS_WELDALL = &H1 ' // weld all vertices marked by adjacency as being overlapping
%EQUATE `D3DXWELDEPSILONS_WELDPARTIALMATCHES = &H2 ' // if a given vertex component is within epsilon, modify partial matched
 ' // vertices so that both components identical AND if all components "equal"
 ' // remove one of the vertices
%EQUATE `D3DXWELDEPSILONS_DONOTREMOVEVERTICES = &H4 ' // instructs weld to only allow modifications to vertices and not removal
 ' // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set
 ' // useful to modify vertices to be equal, but not allow vertices to be removed
%EQUATE `D3DXWELDEPSILONS_DONOTSPLIT = &H8 ' // instructs weld to specify the D3DXMESHOPT_DONOTSPLIT flag when doing an Optimize(ATTR_SORT)
 ' // if this flag is not set, all vertices that are in separate attribute groups
 ' // will remain split and not welded. Setting this flag can slow down software vertex processing
' // Size = 68 bytes
TYPE D3DXWELDEPSILONS DWORD
 Position AS SINGLE ' FLOAT // NOTE: This does NOT replace the epsilon in GenerateAdjacency
 ' // in general, it should be the same value or greater than the one passed to GeneratedAdjacency
 BlendWeights AS SINGLE ' FLOAT
 Normal AS SINGLE ' FLOAT
 PSize AS SINGLE ' FLOAT
 Specular AS SINGLE ' FLOAT
 Diffuse AS SINGLE ' FLOAT
 Texcoord(7) AS SINGLE ' FLOAT[8]
 Tangent AS SINGLE ' FLOAT
 Binormal AS SINGLE ' FLOAT
 TessFactor AS SINGLE ' FLOAT
END TYPE
'//////////////////////////////////////////////////////////////////////////////
'// ID3DXBaseMesh /////////////////////////////////////////////////////////////
'//////////////////////////////////////////////////////////////////////////////
INTERFACE ID3DXBaseMesh $IID_ID3DXBaseMesh
 INHERIT IUnknown
 ' =====================================================================================
 METHOD DrawSubset ( ' VTable offset = 12
 BYVAL AttribId AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetNumFaces ( ' VTable offset = 16
 ) AS DWORD
 ' =====================================================================================
 METHOD GetNumVertices ( ' VTable offset = 20
 ) AS DWORD
 ' =====================================================================================
 METHOD GetFVF ( ' VTable offset = 24
 ) AS DWORD
 ' =====================================================================================
 METHOD GetDeclaration ( ' VTable offset = 28
 BYREF Declaration AS D3DVERTEXELEMENT9
 ) AS LONG
 ' =====================================================================================
 METHOD GetNumBytesPerVertex ( ' VTable offset = 32
 ) AS DWORD
 ' =====================================================================================
 METHOD GetOptions ( ' VTable offset = 36
 ) AS DWORD
 ' =====================================================================================
 METHOD GetDevice ( ' VTable offset = 40
 BYREF ppDevice AS IDirect3DDevice9
 ) AS LONG
 ' =====================================================================================
 METHOD CloneMeshFVF ( ' VTable offset = 44
 BYVAL Options AS DWORD
 , BYVAL FVF AS DWORD
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppCloneMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD CloneMesh ( ' VTable offset = 48
 BYVAL Options AS DWORD
 , BYREF pDeclaration AS D3DVERTEXELEMENT9
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppCloneMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD GetVertexBuffer ( ' VTable offset = 52
 BYREF ppVB AS IDirect3DVertexBuffer9
 ) AS LONG
 ' =====================================================================================
 METHOD GetIndexBuffer ( ' VTable offset = 56
 BYREF ppIB AS IDirect3DIndexBuffer9
 ) AS LONG
 ' =====================================================================================
 METHOD LockVertexBuffer ( ' VTable offset = 60
 BYVAL Flags AS DWORD
 , BYREF ppData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnlockVertexBuffer ( ' VTable offset = 64
 ) AS LONG
 ' =====================================================================================
 METHOD LockIndexBuffer ( ' VTable offset = 68
 BYVAL Flags AS DWORD
 , BYREF ppData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnlockIndexBuffer ( ' VTable offset = 72
 ) AS LONG
 ' =====================================================================================
 METHOD GetAttributeTable ( ' VTable offset = 76
 BYREF pAttribTable AS D3DXATTRIBUTERANGE
 , BYREF pAttribTableSize AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD ConvertPointRepsToAdjacency ( ' VTable offset = 80
 BYREF pPRep AS DWORD
 , BYREF pAdjacency AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD ConvertAdjacencyToPointReps ( ' VTable offset = 84
 BYREF pAdjacency AS DWORD
 , BYREF pPRep AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GenerateAdjacency ( ' VTable offset = 88
 BYVAL Epsilon AS SINGLE
 , BYREF pAdjacency AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UpdateSemantics ( ' VTable offset = 92
 BYREF Declaration AS D3DVERTEXELEMENT9
 ) AS LONG
 ' =====================================================================================
END INTERFACE
'//////////////////////////////////////////////////////////////////////////////
'// ID3DXMesh /////////////////////////////////////////////////////////////////
'//////////////////////////////////////////////////////////////////////////////
INTERFACE ID3DXMesh $IID_ID3DXMesh
 INHERIT IUnknown
 ' =====================================================================================
 ' ID3DXBaseMesh methods
 ' =====================================================================================
 METHOD DrawSubset ( ' VTable offset = 12
 BYVAL AttribId AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetNumFaces ( ' VTable offset = 16
 ) AS DWORD
 ' =====================================================================================
 METHOD GetNumVertices ( ' VTable offset = 20
 ) AS DWORD
 ' =====================================================================================
 METHOD GetFVF ( ' VTable offset = 24
 ) AS DWORD
 ' =====================================================================================
 METHOD GetDeclaration ( ' VTable offset = 28
 BYREF Declaration AS D3DVERTEXELEMENT9
 ) AS LONG
 ' =====================================================================================
 METHOD GetNumBytesPerVertex ( ' VTable offset = 32
 ) AS DWORD
 ' =====================================================================================
 METHOD GetOptions ( ' VTable offset = 36
 ) AS DWORD
 ' =====================================================================================
 METHOD GetDevice ( ' VTable offset = 40
 BYREF ppDevice AS IDirect3DDevice9
 ) AS LONG
 ' =====================================================================================
 METHOD CloneMeshFVF ( ' VTable offset = 44
 BYVAL Options AS DWORD
 , BYVAL FVF AS DWORD
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppCloneMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD CloneMesh ( ' VTable offset = 48
 BYVAL Options AS DWORD
 , BYREF pDeclaration AS D3DVERTEXELEMENT9
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppCloneMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD GetVertexBuffer ( ' VTable offset = 52
 BYREF ppVB AS IDirect3DVertexBuffer9
 ) AS LONG
 ' =====================================================================================
 METHOD GetIndexBuffer ( ' VTable offset = 56
 BYREF ppIB AS IDirect3DIndexBuffer9
 ) AS LONG
 ' =====================================================================================
 METHOD LockVertexBuffer ( ' VTable offset = 60
 BYVAL Flags AS DWORD
 , BYREF ppData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnlockVertexBuffer ( ' VTable offset = 64
 ) AS LONG
 ' =====================================================================================
 METHOD LockIndexBuffer ( ' VTable offset = 68
 BYVAL Flags AS DWORD
 , BYREF ppData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnlockIndexBuffer ( ' VTable offset = 72
 ) AS LONG
 ' =====================================================================================
 METHOD GetAttributeTable ( ' VTable offset = 76
 BYREF pAttribTable AS D3DXATTRIBUTERANGE
 , BYREF pAttribTableSize AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD ConvertPointRepsToAdjacency ( ' VTable offset = 80
 BYREF pPRep AS DWORD
 , BYREF pAdjacency AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD ConvertAdjacencyToPointReps ( ' VTable offset = 84
 BYREF pAdjacency AS DWORD
 , BYREF pPRep AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GenerateAdjacency ( ' VTable offset = 88
 BYVAL Epsilon AS SINGLE
 , BYREF pAdjacency AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UpdateSemantics ( ' VTable offset = 92
 BYREF Declaration AS D3DVERTEXELEMENT9
 ) AS LONG
 ' =====================================================================================
 ' =====================================================================================
 ' ID3DXMesh methods
 ' =====================================================================================
 METHOD LockAttributeBuffer ( ' VTable offset = 96
 BYVAL Flags AS DWORD
 , BYREF ppData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnlockAttributeBuffer ( ' VTable offset = 100
 ) AS LONG
 ' =====================================================================================
 METHOD Optimize ( ' VTable offset = 104
 BYVAL Flags AS DWORD
 , BYREF pAdjacencyIn AS DWORD
 , BYREF pAdjacencyOut AS DWORD
 , BYREF pFaceRemap AS DWORD
 , BYREF ppVertexRemap AS ID3DXBuffer
 , BYREF ppOptMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD OptimizeInplace ( ' VTable offset = 108
 BYVAL Flags AS DWORD
 , BYREF pAdjacencyIn AS DWORD
 , BYREF pAdjacencyOut AS DWORD
 , BYREF pFaceRemap AS DWORD
 , BYREF ppVertexRemap AS ID3DXBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD SetAttributeTable ( ' VTable offset = 112
 BYREF pAttribTable AS D3DXATTRIBUTERANGE
 , BYVAL cAttribTableSize AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
'//////////////////////////////////////////////////////////////////////////////
'// ID3DXPMesh ////////////////////////////////////////////////////////////////
'//////////////////////////////////////////////////////////////////////////////
INTERFACE ID3DXPMesh $IID_ID3DXPMesh
 INHERIT IUnknown
 ' =====================================================================================
 ' ID3DXBaseMesh methods
 ' =====================================================================================
 METHOD DrawSubset ( ' VTable offset = 12
 BYVAL AttribId AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetNumFaces ( ' VTable offset = 16
 ) AS DWORD
 ' =====================================================================================
 METHOD GetNumVertices ( ' VTable offset = 20
 ) AS DWORD
 ' =====================================================================================
 METHOD GetFVF ( ' VTable offset = 24
 ) AS DWORD
 ' =====================================================================================
 METHOD GetDeclaration ( ' VTable offset = 28
 BYREF Declaration AS D3DVERTEXELEMENT9
 ) AS LONG
 ' =====================================================================================
 METHOD GetNumBytesPerVertex ( ' VTable offset = 32
 ) AS DWORD
 ' =====================================================================================
 METHOD GetOptions ( ' VTable offset = 36
 ) AS DWORD
 ' =====================================================================================
 METHOD GetDevice ( ' VTable offset = 40
 BYREF ppDevice AS IDirect3DDevice9
 ) AS LONG
 ' =====================================================================================
 METHOD CloneMeshFVF ( ' VTable offset = 44
 BYVAL Options AS DWORD
 , BYVAL FVF AS DWORD
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppCloneMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD CloneMesh ( ' VTable offset = 48
 BYVAL Options AS DWORD
 , BYREF pDeclaration AS D3DVERTEXELEMENT9
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppCloneMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD GetVertexBuffer ( ' VTable offset = 52
 BYREF ppVB AS IDirect3DVertexBuffer9
 ) AS LONG
 ' =====================================================================================
 METHOD GetIndexBuffer ( ' VTable offset = 56
 BYREF ppIB AS IDirect3DIndexBuffer9
 ) AS LONG
 ' =====================================================================================
 METHOD LockVertexBuffer ( ' VTable offset = 60
 BYVAL Flags AS DWORD
 , BYREF ppData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnlockVertexBuffer ( ' VTable offset = 64
 ) AS LONG
 ' =====================================================================================
 METHOD LockIndexBuffer ( ' VTable offset = 68
 BYVAL Flags AS DWORD
 , BYREF ppData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnlockIndexBuffer ( ' VTable offset = 72
 ) AS LONG
 ' =====================================================================================
 METHOD GetAttributeTable ( ' VTable offset = 76
 BYREF pAttribTable AS D3DXATTRIBUTERANGE
 , BYREF pAttribTableSize AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD ConvertPointRepsToAdjacency ( ' VTable offset = 80
 BYREF pPRep AS DWORD
 , BYREF pAdjacency AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD ConvertAdjacencyToPointReps ( ' VTable offset = 84
 BYREF pAdjacency AS DWORD
 , BYREF pPRep AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GenerateAdjacency ( ' VTable offset = 88
 BYVAL Epsilon AS SINGLE
 , BYREF pAdjacency AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UpdateSemantics ( ' VTable offset = 92
 BYREF Declaration AS D3DVERTEXELEMENT9
 ) AS LONG
 ' =====================================================================================
 ' =====================================================================================
 ' ID3DXPMesh methods
 ' =====================================================================================
 METHOD ClonePMeshFVF ( ' VTable offset = 96
 BYVAL Options AS DWORD
 , BYVAL FVF AS DWORD
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppCloneMesh AS ID3DXPMesh
 ) AS LONG
 ' =====================================================================================
 METHOD ClonePMesh ( ' VTable offset = 100
 BYVAL Options AS DWORD
 , BYREF pDeclaration AS D3DVERTEXELEMENT9
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppCloneMesh AS ID3DXPMesh
 ) AS LONG
 ' =====================================================================================
 METHOD SetNumFaces ( ' VTable offset = 104
 BYVAL Faces AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetNumVertices ( ' VTable offset = 108
 BYVAL Vertices AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetMaxFaces ( ' VTable offset = 112
 ) AS DWORD
 ' =====================================================================================
 METHOD GetMinFaces ( ' VTable offset = 116
 ) AS DWORD
 ' =====================================================================================
 METHOD GetMaxVertices ( ' VTable offset = 120
 ) AS DWORD
 ' =====================================================================================
 METHOD GetMinVertices ( ' VTable offset = 124
 ) AS DWORD
 ' =====================================================================================
 METHOD Save ( ' VTable offset = 128
 BYVAL pStream AS IStream
 , BYREF pMaterials AS D3DXMATERIAL
 , BYREF pEffectInstances AS D3DXEFFECTINSTANCE
 , BYVAL NumMaterials AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD Optimize ( ' VTable offset = 132
 BYVAL Flags AS DWORD
 , BYREF pAdjacencyOut AS DWORD
 , BYREF pFaceRemap AS DWORD
 , BYREF ppVertexRemap AS ID3DXBuffer
 , BYREF ppOptMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD OptimizeBaseLOD ( ' VTable offset = 136
 BYVAL Flags AS DWORD
 , BYREF pFaceRemap AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD TrimByFaces ( ' VTable offset = 140
 BYVAL NewFacesMin AS DWORD
 , BYVAL NewFacesMax AS DWORD
 , BYREF rgiFaceRemap AS DWORD
 , BYREF rgiVertRemap AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD TrimByVertices ( ' VTable offset = 144
 BYVAL NewVerticesMin AS DWORD
 , BYVAL NewVerticesMax AS DWORD
 , BYREF rgiFaceRemap AS DWORD
 , BYREF rgiVertRemap AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetAdjacency ( ' VTable offset = 148
 BYREF pAdjacency AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GenerateVertexHistory ( ' VTable offset = 152
 BYREF pVertexHistory AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
'//////////////////////////////////////////////////////////////////////////////
'// ID3DXSPMesh ///////////////////////////////////////////////////////////////
'//////////////////////////////////////////////////////////////////////////////
INTERFACE ID3DXSPMesh $IID_ID3DXSPMesh
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetNumFaces ( ' VTable offset = 12
 ) AS DWORD
 ' =====================================================================================
 METHOD GetNumVertices ( ' VTable offset = 16
 ) AS DWORD
 ' =====================================================================================
 METHOD GetFVF ( ' VTable offset = 20
 ) AS DWORD
 ' =====================================================================================
 METHOD GetDeclaration ( ' VTable offset = 24
 BYREF Declaration AS D3DVERTEXELEMENT9
 ) AS LONG
 ' =====================================================================================
 METHOD GetOptions ( ' VTable offset = 28
 ) AS DWORD
 ' =====================================================================================
 METHOD GetDevice ( ' VTable offset = 32
 BYREF ppDevice AS IDirect3DDevice9
 ) AS LONG
 ' =====================================================================================
 METHOD CloneMeshFVF ( ' VTable offset = 36
 BYVAL Options AS DWORD
 , BYVAL FVF AS DWORD
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF pAdjacencyOut AS DWORD
 , BYREF pVertexRemapOut AS DWORD
 , BYREF ppCloneMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD CloneMesh ( ' VTable offset = 40
 BYVAL Options AS DWORD
 , BYREF pDeclaration AS D3DVERTEXELEMENT9
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF pAdjacencyOut AS DWORD
 , BYREF pVertexRemapOut AS DWORD
 , BYREF ppCloneMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD ClonePMeshFVF ( ' VTable offset = 44
 BYVAL Options AS DWORD
 , BYVAL FVF AS DWORD
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF pVertexRemapOut AS DWORD
 , BYREF pErrorsByFace AS SINGLE
 , BYREF ppCloneMesh AS ID3DXPMesh
 ) AS LONG
 ' =====================================================================================
 METHOD ClonePMesh ( ' VTable offset = 48
 BYVAL Options AS DWORD
 , BYREF pDeclaration AS D3DVERTEXELEMENT9
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF pVertexRemapOut AS DWORD
 , BYREF pErrorsbyFace AS SINGLE
 , BYREF ppCloneMesh AS ID3DXPMesh
 ) AS LONG
 ' =====================================================================================
 METHOD ReduceFaces ( ' VTable offset = 52
 BYVAL Faces AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD ReduceVertices ( ' VTable offset = 56
 BYVAL Vertices AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetMaxFaces ( ' VTable offset = 60
 ) AS DWORD
 ' =====================================================================================
 METHOD GetMaxVertices ( ' VTable offset = 64
 ) AS DWORD
 ' =====================================================================================
 METHOD GetVertexAttributeWeights ( ' VTable offset = 68
 BYREF pVertexAttributeWeights AS D3DXATTRIBUTEWEIGHTS
 ) AS DWORD
 ' =====================================================================================
 METHOD GetVertexWeights ( ' VTable offset = 72
 BYREF pVertexWeights AS SINGLE
 ) AS DWORD
 ' =====================================================================================
END INTERFACE
%EQUATE `UNUSED16 = &HFFFF
%EQUATE `UNUSED32 = &HFFFFFFFF
'// ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags
'enum D3DXMESHOPT {
%EQUATE `D3DXMESHOPT_COMPACT = &H01000000
%EQUATE `D3DXMESHOPT_ATTRSORT = &H02000000
%EQUATE `D3DXMESHOPT_VERTEXCACHE = &H04000000
%EQUATE `D3DXMESHOPT_STRIPREORDER = &H08000000
%EQUATE `D3DXMESHOPT_IGNOREVERTS = &H10000000 ' // optimize faces only, don't touch vertices
%EQUATE `D3DXMESHOPT_DONOTSPLIT = &H20000000 ' // do not split vertices shared between attribute groups when attribute sorting
%EQUATE `D3DXMESHOPT_DEVICEINDEPENDENT = &H00400000 ' // Only affects VCache. uses a static known good cache size for all cards
' // D3DXMESHOPT_SHAREVB has been removed, please use D3DXMESH_VB_SHARE instead
'// Subset of the mesh that has the same attribute and bone combination.
'// This subset can be rendered in a single draw call
' // Size = 24 bytes
TYPE D3DXBONECOMBINATION DWORD
 AttribId AS DWORD
 FaceStart AS DWORD
 FaceCount AS DWORD
 VertexStart AS DWORD
 VertexCount AS DWORD
 BoneId AS DWORD
END TYPE
'// The following types of patch combinations are supported:
'// Patch type Basis Degree
'// Rect Bezier 2,3,5
'// Rect B-Spline 2,3,5
'// Rect Catmull-Rom 3
'// Tri Bezier 2,3,5
'// N-Patch N/A 3
' // Size = 12 bytes
TYPE D3DXPATCHINFO DWORD
 PatchType AS DWORD ' D3DXPATCHMESHTYPE
 Degree AS DWORD ' D3DDEGREETYPE
 Basis AS DWORD ' D3DBASISTYPE
END TYPE
'//////////////////////////////////////////////////////////////////////////////
'// ID3DXPatchMesh ////////////////////////////////////////////////////////////
'//////////////////////////////////////////////////////////////////////////////
INTERFACE ID3DXPatchMesh $IID_ID3DXPatchMesh
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetNumPatches ( ' VTable offset = 12
 ) AS DWORD
 ' =====================================================================================
 METHOD GetNumVertices ( ' VTable offset = 16
 ) AS DWORD
 ' =====================================================================================
 METHOD GetDeclaration ( ' VTable offset = 20
 BYREF Declaration AS D3DVERTEXELEMENT9
 ) AS LONG
 ' =====================================================================================
 METHOD GetControlVerticesPerPatch ( ' VTable offset = 24
 ) AS DWORD
 ' =====================================================================================
 METHOD GetOptions ( ' VTable offset = 28
 ) AS DWORD
 ' =====================================================================================
 METHOD GetDevice ( ' VTable offset = 32
 BYREF ppDevice AS IDirect3DDevice9
 ) AS LONG
 ' =====================================================================================
 METHOD GetPatchInfo ( ' VTable offset = 36
 BYREF PatchInfo AS D3DXPATCHINFO
 ) AS LONG
 ' =====================================================================================
 METHOD GetVertexBuffer ( ' VTable offset = 40
 BYREF ppVB AS IDirect3DVertexBuffer9
 ) AS LONG
 ' =====================================================================================
 METHOD GetIndexBuffer ( ' VTable offset = 44
 BYREF ppIB AS IDirect3DIndexBuffer9
 ) AS LONG
 ' =====================================================================================
 METHOD LockVertexBuffer ( ' VTable offset = 48
 BYVAL flags AS DWORD
 , BYREF ppData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnlockVertexBuffer ( ' VTable offset = 52
 ) AS LONG
 ' =====================================================================================
 METHOD LockIndexBuffer ( ' VTable offset = 56
 BYVAL flags AS DWORD
 , BYREF ppData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnlockIndexBuffer ( ' VTable offset = 60
 ) AS LONG
 ' =====================================================================================
 METHOD LockAttributeBuffer ( ' VTable offset = 64
 BYVAL flags AS DWORD
 , BYREF ppData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD UnlockAttributeBuffer ( ' VTable offset = 68
 ) AS LONG
 ' =====================================================================================
 METHOD GetTessSize ( ' VTable offset = 72
 BYVAL fTessLevel AS SINGLE
 , BYVAL Adaptive AS DWORD
 , BYREF NumTriangles AS DWORD
 , BYREF NumVertices AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GenerateAdjacency ( ' VTable offset = 76
 BYVAL Tolerance AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD CloneMesh ( ' VTable offset = 80
 BYVAL Options AS DWORD
 , BYREF pDecl AS D3DVERTEXELEMENT9
 , BYREF pMesh AS ID3DXPatchMesh
 ) AS LONG
 ' =====================================================================================
 METHOD Optimize ( ' VTable offset = 84
 BYVAL flags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetDisplaceParam ( ' VTable offset = 88
 BYVAL Texture AS IDirect3DBaseTexture9
 , BYVAL MinFilter AS DWORD
 , BYVAL MagFilter AS DWORD
 , BYVAL MipFilter AS DWORD
 , BYVAL Wrap AS DWORD
 , BYVAL dwLODBias AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetDisplaceParam ( ' VTable offset = 92
 BYREF Texture AS IDirect3DBaseTexture9
 , BYREF MinFilter AS DWORD
 , BYREF MagFilter AS DWORD
 , BYREF MipFilter AS DWORD
 , BYREF Wrap AS DWORD
 , BYREF dwLODBias AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD Tessellate ( ' VTable offset = 96
 BYVAL fTessLevel AS SINGLE
 , BYVAL pMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD TessellateAdaptive ( ' VTable offset = 100
 BYREF pTrans AS D3DXVECTOR4
 , BYVAL dwMaxTessLevel AS DWORD
 , BYVAL dwMinTessLevel AS DWORD
 , BYVAL pMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
END INTERFACE
'//////////////////////////////////////////////////////////////////////////////
'// ID3DXSkinInfo /////////////////////////////////////////////////////////////
'//////////////////////////////////////////////////////////////////////////////
INTERFACE ID3DXSkinInfo $IID_ID3DXSkinInfo
 INHERIT IUnknown
 ' =====================================================================================
 METHOD SetBoneInfluence ( ' VTable offset = 12
 BYVAL bone AS DWORD
 , BYVAL numInfluences AS DWORD
 , BYREF vertices AS DWORD
 , BYREF weights AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD SetBoneVertexInfluence ( ' VTable offset = 16
 BYVAL boneNum AS DWORD
 , BYVAL influenceNum AS DWORD
 , BYVAL weight AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD GetNumBoneInfluences ( ' VTable offset = 20
 BYVAL bone AS DWORD
 ) AS DWORD
 ' =====================================================================================
 METHOD GetBoneInfluence ( ' VTable offset = 24
 BYVAL bone AS DWORD
 , BYREF vertices AS DWORD
 , BYREF weights AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD GetBoneVertexInfluence ( ' VTable offset = 28
 BYVAL boneNum AS DWORD
 , BYVAL influenceNum AS DWORD
 , BYREF pWeight AS SINGLE
 , BYREF pVertexNum AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetMaxVertexInfluences ( ' VTable offset = 32
 BYREF maxVertexInfluences AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetNumBones ( ' VTable offset = 36
 ) AS DWORD
 ' =====================================================================================
 METHOD FindBoneVertexInfluenceIndex ( ' VTable offset = 40
 BYVAL boneNum AS DWORD
 , BYVAL vertexNum AS DWORD
 , BYREF pInfluenceIndex AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetMaxFaceInfluences ( ' VTable offset = 44
 BYVAL pIB AS IDirect3DIndexBuffer9
 , BYVAL NumFaces AS DWORD
 , BYREF maxFaceInfluences AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetMinBoneInfluence ( ' VTable offset = 48
 BYVAL MinInfl AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD GetMinBoneInfluence ( ' VTable offset = 52
 ) AS SINGLE ' SINGLE
 ' =====================================================================================
 METHOD SetBoneName ( ' VTable offset = 56
 BYVAL Bone AS DWORD
 , BYREF pName AS ASCIIZ
 ) AS LONG
 ' =====================================================================================
 METHOD GetBoneName ( ' VTable offset = 60
 BYVAL Bone AS DWORD
 ) AS DWORD
 ' =====================================================================================
 METHOD SetBoneOffsetMatrix ( ' VTable offset = 64
 BYVAL Bone AS DWORD
 , BYREF pBoneTransform AS D3DXMATRIX
 ) AS LONG
 ' =====================================================================================
 METHOD GetBoneOffsetMatrix ( ' VTable offset = 68
 BYVAL Bone AS DWORD
 ) AS D3DXMATRIX ' D3DXMATRIX
 ' =====================================================================================
 METHOD Clone ( ' VTable offset = 72
 BYREF ppSkinInfo AS ID3DXSkinInfo
 ) AS LONG
 ' =====================================================================================
 METHOD Remap ( ' VTable offset = 76
 BYVAL NumVertices AS DWORD
 , BYREF pVertexRemap AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetFVF ( ' VTable offset = 80
 BYVAL FVF AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetDeclaration ( ' VTable offset = 84
 BYREF pDeclaration AS D3DVERTEXELEMENT9
 ) AS LONG
 ' =====================================================================================
 METHOD GetFVF ( ' VTable offset = 88
 ) AS DWORD
 ' =====================================================================================
 METHOD GetDeclaration ( ' VTable offset = 92
 BYREF Declaration AS D3DVERTEXELEMENT9
 ) AS LONG
 ' =====================================================================================
 METHOD UpdateSkinnedMesh ( ' VTable offset = 96
 BYREF pBoneTransforms AS D3DXMATRIX
 , BYREF pBoneInvTransposeTransforms AS D3DXMATRIX
 , BYVAL pVerticesSrc AS DWORD
 , BYVAL pVerticesDst AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD ConvertToBlendedMesh ( ' VTable offset = 100
 BYVAL pMesh AS ID3DXMesh
 , BYVAL Options AS DWORD
 , BYREF pAdjacencyIn AS DWORD
 , BYREF pAdjacencyOut AS DWORD
 , BYREF pFaceRemap AS DWORD
 , BYREF ppVertexRemap AS ID3DXBuffer
 , BYREF pMaxFaceInfl AS DWORD
 , BYREF pNumBoneCombinations AS DWORD
 , BYREF ppBoneCombinationTable AS ID3DXBuffer
 , BYREF ppMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD ConvertToIndexedBlendedMesh ( ' VTable offset = 104
 BYVAL pMesh AS ID3DXMesh
 , BYVAL Options AS DWORD
 , BYVAL paletteSize AS DWORD
 , BYREF pAdjacencyIn AS DWORD
 , BYREF pAdjacencyOut AS DWORD
 , BYREF pFaceRemap AS DWORD
 , BYREF ppVertexRemap AS ID3DXBuffer
 , BYREF pMaxVertexInfl AS DWORD
 , BYREF pNumBoneCombinations AS DWORD
 , BYREF ppBoneCombinationTable AS ID3DXBuffer
 , BYREF ppMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
END INTERFACE
DECLARE FUNCTION D3DXCreateMesh IMPORT $D3DX_DLLNAME ALIAS "D3DXCreateMesh" ( BYVAL NumFaces AS QUAD , BYVAL NumVertices AS QUAD , BYVAL Options AS QUAD , BYREF pDeclaration AS D3DVERTEXELEMENT9 , BYVAL pD3DDevice AS IDirect3DDevice9 , BYREF ppMesh AS ID3DXMesh ) AS LONG
DECLARE FUNCTION D3DXCreateMeshFVF IMPORT $D3DX_DLLNAME ALIAS "D3DXCreateMeshFVF" ( BYVAL NumFaces AS QUAD
 , BYVAL NumVertices AS DWORD
 , BYVAL Options AS DWORD
 , BYVAL FVF AS DWORD
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppMesh AS ID3DXMesh
 ) AS LONG
DECLARE FUNCTION D3DXCreateSPMesh IMPORT $D3DX_DLLNAME ALIAS "D3DXCreateSPMesh" ( BYVAL pMesh AS ID3DXMesh
 , BYREF pAdjacency AS DWORD
 , BYREF pVertexAttributeWeights AS D3DXATTRIBUTEWEIGHTS
 , BYREF pVertexWeights AS SINGLE
 , BYVAL ppSMesh AS ID3DXSPMesh
 ) AS LONG
'// clean a mesh up for simplification, try to make manifold
DECLARE FUNCTION D3DXCleanMesh IMPORT $D3DX_DLLNAME ALIAS "D3DXCleanMesh" ( BYVAL CleanType AS QUAD , BYVAL pMeshIn AS ID3DXMesh , BYREF pAdjacencyIn AS QUAD , BYREF ppMeshOut AS ID3DXMesh , BYREF pAdjacencyOut AS QUAD , BYREF ppErrorsAndWarnings AS ID3DXBuffer ) AS LONG
DECLARE FUNCTION D3DXValidMesh IMPORT $D3DX_DLLNAME ALIAS "D3DXValidMesh" ( BYVAL pMeshIn AS ID3DXMesh
 , BYREF pAdjacency AS DWORD
 , BYREF ppErrorsAndWarnings AS ID3DXBuffer
 ) AS LONG
DECLARE FUNCTION D3DXGeneratePMesh IMPORT $D3DX_DLLNAME ALIAS "D3DXGeneratePMesh" ( BYVAL pMesh AS ID3DXMesh
 , BYREF pAdjacency AS DWORD
 , BYREF pVertexAttributeWeights AS D3DXATTRIBUTEWEIGHTS
 , BYREF pVertexWeights AS SINGLE
 , BYVAL MinValue AS DWORD
 , BYVAL Options AS DWORD
 , BYREF ppPMesh AS ID3DXPMesh
 ) AS LONG
DECLARE FUNCTION D3DXSimplifyMesh IMPORT $D3DX_DLLNAME ALIAS "D3DXSimplifyMesh" ( BYVAL pMesh AS ID3DXMesh
 , BYREF pAdjacency AS DWORD
 , BYREF pVertexAttributeWeights AS D3DXATTRIBUTEWEIGHTS
 , BYREF pVertexWeights AS SINGLE
 , BYVAL MinValue AS DWORD
 , BYVAL Options AS DWORD
 , BYREF ppMesh AS ID3DXMesh
 ) AS LONG
DECLARE FUNCTION D3DXComputeBoundingSphere IMPORT $D3DX_DLLNAME ALIAS "D3DXComputeBoundingSphere" ( BYREF pFirstPosition AS D3DXVECTOR3
 , BYVAL NumVertices AS DWORD
 , BYVAL dwStride AS DWORD
 , BYREF pCenter AS D3DXVECTOR3
 , BYREF pRadius AS SINGLE
 ) AS LONG
DECLARE FUNCTION D3DXComputeBoundingBox IMPORT $D3DX_DLLNAME ALIAS "D3DXComputeBoundingBox" ( BYREF pFirstPosition AS D3DXVECTOR3
 , BYVAL NumVertices AS DWORD
 , BYVAL dwStride AS DWORD
 , BYREF pMin AS D3DXVECTOR3
 , BYREF pMax AS D3DXVECTOR3
 ) AS LONG
DECLARE FUNCTION D3DXComputeNormals IMPORT $D3DX_DLLNAME ALIAS "D3DXComputeNormals" ( BYVAL pMesh AS ID3DXBaseMesh
 , BYREF pAdjacency AS DWORD
 ) AS LONG
DECLARE FUNCTION D3DXCreateBuffer IMPORT $D3DX_DLLNAME ALIAS "D3DXCreateBuffer" ( BYVAL NumBytes AS DWORD
 , BYREF ppBuffer AS ID3DXBuffer
 ) AS LONG
DECLARE FUNCTION D3DXLoadMeshFromXA IMPORT $D3DX_DLLNAME ALIAS "D3DXLoadMeshFromXA" ( BYREF pFilename AS ASCIIZ
 , BYVAL Options AS DWORD
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppAdjacency AS ID3DXBuffer
 , BYREF ppMaterials AS ID3DXBuffer
 , BYREF ppEffectInstances AS ID3DXBuffer
 , BYREF pNumMaterials AS DWORD
 , BYREF ppMesh AS ID3DXMesh
 ) AS LONG
DECLARE FUNCTION D3DXLoadMeshFromXW IMPORT $D3DX_DLLNAME ALIAS "D3DXLoadMeshFromXW" ( BYREF pFilename AS WSTRINGZ
 , BYVAL Options AS DWORD
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppAdjacency AS ID3DXBuffer
 , BYREF ppAdjacency AS ID3DXBuffer
 , BYREF ppEffectInstances AS ID3DXBuffer
 , BYREF pNumMaterials AS DWORD
 , BYREF ppMesh AS ID3DXMesh
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO D3DXLoadMeshFromX = D3DXLoadMeshFromXW
#ELSE
 MACRO D3DXLoadMeshFromX = D3DXLoadMeshFromXA
#ENDIF
DECLARE FUNCTION D3DXLoadMeshFromXInMemory IMPORT $D3DX_DLLNAME ALIAS "D3DXLoadMeshFromXInMemory" ( BYVAL Memory AS QUAD , BYVAL SizeOfMemory AS QUAD , BYVAL Options AS QUAD , BYVAL pD3DDevice AS IDirect3DDevice9 , BYREF ppAdjacency AS ID3DXBuffer , BYREF ppMaterials AS ID3DXBuffer , BYREF ppEffectInstances AS ID3DXBuffer , BYREF pNumMaterials AS QUAD , BYREF ppMesh AS ID3DXMesh ) AS LONG
DECLARE FUNCTION D3DXLoadMeshFromXResource IMPORT $D3DX_DLLNAME ALIAS "D3DXLoadMeshFromXResource" ( BYVAL Module AS QUAD
 , BYREF Name AS ASCIIZ
 , BYREF Type AS ASCIIZ
 , BYVAL Options AS DWORD
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppAdjacency AS ID3DXBuffer
 , BYREF ppMaterials AS ID3DXBuffer
 , BYREF ppEffectInstances AS ID3DXBuffer
 , BYREF pNumMaterials AS DWORD
 , BYREF ppMesh AS ID3DXMesh
 ) AS LONG
DECLARE FUNCTION D3DXSaveMeshToXA IMPORT $D3DX_DLLNAME ALIAS "D3DXSaveMeshToXA" ( BYREF pFilename AS ASCIIZ
 , BYVAL pMesh AS ID3DXMesh
 , BYREF pAdjacency AS DWORD
 , BYREF pMaterials AS D3DXMATERIAL
 , BYREF pEffectInstances AS D3DXEFFECTINSTANCE
 , BYVAL NumMaterials AS DWORD
 , BYVAL Format AS DWORD
 ) AS LONG
DECLARE FUNCTION D3DXSaveMeshToXW IMPORT $D3DX_DLLNAME ALIAS "D3DXSaveMeshToXW" ( BYREF pFilename AS WSTRINGZ
 , BYVAL pMesh AS ID3DXMesh
 , BYREF pAdjacency AS DWORD
 , BYREF pMaterials AS D3DXMATERIAL
 , BYREF pEffectInstances AS D3DXEFFECTINSTANCE
 , BYVAL NumMaterials AS DWORD
 , BYVAL Format AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO D3DXSaveMeshToX = D3DXSaveMeshToXW
#ELSE
 MACRO D3DXSaveMeshToX = D3DXSaveMeshToXA
#ENDIF
DECLARE FUNCTION D3DXCreatePMeshFromStream IMPORT $D3DX_DLLNAME ALIAS "D3DXCreatePMeshFromStream" ( BYVAL pStream AS IStream , BYVAL Options AS QUAD , BYVAL pD3DDevice AS IDirect3DDevice9 , BYREF ppMaterials AS ID3DXBuffer , BYREF ppEffectInstances AS ID3DXBuffer , BYREF pNumMaterials AS QUAD , BYREF ppPMesh AS ID3DXPMesh ) AS LONG
'// 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
'// The bone names and initial bone transforms are not filled in the skin info object by this method.
DECLARE FUNCTION D3DXCreateSkinInfo IMPORT $D3DX_DLLNAME ALIAS "D3DXCreateSkinInfo" ( BYVAL NumVertices AS QUAD , BYREF pDeclaration AS D3DVERTEXELEMENT9 , BYVAL NumBones AS QUAD , BYREF ppSkinInfo AS ID3DXSkinInfo ) AS LONG
'// 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
'// The bone names and initial bone transforms are not filled in the skin info object by this method.
DECLARE FUNCTION D3DXCreateSkinInfoFVF IMPORT $D3DX_DLLNAME ALIAS "D3DXCreateSkinInfoFVF" ( BYVAL NumVertices AS QUAD , BYVAL FVF AS QUAD , BYVAL NumBones AS QUAD , BYREF ppSkinInfo AS ID3DXSkinInfo ) AS LONG
DECLARE FUNCTION D3DXLoadMeshFromXof IMPORT $D3DX_DLLNAME ALIAS "D3DXLoadMeshFromXof" ( BYVAL pxofMesh AS ID3DXFileData
 , BYVAL Options AS DWORD
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppAdjacency AS ID3DXBuffer
 , BYREF ppMaterials AS ID3DXBuffer
 , BYREF ppEffectInstances AS ID3DXBuffer
 , BYREF pNumMaterials AS DWORD
 , BYREF ppMesh AS ID3DXMesh
 ) AS LONG
'// This similar to D3DXLoadMeshFromXof, except also returns skinning info if present in the file
'// If skinning info is not present, ppSkinInfo will be NULL
DECLARE FUNCTION D3DXLoadSkinMeshFromXof IMPORT $D3DX_DLLNAME ALIAS "D3DXLoadSkinMeshFromXof" ( BYVAL pxofMesh AS ID3DXFileData , BYVAL Options AS QUAD , BYVAL pD3DDevice AS IDirect3DDevice9 , BYREF ppAdjacency AS ID3DXBuffer , BYREF ppMaterials AS ID3DXBuffer , BYREF ppEffectInstances AS ID3DXBuffer , BYREF pMatOut AS QUAD , BYREF ppSkinInfo AS ID3DXSkinInfo , BYREF ppMesh AS ID3DXMesh ) AS LONG
'// The inverse of D3DXConvertTo{Indexed}BlendedMesh() functions. It figures out the skinning info from
'// the mesh and the bone combination table and populates a skin info object with that data. The bone
'// names and initial bone transforms are not filled in the skin info object by this method. This works
'// with either a non-indexed or indexed blended mesh. It examines the FVF or declarator of the mesh to
'// determine what type it is.
DECLARE FUNCTION D3DXCreateSkinInfoFromBlendedMesh IMPORT $D3DX_DLLNAME ALIAS "D3DXCreateSkinInfoFromBlendedMesh" ( BYVAL pMesh AS ID3DXBaseMesh , BYVAL NumBones AS QUAD , BYREF pBoneCombinationTable AS D3DXBONECOMBINATION , BYREF ppSkinInfo AS ID3DXSkinInfo ) AS LONG
DECLARE FUNCTION D3DXTessellateNPatches IMPORT $D3DX_DLLNAME ALIAS "D3DXTessellateNPatches" ( BYVAL pMeshIn AS ID3DXMesh
 , BYREF pAdjacencyIn AS DWORD
 , BYVAL NumSegs AS SINGLE
 , BYVAL QuadraticInterpNormals AS LONG
 , BYREF ppMeshOut AS ID3DXMesh
 , BYREF ppAdjacencyOut AS ID3DXBuffer
 ) AS LONG
'//generates implied outputdecl from input decl
'//the decl generated from this should be used to generate the output decl for
'//the tessellator subroutines.
DECLARE FUNCTION D3DXGenerateOutputDecl IMPORT $D3DX_DLLNAME ALIAS "D3DXGenerateOutputDecl" (_
 BYREF pOutput AS D3DVERTEXELEMENT9
 , BYREF pInput AS D3DVERTEXELEMENT9
 ) AS LONG
'//loads patches from an XFileData
'//since an X file can have up to 6 different patch meshes in it,
'//returns them in an array - pNumPatches will contain the number of
'//meshes in the actual file.
DECLARE FUNCTION D3DXLoadPatchMeshFromXof IMPORT $D3DX_DLLNAME ALIAS "D3DXLoadPatchMeshFromXof" (_
 BYVAL pXofObjMesh AS ID3DXFileData
 , BYVAL Options AS DWORD
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppMaterials AS ID3DXBuffer
 , BYREF ppEffectInstances AS ID3DXBuffer
 , BYREF pNumMaterials AS DWORD
 , BYREF ppMesh AS ID3DXPatchMesh
 ) AS LONG
'//computes the size a single rect patch.
DECLARE FUNCTION D3DXRectPatchSize IMPORT $D3DX_DLLNAME ALIAS "D3DXRectPatchSize" (_
 BYVAL pfNumSegs AS SINGLE
 , BYREF pdwTriangles AS DWORD
 , BYREF pdwVertices AS DWORD
 ) AS LONG
'//computes the size of a single triangle patch
DECLARE FUNCTION D3DXTriPatchSize IMPORT $D3DX_DLLNAME ALIAS "D3DXTriPatchSize" (_
 BYVAL pfNumSegs AS SINGLE
 , BYREF pdwTriangles AS DWORD
 , BYREF pdwVertices AS DWORD
 ) AS LONG
'//tessellates a patch into a created mesh
'//similar to D3D RT patch
DECLARE FUNCTION D3DXTessellateRectPatch IMPORT $D3DX_DLLNAME ALIAS "D3DXTessellateRectPatch" (_
 BYVAL pVB AS IDirect3DVertexBuffer9
 , BYREF pNumSegs AS SINGLE
 , BYREF pdwInDecl AS D3DVERTEXELEMENT9
 , BYREF pRectPatchInfo AS D3DRECTPATCH_INFO
 , BYREF pMesh AS ID3DXMesh
 ) AS LONG
DECLARE FUNCTION D3DXTessellateTriPatch IMPORT $D3DX_DLLNAME ALIAS "D3DXTessellateTriPatch" (_
 BYVAL pVB AS IDirect3DVertexBuffer9
 , BYREF pNumSegs AS SINGLE
 , BYREF pInDecl AS D3DVERTEXELEMENT9
 , BYREF pTriPatchInfo AS D3DTRIPATCH_INFO
 , BYREF pMesh AS ID3DXMesh
 ) AS LONG
'//creates an NPatch PatchMesh from a D3DXMESH
DECLARE FUNCTION D3DXCreateNPatchMesh IMPORT $D3DX_DLLNAME ALIAS "D3DXCreateNPatchMesh" (_
 BYVAL pMeshSysMem AS ID3DXMesh
 , BYREF pPatchMesh AS ID3DXPatchMesh
 ) AS LONG
'//creates a patch mesh
DECLARE FUNCTION D3DXCreatePatchMesh IMPORT $D3DX_DLLNAME ALIAS "D3DXCreatePatchMesh" (_
 BYREF pInfo AS D3DXPATCHINFO
 , BYVAL dwNumPatches AS DWORD
 , BYVAL dwNumVertices AS DWORD
 , BYVAL dwOptions AS DWORD
 , BYREF pDecl AS D3DVERTEXELEMENT9
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF pPatchMesh AS ID3DXPatchMesh
 ) AS LONG
'//returns the number of degenerates in a patch mesh -
'//text output put in string.
DECLARE FUNCTION D3DXValidPatchMesh IMPORT $D3DX_DLLNAME ALIAS "D3DXValidPatchMesh" (_
 BYVAL pMesh AS ID3DXPatchMesh
 , BYREF dwcDegenerateVertices AS DWORD
 , BYREF dwcDegeneratePatches AS DWORD
 , BYREF ppErrorsAndWarnings AS ID3DXBuffer
 ) AS LONG
DECLARE FUNCTION D3DXGetFVFVertexSize IMPORT $D3DX_DLLNAME ALIAS "D3DXGetFVFVertexSize" (_
 BYVAL FVF AS DWORD
 ) AS DWORD ' UINT
DECLARE FUNCTION D3DXGetDeclVertexSize IMPORT $D3DX_DLLNAME ALIAS "D3DXGetDeclVertexSize" (_
 BYREF pDecl AS D3DVERTEXELEMENT9
 , BYVAL Stream AS DWORD
 ) AS DWORD ' UINT
DECLARE FUNCTION D3DXGetDeclLength IMPORT $D3DX_DLLNAME ALIAS "D3DXGetDeclLength" (_
 BYREF pDecl AS D3DVERTEXELEMENT9
 ) AS DWORD ' UINT
DECLARE FUNCTION D3DXDeclaratorFromFVF IMPORT $D3DX_DLLNAME ALIAS "D3DXDeclaratorFromFVF" (_
 BYVAL FVF AS DWORD
 , BYREF pDeclarator AS D3DVERTEXELEMENT9
 ) AS LONG
DECLARE FUNCTION D3DXFVFFromDeclarator IMPORT $D3DX_DLLNAME ALIAS "D3DXFVFFromDeclarator" (_
 BYREF pDeclarator AS D3DVERTEXELEMENT9
 , BYREF pFVF AS DWORD
 ) AS LONG
DECLARE FUNCTION D3DXWeldVertices IMPORT $D3DX_DLLNAME ALIAS "D3DXWeldVertices" (_
 BYVAL pMesh AS ID3DXMesh
 , BYVAL Flags AS DWORD
 , BYREF pEpsilons AS D3DXWELDEPSILONS
 , BYREF pAdjacencyIn AS DWORD
 , BYVAL pAdjacencyOut AS DWORD
 , BYREF pFaceRemap AS DWORD
 , BYREF ppVertexRemap AS ID3DXBuffer
 ) AS LONG
' // Size = 16 bytes
TYPE D3DXINTERSECTINFO DWORD
 FaceIndex AS DWORD ' DWORD // index of face intersected
 U AS SINGLE ' FLOAT // Barycentric Hit Coordinates
 V AS SINGLE ' FLOAT // Barycentric Hit Coordinates
 Dist AS SINGLE ' FLOAT // Ray-Intersection Parameter Distance
END TYPE
DECLARE FUNCTION D3DXIntersect IMPORT $D3DX_DLLNAME ALIAS "D3DXIntersect" (_
 BYVAL pMesh AS ID3DXBaseMesh
 , BYREF pRayPos AS D3DXVECTOR3
 , BYREF pRayDir AS D3DXVECTOR3
 , BYREF pHit AS LONG
 , BYREF pFaceIndex AS DWORD
 , BYREF pU AS SINGLE
 , BYREF pV AS SINGLE
 , BYREF pDist AS SINGLE
 , BYREF ppAllHits AS ID3DXBuffer
 , BYREF pCountOfHits AS DWORD
 ) AS LONG
DECLARE FUNCTION D3DXIntersectSubset IMPORT $D3DX_DLLNAME ALIAS "D3DXIntersectSubset" (_
 BYVAL pMesh AS ID3DXBaseMesh
 , BYVAL AttribId AS DWORD
 , BYREF pRayPos AS D3DXVECTOR3
 , BYREF pRayDir AS D3DXVECTOR3
 , BYREF pHit AS LONG
 , BYREF pFaceIndex AS DWORD
 , BYREF pU AS SINGLE
 , BYREF pV AS SINGLE
 , BYREF pDist AS SINGLE
 , BYREF ppAllHits AS ID3DXBuffer
 , BYREF pCountOfHits AS DWORD
 ) AS LONG
DECLARE FUNCTION D3DXSplitMesh IMPORT $D3DX_DLLNAME ALIAS "D3DXSplitMesh" (_
 BYVAL pMeshIn AS ID3DXMesh
 , BYREF pAdjacencyIn AS DWORD
 , BYVAL MaxSize AS DWORD
 , BYVAL Options AS DWORD
 , BYREF pMeshesOut AS DWORD
 , BYREF ppMeshArrayOut AS ID3DXBuffer
 , BYREF ppAdjacencyArrayOut AS ID3DXBuffer
 , BYREF ppFaceRemapArrayOut AS ID3DXBuffer
 , BYREF ppVertRemapArrayOut AS ID3DXBuffer
 ) AS LONG
DECLARE FUNCTION D3DXIntersectTri IMPORT $D3DX_DLLNAME ALIAS "D3DXIntersectTri" (_
 BYREF p0 AS D3DXVECTOR3
 , BYREF p1 AS D3DXVECTOR3
 , BYREF p2 AS D3DXVECTOR3
 , BYREF pRayPos AS D3DXVECTOR3
 , BYREF pRayDir AS D3DXVECTOR3
 , BYREF pU AS SINGLE
 , BYREF pV AS SINGLE
 , BYREF pDist AS SINGLE
 ) AS LONG
DECLARE FUNCTION D3DXSphereBoundProbe IMPORT $D3DX_DLLNAME ALIAS "D3DXSphereBoundProbe" (_
 BYREF pCenter AS D3DXVECTOR3
 , BYVAL Radius AS SINGLE
 , BYREF pRayPosition AS D3DXVECTOR3
 , BYREF pRayDirection AS D3DXVECTOR3
 ) AS LONG
DECLARE FUNCTION D3DXBoxBoundProbe IMPORT $D3DX_DLLNAME ALIAS "D3DXBoxBoundProbe" (_
 BYREF pMin AS D3DXVECTOR3
 , BYREF pMax AS D3DXVECTOR3
 , BYREF pRayPosition AS D3DXVECTOR3
 , BYREF pRayDirection AS D3DXVECTOR3
 ) AS LONG
DECLARE FUNCTION D3DXComputeTangentFrame IMPORT $D3DX_DLLNAME ALIAS "D3DXComputeTangentFrame" (_
 BYVAL pMesh AS ID3DXMesh
 , BYVAL dwOptions AS DWORD
 ) AS LONG
DECLARE FUNCTION D3DXComputeTangentFrameEx IMPORT $D3DX_DLLNAME ALIAS "D3DXComputeTangentFrameEx" (_
 BYVAL pMesh AS ID3DXMesh
 , BYVAL dwTextureInSemantic AS DWORD
 , BYVAL dwTextureInIndex AS DWORD
 , BYVAL dwUPartialOutSemantic AS DWORD
 , BYVAL dwUPartialOutIndex AS DWORD
 , BYVAL dwVPartialOutSemantic AS DWORD
 , BYVAL dwVPartialOutIndex AS DWORD
 , BYVAL dwNormalOutSemantic AS DWORD
 , BYVAL dwNormalOutIndex AS DWORD
 , BYVAL dwOptions AS DWORD
 , BYREF pdwAdjacency AS DWORD
 , BYVAL fPartialEdgeThreshold AS SINGLE
 , BYVAL fSingularPointThreshold AS SINGLE
 , BYVAL fNormalEdgeThreshold AS SINGLE
 , BYREF ppMeshOut AS ID3DXMesh
 , BYREF ppVertexMapping AS ID3DXBuffer
 ) AS LONG
'//D3DXComputeTangent
'//
'//Computes the Tangent vectors for the TexStage texture coordinates
'//and places the results in the TANGENT[TangentIndex] specified in the meshes' DECL
'//puts the binorm in BINORM[BinormIndex] also specified in the decl.
'//
'//If neither the binorm or the tangnet are in the meshes declaration,
'//the function will fail.
'//
'//If a tangent or Binorm field is in the Decl, but the user does not
'//wish D3DXComputeTangent to replace them, then D3DX_DEFAULT specified
'//in the TangentIndex or BinormIndex will cause it to ignore the specified
'//semantic.
'//
'//Wrap should be specified if the texture coordinates wrap.
DECLARE FUNCTION D3DXComputeTangent IMPORT $D3DX_DLLNAME ALIAS "D3DXComputeTangent" (_
 BYVAL Mesh AS ID3DXMesh
 , BYVAL TexStage AS DWORD
 , BYVAL TangentIndex AS DWORD
 , BYVAL BinormIndex AS DWORD
 , BYVAL Wrap AS DWORD
 ) AS LONG
'//============================================================================
'//
'// UVAtlas apis
'//
'//============================================================================
'typedef HRESULT (WINAPI *LPD3DXUVATLASCB)(FLOAT fPercentDone, LPVOID lpUserContext);
'// This function creates atlases for meshes. There are two modes of operation,
'// either based on the number of charts, or the maximum allowed stretch. If the
'// maximum allowed stretch is 0, then each triangle will likely be in its own
'// chart.
'//
'// The parameters are as follows:
'// pMesh - Input mesh to calculate an atlas for. This must have a position
'// channel and at least a 2-d texture channel.
'// uMaxChartNumber - The maximum number of charts required for the atlas.
'// If this is 0, it will be parameterized based solely on
'// stretch.
'// fMaxStretch - The maximum amount of stretch, if 0, no stretching is allowed,
'// if 1, then any amount of stretching is allowed.
'// uWidth - The width of the texture the atlas will be used on.
'// uHeight - The height of the texture the atlas will be used on.
'// fGutter - The minimum distance, in texels between two charts on the atlas.
'// this gets scaled by the width, so if fGutter is 2.5, and it is
'// used on a 512x512 texture, then the minimum distance will be
'// 2.5 / 512 in u-v space.
'// dwTextureIndex - Specifies which texture coordinate to write to in the
'// output mesh (which is cloned from the input mesh). Useful
'// if your vertex has multiple texture coordinates.
'// pdwAdjacency - a pointer to an array with 3 DWORDs per face, indicating
'// which triangles are adjacent to each other.
'// pdwFalseEdgeAdjacency - a pointer to an array with 3 DWORDS per face, indicating
'// at each face, whether an edge is a false edge or not (using
'// the same ordering as the adjacency data structure). If this
'// is NULL, then it is assumed that there are no false edges. If
'// not NULL, then a non-false edge is indicated by -1 and a false
'// edge is indicated by any other value (it is not required, but
'// it may be useful for the caller to use the original adjacency
'// value). This allows you to parameterize a mesh of quads, and
'// the edges down the middle of each quad will not be cut when
'// parameterizing the mesh.
'// pfIMTArray - a pointer to an array with 3 FLOATs per face, describing the
'// integrated metric tensor for that face. This lets you control
'// the way this triangle may be stretched in the atlas. The IMT
'// passed in will be 3 floats (a,b,c) and specify a symmetric
'// matrix (a b) that, given a vector (s,t), specifies the
'// (b c)
'// distance between a vector v1 and a vector v2 = v1 + (s,t) as
'// sqrt((s, t) * M * (s, t)^T).
'// In other words, this lets one specify the magnitude of the
'// stretch in an arbitrary direction in u-v space. For example
'// if a = b = c = 1, then this scales the vector (1,1) by 2, and
'// the vector (1,-1) by 0. Note that this is multiplying the edge
'// length by the square of the matrix, so if you want the face to
'// stretch to twice its
'// size with no shearing, the IMT value should be (2, 0, 2), which
'// is just the identity matrix times 2.
'// Note that this assumes you have an orientation for the triangle
'// in some 2-D space. For D3DXUVAtlas, this space is created by
'// letting S be the direction from the first to the second
'// vertex, and T be the cross product between the normal and S.
'//
'// pStatusCallback - Since the atlas creation process can be very CPU intensive,
'// this allows the programmer to specify a function to be called
'// periodically, similarly to how it is done in the PRT simulation
'// engine.
'// fCallbackFrequency - This lets you specify how often the callback will be
'// called. A decent default should be 0.0001f.
'// pUserContext - a void pointer to be passed back to the callback function
'// dwOptions - A combination of flags in the D3DXUVATLAS enum
'// ppMeshOut - A pointer to a location to store a pointer for the newly created
'// mesh.
'// ppFacePartitioning - A pointer to a location to store a pointer for an array,
'// one DWORD per face, giving the final partitioning
'// created by the atlasing algorithm.
'// ppVertexRemapArray - A pointer to a location to store a pointer for an array,
'// one DWORD per vertex, giving the vertex it was copied
'// from, if any vertices needed to be split.
'// pfMaxStretchOut - A location to store the maximum stretch resulting from the
'// atlasing algorithm.
'// puNumChartsOut - A location to store the number of charts created, or if the
'// maximum number of charts was too low, this gives the minimum
'// number of charts needed to create an atlas.
DECLARE FUNCTION D3DXUVAtlasCreate IMPORT $D3DX_DLLNAME ALIAS "D3DXUVAtlasCreate" (_
 BYVAL Mesh AS ID3DXMesh
 , BYVAL uMaxChartNumber AS DWORD
 , BYVAL fMaxStretch AS SINGLE
 , BYVAL uWidth AS DWORD
 , BYVAL uHeight AS DWORD
 , BYVAL fGutter AS SINGLE
 , BYVAL dwTextureIndex AS DWORD
 , BYREF pdwAdjacency AS DWORD
 , BYREF pdwFalseEdgeAdjacency AS DWORD
 , BYREF pfIMTArray AS SINGLE
 , BYVAL pStatusCallback AS DWORD
 , BYVAL fCallbackFrequency AS SINGLE
 , BYVAL pUserContext AS DWORD
 , BYVAL dwOptions AS DWORD
 , BYREF ppMeshOut AS ID3DXMesh
 , BYREF ppFacePartitioning AS ID3DXBuffer
 , BYREF ppVertexRemapArray AS ID3DXBuffer
 , BYREF pfMaxStretchOut AS SINGLE
 , BYREF puNumChartsOut AS DWORD
 ) AS LONG
'// This has the same exact arguments as Create, except that it does not perform the
'// final packing step. This method allows one to get a partitioning out, and possibly
'// modify it before sending it to be repacked. Note that if you change the
'// partitioning, you'll also need to calculate new texture coordinates for any faces
'// that have switched charts.
'//
'// The partition result adjacency output parameter is meant to be passed to the
'// UVAtlasPack function, this adjacency cuts edges that are between adjacent
'// charts, and also can include cuts inside of a chart in order to make it
'// equivalent to a disc. For example:
'//
'// _______
'// | ___ |
'// | |_| |
'// |_____|
'//
'// In order to make this equivalent to a disc, we would need to add a cut, and it
'// Would end up looking like:
'// _______
'// | ___ |
'// | |_|_|
'// |_____|
'//
'// The resulting partition adjacency parameter cannot be NULL, because it is
'// required for the packing step.
DECLARE FUNCTION D3DXUVAtlasPartition IMPORT $D3DX_DLLNAME ALIAS "D3DXUVAtlasPartition" (_
 BYVAL Mesh AS ID3DXMesh
 , BYVAL uMaxChartNumber AS DWORD
 , BYVAL fMaxStretch AS SINGLE
 , BYVAL dwTextureIndex AS DWORD
 , BYREF pdwAdjacency AS DWORD
 , BYREF pdwFalseEdgeAdjacency AS DWORD
 , BYREF pfIMTArray AS SINGLE
 , BYVAL pStatusCallback AS DWORD
 , BYVAL fCallbackFrequency AS SINGLE
 , BYVAL pUserContext AS DWORD
 , BYVAL dwOptions AS DWORD
 , BYREF ppMeshOut AS ID3DXMesh
 , BYREF ppFacePartitioning AS ID3DXBuffer
 , BYREF ppVertexRemapArray AS ID3DXBuffer
 , BYREF ppPartitionResultAdjacency AS ID3DXBuffer
 , BYREF pfMaxStretchOut AS SINGLE
 , BYREF puNumChartsOut AS DWORD
 ) AS LONG
'// This takes the face partitioning result from Partition and packs it into an
'// atlas of the given size. pdwPartitionResultAdjacency should be derived from
'// the adjacency returned from the partition step. This value cannot be NULL
'// because Pack needs to know where charts were cut in the partition step in
'// order to find the edges of each chart.
'// The options parameter is currently reserved.
DECLARE FUNCTION D3DXUVAtlasPack IMPORT $D3DX_DLLNAME ALIAS "D3DXUVAtlasPack" (_
 BYVAL Mesh AS ID3DXMesh
 , BYVAL uWidth AS DWORD
 , BYVAL uHeight AS DWORD
 , BYVAL fGutter AS SINGLE
 , BYVAL dwTextureIndex AS DWORD
 , BYREF pdwPartitionResultAdjacency AS DWORD
 , BYVAL pStatusCallback AS DWORD
 , BYVAL fCallbackFrequency AS SINGLE
 , BYVAL pUserContext AS DWORD
 , BYVAL dwOptions AS DWORD
 , BYVAL pFacePartitioning AS ID3DXBuffer
 ) AS LONG
'//============================================================================
'//
'// IMT Calculation apis
'//
'// These functions all compute the Integrated Metric Tensor for use in the
'// UVAtlas API. They all calculate the IMT with respect to the canonical
'// triangle, where the coordinate system is set up so that the u axis goes
'// from vertex 0 to 1 and the v axis is N x u. So, for example, the second
'// vertex's canonical uv coordinates are (d,0) where d is the distance between
'// vertices 0 and 1. This way the IMT does not depend on the parameterization
'// of the mesh, and if the signal over the surface doesn't change, then
'// the IMT doesn't need to be recalculated.
'//============================================================================
'// This callback is used by D3DXComputeIMTFromSignal.
'//
'// uv - The texture coordinate for the vertex.
'// uPrimitiveID - Face ID of the triangle on which to compute the signal.
'// uSignalDimension - The number of floats to store in pfSignalOut.
'// pUserData - The pUserData pointer passed in to ComputeIMTFromSignal.
'// pfSignalOut - A pointer to where to store the signal data.
'typedef HRESULT (WINAPI* LPD3DXIMTSIGNALCALLBACK)
' (CONST D3DXVECTOR2 *uv,
' UINT uPrimitiveID,
' UINT uSignalDimension,
' VOID *pUserData,
' FLOAT *pfSignalOut);
'// This function is used to calculate the IMT from per vertex data. It sets
'// up a linear system over the triangle, solves for the jacobian J, then
'// constructs the IMT from that (J^TJ).
'// This function allows you to calculate the IMT based off of any value in a
'// mesh (color, normal, etc) by specifying the correct stride of the array.
'// The IMT computed will cause areas of the mesh that have similar values to
'// take up less space in the texture.
'//
'// pMesh - The mesh to calculate the IMT for.
'// pVertexSignal - A float array of size uSignalStride * v, where v is the
'// number of vertices in the mesh.
'// uSignalDimension - How many floats per vertex to use in calculating the IMT.
'// uSignalStride - The number of bytes per vertex in the array. This must be
'// a multiple of sizeof(float)
'// ppIMTData - Where to store the buffer holding the IMT data
DECLARE FUNCTION D3DXComputeIMTFromPerVertexSignal IMPORT $D3DX_DLLNAME ALIAS "D3DXComputeIMTFromPerVertexSignal" (_
 BYVAL Mesh AS ID3DXMesh
 , BYREF pfVertexSignal AS SINGLE
 , BYVAL uSignalDimension AS DWORD
 , BYVAL uSignalStride AS DWORD
 , BYVAL dwOptions AS DWORD
 , BYVAL pStatusCallback AS DWORD
 , BYVAL pUserContext AS DWORD
 , BYREF ppIMTData AS ID3DXBuffer
 ) AS LONG
'// This function is used to calculate the IMT from data that varies over the
'// surface of the mesh (generally at a higher frequency than vertex data).
'// This function requires the mesh to already be parameterized (so it already
'// has texture coordinates). It allows the user to define a signal arbitrarily
'// over the surface of the mesh.
'//
'// pMesh - The mesh to calculate the IMT for.
'// dwTextureIndex - This describes which set of texture coordinates in the
'// mesh to use.
'// uSignalDimension - How many components there are in the signal.
'// fMaxUVDistance - The subdivision will continue until the distance between
'// all vertices is at most fMaxUVDistance.
'// dwOptions - reserved for future use
'// pSignalCallback - The callback to use to get the signal.
'// pUserData - A pointer that will be passed in to the callback.
'// ppIMTData - Where to store the buffer holding the IMT data
DECLARE FUNCTION D3DXComputeIMTFromSignal IMPORT $D3DX_DLLNAME ALIAS "D3DXComputeIMTFromSignal" (_
 BYVAL Mesh AS ID3DXMesh
 , BYVAL dwTextureIndex AS DWORD
 , BYVAL uSignalDimension AS DWORD
 , BYVAL fMaxUVDistance AS SINGLE
 , BYVAL dwOptions AS DWORD
 , BYVAL pSignalCallback AS DWORD
 , BYVAL pUserData AS DWORD
 , BYVAL pStatusCallback AS DWORD
 , BYVAL pUserContext AS DWORD
 , BYREF ppIMTData AS ID3DXBuffer
 ) AS LONG
'// This function is used to calculate the IMT from texture data. Given a texture
'// that maps over the surface of the mesh, the algorithm computes the IMT for
'// each face. This will cause large areas that are very similar to take up less
'// room when parameterized with UVAtlas. The texture is assumed to be
'// interpolated over the mesh bilinearly.
'//
'// pMesh - The mesh to calculate the IMT for.
'// pTexture - The texture to load data from.
'// dwTextureIndex - This describes which set of texture coordinates in the
'// mesh to use.
'// dwOptions - Combination of one or more D3DXIMT flags.
'// ppIMTData - Where to store the buffer holding the IMT data
DECLARE FUNCTION D3DXComputeIMTFromTexture IMPORT $D3DX_DLLNAME ALIAS "D3DXComputeIMTFromTexture" (_
 BYVAL Mesh AS ID3DXMesh
 , BYVAL pTexture AS IDirect3DTexture9
 , BYVAL dwTextureIndex AS DWORD
 , BYVAL dwOptions AS DWORD
 , BYVAL pStatusCallback AS DWORD
 , BYVAL pUserContext AS DWORD
 , BYREF ppIMTData AS ID3DXBuffer
 ) AS LONG
'// This function is very similar to ComputeIMTFromTexture, but it uses a
'// float array to pass in the data, and it can calculate higher dimensional
'// values than 4.
'//
'// pMesh - The mesh to calculate the IMT for.
'// dwTextureIndex - This describes which set of texture coordinates in the
'// mesh to use.
'// pfFloatArray - a pointer to a float array of size
'// uWidth*uHeight*uComponents
'// uWidth - The width of the texture
'// uHeight - The height of the texture
'// uSignalDimension - The number of floats per texel in the signal
'// uComponents - The number of floats in each texel
'// dwOptions - Combination of one or more D3DXIMT flags
'// ppIMTData - Where to store the buffer holding the IMT data
DECLARE FUNCTION D3DXComputeIMTFromPerTexelSignal IMPORT $D3DX_DLLNAME ALIAS "D3DXComputeIMTFromPerTexelSignal" (_
 BYVAL Mesh AS ID3DXMesh
 , BYVAL dwTextureIndex AS DWORD
 , BYREF pfTexelSignal AS SINGLE
 , BYVAL uWidth AS DWORD
 , BYVAL uHeight AS DWORD
 , BYVAL uSignalDimension AS DWORD
 , BYVAL uComponents AS DWORD
 , BYVAL dwOptions AS DWORD
 , BYVAL pStatusCallback AS DWORD
 , BYVAL pUserContext AS DWORD
 , BYREF ppIMTData AS ID3DXBuffer
 ) AS LONG
DECLARE FUNCTION D3DXConvertMeshSubsetToSingleStrip IMPORT $D3DX_DLLNAME ALIAS "D3DXConvertMeshSubsetToSingleStrip" (_
 BYVAL MeshIn AS ID3DXBaseMesh
 , BYVAL AttribId AS DWORD
 , BYVAL IBOptions AS DWORD
 , BYREF ppIndexBuffer AS IDirect3DIndexBuffer9
 , BYREF pNumIndices AS DWORD
 ) AS LONG
DECLARE FUNCTION D3DXConvertMeshSubsetToStrips IMPORT $D3DX_DLLNAME ALIAS "D3DXConvertMeshSubsetToStrips" (_
 BYVAL MeshIn AS ID3DXBaseMesh
 , BYVAL AttribId AS DWORD
 , BYVAL IBOptions AS DWORD
 , BYREF ppIndexBuffer AS IDirect3DIndexBuffer9
 , BYREF pNumIndices AS DWORD
 , BYREF ppStripLengths AS ID3DXBuffer
 , BYREF pNumStrips AS DWORD
 ) AS LONG
'//============================================================================
'//
'// D3DXOptimizeFaces:
'// --------------------
'// Generate a face remapping for a triangle list that more effectively utilizes
'// vertex caches. This optimization is identical to the one provided
'// by ID3DXMesh::Optimize with the hardware independent option enabled.
'//
'// Parameters:
'// pbIndices
'// Triangle list indices to use for generating a vertex ordering
'// NumFaces
'// Number of faces in the triangle list
'// NumVertices
'// Number of vertices referenced by the triangle list
'// b32BitIndices
'// TRUE if indices are 32 bit, FALSE if indices are 16 bit
'// pFaceRemap
'// Destination buffer to store face ordering
'// The number stored for a given element is where in the new ordering
'// the face will have come from. See ID3DXMesh::Optimize for more info.
'//
'//============================================================================
DECLARE FUNCTION D3DXOptimizeFaces IMPORT $D3DX_DLLNAME ALIAS "D3DXOptimizeFaces" (_
 BYVAL pbIndices AS DWORD
 , BYVAL cFaces AS DWORD
 , BYVAL cVertices AS DWORD
 , BYVAL b32BitIndices AS LONG
 , BYVAL pFaceRemap AS DWORD
 ) AS LONG
'//============================================================================
'//
'// D3DXOptimizeVertices:
'// --------------------
'// Generate a vertex remapping to optimize for in order use of vertices for
'// a given set of indices. This is commonly used after applying the face
'// remap generated by D3DXOptimizeFaces
'//
'// Parameters:
'// pbIndices
'// Triangle list indices to use for generating a vertex ordering
'// NumFaces
'// Number of faces in the triangle list
'// NumVertices
'// Number of vertices referenced by the triangle list
'// b32BitIndices
'// TRUE if indices are 32 bit, FALSE if indices are 16 bit
'// pVertexRemap
'// Destination buffer to store vertex ordering
'// The number stored for a given element is where in the new ordering
'// the vertex will have come from. See ID3DXMesh::Optimize for more info.
'//
'//============================================================================
DECLARE FUNCTION D3DXOptimizeVertices IMPORT $D3DX_DLLNAME ALIAS "D3DXOptimizeVertices" (_
 BYVAL pbIndices AS DWORD
 , BYVAL cFaces AS DWORD
 , BYVAL cVertices AS DWORD
 , BYVAL b32BitIndices AS LONG
 , BYVAL pVertexRemap AS DWORD
 ) AS LONG
'//===========================================================================
'//
'// Data structures for Spherical Harmonic Precomputation
'//
'//
'//============================================================================
'enum D3DXSHCOMPRESSQUALITYTYPE
%EQUATE `D3DXSHCQUAL_FASTLOWQUALITY = 1
%EQUATE `D3DXSHCQUAL_SLOWHIGHQUALITY = 2
%EQUATE `D3DXSHCQUAL_FORCE_DWORD = &H7FFFFFFF
'enum _D3DXSHGPUSIMOPT
%EQUATE `D3DXSHGPUSIMOPT_SHADOWRES256 = 1
%EQUATE `D3DXSHGPUSIMOPT_SHADOWRES512 = 0
%EQUATE `D3DXSHGPUSIMOPT_SHADOWRES1024 = 2
%EQUATE `D3DXSHGPUSIMOPT_SHADOWRES2048 = 3
%EQUATE `D3DXSHGPUSIMOPT_HIGHQUALITY = 4
%EQUATE `D3DXSHGPUSIMOPT_FORCE_DWORD = &H7FFFFFFF
'// for all properties that are colors the luminance is computed
'// if the simulator is run with a single channel using the following
'// formula: R * 0.2125 + G * 0.7154 + B * 0.0721
' // Size = 60 bytes
TYPE D3DXSHMATERIAL DWORD
 Diffuse AS D3DCOLORVALUE ' // Diffuse albedo of the surface. (Ignored if object is a Mirror)
 bMirror AS LONG ' BOOL // Must be set to FALSE. bMirror == TRUE not currently supported
 bSubSurf AS LONG ' BOOL // true if the object does subsurface scattering - can't do this and be a mirror
 ' // subsurface scattering parameters
 RelativeIndexOfRefraction AS SINGLE ' FLOAT
 Absorption AS D3DCOLORVALUE
 ReducedScattering AS D3DCOLORVALUE
END TYPE
'// allocated in D3DXSHPRTCompSplitMeshSC
'// vertices are duplicated into multiple super clusters but
'// only have a valid status in one super cluster (fill in the rest)
' // Size = 12 bytes
TYPE D3DXSHPRTSPLITMESHVERTDATA DWORD
 uVertRemap AS DWORD ' UINT // vertex in original mesh this corresponds to
 uSubCluster AS DWORD ' UINT // cluster index relative to super cluster
 ucVertStatus AS BYTE ' UCHAR // 1 if vertex has valid data, 0 if it is "fill"
END TYPE
'// used in D3DXSHPRTCompSplitMeshSC
'// information for each super cluster that maps into face/vert arrays
' // Size = 24 bytes
TYPE D3DXSHPRTSPLITMESHCLUSTERDATA DWORD
 uVertStart AS DWORD ' UINT // initial index into remapped vertex array
 uVertLength AS DWORD ' UINT // number of vertices in this super cluster
 uFaceStart AS DWORD ' UINT // initial index into face array
 uFaceLength AS DWORD ' UINT // number of faces in this super cluster
 uClusterStart AS DWORD ' UINT // initial index into cluster array
 uClusterLength AS DWORD ' UINT // number of clusters in this super cluster
END TYPE
'// call back function for simulator
'// return S_OK to keep running the simulator - anything else represents
'// failure and the simulator will abort.
'typedef HRESULT (WINAPI *LPD3DXSHPRTSIMCB)(float fPercentDone, LPVOID lpUserContext);
' Prototype for the callback function LPD3DXSHPRTSIMCB
' You need to declare a function like this one in your program and pass its address
' (with CODEPTR(LPD3DXSHPRTSIMCB) to the function that requires it.
'FUNCTION LPD3DXSHPRTSIMCB (BYVAL fPercentDone AS SINGLE, BYVAL lpUserContext AS DWORD) AS DWORD
'END FUNCTION
'// interfaces for PRT buffers/simulator
$IID_ID3DXPRTBuffer = GUID$("{F1827E47-00A8-49cd-908C-9D11955F8728}")
$IID_ID3DXPRTCompBuffer = GUID$("{A758D465-FE8D-45ad-9CF0-D01E56266A07}")
$IID_ID3DXTextureGutterHelper = GUID$("{06F57E0A-BD95-43f1-A3DA-791CF6CA297B}")
$IID_ID3DXPRTEngine = GUID$("{C3F4ADBF-E6D2-4b7b-BFE8-9E7208746ADF}")
'// Buffer interface - contains "NumSamples" samples
'// each sample in memory is stored as NumCoeffs scalars per channel (1 or 3)
'// Same interface is used for both Vertex and Pixel PRT buffers
'//////////////////////////////////////////////////////////////////////////////
'// ID3DXPRTBuffer ////////////////////////////////////////////////////////////
'//////////////////////////////////////////////////////////////////////////////
INTERFACE ID3DXPRTBuffer $IID_ID3DXPRTBuffer
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetNumSamples ( ' VTable offset = 12
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetNumCoeffs ( ' VTable offset = 16
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetNumChannels ( ' VTable offset = 20
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD IsTexture ( ' VTable offset = 24
 ) AS LONG
 ' =====================================================================================
 METHOD GetWidth ( ' VTable offset = 28
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetHeight ( ' VTable offset = 32
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD Resize ( ' VTable offset = 36
 BYVAL NewSize AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD LockBuffer ( ' VTable offset = 40
 BYVAL Start AS DWORD
 , BYVAL NumSamples AS DWORD
 , BYREF ppData AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD UnlockBuffer ( ' VTable offset = 44
 ) AS LONG
 ' =====================================================================================
 METHOD ScaleBuffer ( ' VTable offset = 48
 BYVAL Scale AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD AddBuffer ( ' VTable offset = 52
 BYVAL pBuffer AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD AttachGH ( ' VTable offset = 56
 BYVAL pGH AS ID3DXTextureGutterHelper
 ) AS LONG
 ' =====================================================================================
 METHOD ReleaseGH ( ' VTable offset = 60
 ) AS LONG
 ' =====================================================================================
 METHOD EvalGH ( ' VTable offset = 64
 ) AS LONG
 ' =====================================================================================
 METHOD ExtractTexture ( ' VTable offset = 68
 BYVAL Channel AS DWORD
 , BYVAL StartCoefficient AS DWORD
 , BYVAL NumCoefficients AS DWORD
 , BYVAL pTexture AS IDirect3DTexture9
 ) AS LONG
 ' =====================================================================================
 METHOD ExtractToMesh ( ' VTable offset = 72
 BYVAL NumCoefficients AS DWORD
 , BYVAL Usage AS DWORD
 , BYVAL UsageIndexStart AS DWORD
 , BYVAL pScene AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
END INTERFACE
' // compressed buffers stored a compressed version of a PRTBuffer
'//////////////////////////////////////////////////////////////////////////////
'// ID3DXPRTCompBuffer ////////////////////////////////////////////////////////
'//////////////////////////////////////////////////////////////////////////////
INTERFACE ID3DXPRTCompBuffer $IID_ID3DXPRTCompBuffer
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetNumSamples ( ' VTable offset = 12
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetNumCoeffs ( ' VTable offset = 16
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetNumChannels ( ' VTable offset = 20
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD IsTexture ( ' VTable offset = 24
 ) AS LONG
 ' =====================================================================================
 METHOD GetWidth ( ' VTable offset = 28
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetHeight ( ' VTable offset = 32
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetNumClusters ( ' VTable offset = 36
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetNumPCA ( ' VTable offset = 40
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD NormalizeData ( ' VTable offset = 44
 ) AS LONG
 ' =====================================================================================
 METHOD ExtractBasis ( ' VTable offset = 48
 BYVAL Cluster AS DWORD
 , BYREF pClusterBasis AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD ExtractClusterIDs ( ' VTable offset = 52
 BYREF pClusterIDs AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD ExtractPCA ( ' VTable offset = 56
 BYVAL StartPCA AS DWORD
 , BYVAL NumExtract AS DWORD
 , BYREF NumExtract AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD ExtractTexture ( ' VTable offset = 60
 BYVAL StartPCA AS DWORD
 , BYVAL NumpPCA AS DWORD
 , BYVAL pTexture AS IDirect3DTexture9
 ) AS LONG
 ' =====================================================================================
 METHOD ExtractToMesh ( ' VTable offset = 64
 BYVAL NumPCA AS DWORD
 , BYVAL Usage AS DWORD
 , BYVAL UsageIndexStart AS DWORD
 , BYVAL pScene AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
END INTERFACE
'// ID3DXTextureGutterHelper will build and manage
'// "gutter" regions in a texture - this will allow for
'// bi-linear interpolation to not have artifacts when rendering
'// It generates a map (in texture space) where each texel
'// is in one of 3 states:
'// 0 Invalid - not used at all
'// 1 Inside triangle
'// 2 Gutter texel
'// 4 represents a gutter texel that will be computed during PRT
'// For each Inside/Gutter texel it stores the face it
'// belongs to and barycentric coordinates for the 1st two
'// vertices of that face. Gutter vertices are assigned to
'// the closest edge in texture space.
'//
'// When used with PRT this requires a unique parameterization
'// of the model - every texel must correspond to a single point
'// on the surface of the model and vice versa
'//////////////////////////////////////////////////////////////////////////////
'// ID3DXPRTCompBuffer ////////////////////////////////////////////////////////
'//////////////////////////////////////////////////////////////////////////////
INTERFACE ID3DXTextureGutterHelper $IID_ID3DXTextureGutterHelper
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetWidth ( ' VTable offset = 12
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetHeight ( ' VTable offset = 16
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD ApplyGuttersFloat ( ' VTable offset = 20
 BYREF pDataIn AS SINGLE
 , BYVAL NumCoeffs AS DWORD
 , BYVAL Width AS DWORD
 , BYVAL Height AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD ApplyGuttersTex ( ' VTable offset = 24
 BYVAL pTexture AS IDirect3DTexture9
 ) AS LONG
 ' =====================================================================================
 METHOD ApplyGuttersPRT ( ' VTable offset = 28
 BYVAL pBuffer AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD GetFaceMap ( ' VTable offset = 32
 BYREF pFaceData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetBaryMap ( ' VTable offset = 36
 BYREF pBaryData AS D3DXVECTOR2
 ) AS LONG
 ' =====================================================================================
 METHOD GetTexelMap ( ' VTable offset = 40
 BYREF pTexelData AS D3DXVECTOR2
 ) AS LONG
 ' =====================================================================================
 METHOD GetGutterMap ( ' VTable offset = 44
 BYREF pGutterData AS BYTE
 ) AS LONG
 ' =====================================================================================
 METHOD SetFaceMap ( ' VTable offset = 48
 BYREF pFaceData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetBaryMap ( ' VTable offset = 52
 BYREF pBaryData AS D3DXVECTOR2
 ) AS LONG
 ' =====================================================================================
 METHOD SetTexelMap ( ' VTable offset = 56
 BYREF pTexelData AS D3DXVECTOR2
 ) AS LONG
 ' =====================================================================================
 METHOD SetGutterMap ( ' VTable offset = 50
 BYREF pGutterData AS BYTE
 ) AS LONG
 ' =====================================================================================
END INTERFACE
'// ID3DXPRTEngine is used to compute a PRT simulation
'// Use the following steps to compute PRT for SH
'// (1) create an interface (which includes a scene)
'// (2) call SetSamplingInfo
'// (3) [optional] Set MeshMaterials/albedo's (required if doing bounces)
'// (4) call ComputeDirectLightingSH
'// (5) [optional] call ComputeBounce
'// repeat step 5 for as many bounces as wanted.
'// if you want to model subsurface scattering you
'// need to call ComputeSS after direct lighting and
'// each bounce.
'// If you want to bake the albedo into the PRT signal, you
'// must call MutliplyAlbedo, otherwise the user has to multiply
'// the albedo themselves. Not multiplying the albedo allows you
'// to model albedo variation at a finer scale then illumination, and
'// can result in better compression results.
'// Luminance values are computed from RGB values using the following
'// formula: R * 0.2125 + G * 0.7154 + B * 0.0721
'//////////////////////////////////////////////////////////////////////////////
'// ID3DXPRTEngine ////////////////////////////////////////////////////////////
'//////////////////////////////////////////////////////////////////////////////
INTERFACE ID3DXPRTEngine $IID_ID3DXPRTEngine
 INHERIT IUnknown
 ' =====================================================================================
 METHOD SetMeshMaterials ( ' VTable offset = 12
 BYREF ppMaterials AS D3DXSHMATERIAL
 , BYVAL NumMeshes AS DWORD
 , BYVAL NumChannels AS DWORD
 , BYVAL bSetAlbedo AS LONG
 , BYVAL fLengthScale AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD SetPerVertexAlbedo ( ' VTable offset = 16
 BYVAL pDataIn AS DWORD
 , BYVAL NumChannels AS DWORD
 , BYVAL Stride AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetPerTexelAlbedo ( ' VTable offset = 20
 BYVAL pAlbedoTexture AS IDirect3DTexture9
 , BYVAL NumChannels AS DWORD
 , BYVAL pGH AS ID3DXTextureGutterHelper
 ) AS LONG
 ' =====================================================================================
 METHOD GetVertexAlbedo ( ' VTable offset = 24
 BYREF pVertColors AS D3DXCOLOR
 , BYVAL NumVerts AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetPerTexelNormal ( ' VTable offset = 28
 BYVAL pNormalTexture AS IDirect3DTexture9
 ) AS LONG
 ' =====================================================================================
 METHOD ExtractPerVertexAlbedo ( ' VTable offset = 32
 BYVAL pMesh AS ID3DXMesh
 , BYVAL Usage AS DWORD
 , BYVAL NumChannels AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD ResampleBuffer ( ' VTable offset = 36
 BYVAL pBufferIn AS ID3DXPRTBuffer
 , BYVAL pBufferOut AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD GetAdaptedMesh ( ' VTable offset = 40
 BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF pFaceRemap AS DWORD
 , BYREF pVertRemap AS DWORD
 , BYREF pfVertWeights AS SINGLE
 , BYREF ppMesh AS ID3DXMesh
 ) AS LONG
 ' =====================================================================================
 METHOD GetNumVerts ( ' VTable offset = 44
 ) AS DWORD
 ' =====================================================================================
 METHOD GetNumFaces ( ' VTable offset = 48
 ) AS DWORD
 ' =====================================================================================
 METHOD RobustMeshRefine ( ' VTable offset = 52
 BYVAL MinEdgeLength AS SINGLE
 , BYVAL MaxSubdiv AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetSamplingInfo ( ' VTable offset = 56
 BYVAL NumRays AS DWORD
 , BYVAL UseSphere AS LONG
 , BYVAL UseCosine AS LONG
 , BYVAL Adaptive AS LONG
 , BYVAL AdaptiveThresh AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD ComputeDirectLightingSH ( ' VTable offset = 60
 BYVAL SHOrder AS DWORD
 , BYVAL pDataOut AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD ComputeDirectLightingSHAdaptive ( ' VTable offset = 64
 BYVAL SHOrder AS DWORD
 , BYVAL AdaptiveThresh AS SINGLE
 , BYVAL MinEdgeLength AS SINGLE
 , BYVAL MaxSubdiv AS DWORD
 , BYVAL pDataOut AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD ComputeDirectLightingSHGPU ( ' VTable offset = 68
 BYVAL pD3DDevice AS IDirect3DDevice9
 , BYVAL Flags AS DWORD
 , BYVAL SHOrder AS DWORD
 , BYVAL ZBias AS SINGLE
 , BYVAL ZAngleBias AS SINGLE
 , BYVAL pDataOut AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD ComputeSS ( ' VTable offset = 72
 BYVAL pDataIn AS ID3DXPRTBuffer
 , BYVAL pDataOut AS ID3DXPRTBuffer
 , BYVAL pDataTotal AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD ComputeBounce ( ' VTable offset = 76
 BYVAL pDataIn AS ID3DXPRTBuffer
 , BYVAL pDataOut AS ID3DXPRTBuffer
 , BYVAL pDataTotal AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD ComputeBounceAdaptive ( ' VTable offset = 80
 BYVAL pDataIn AS ID3DXPRTBuffer
 , BYVAL AdaptiveThresh AS SINGLE
 , BYVAL MinEdgeLength AS SINGLE
 , BYVAL MaxSubdiv AS DWORD
 , BYVAL pDataOut AS ID3DXPRTBuffer
 , BYVAL pDataTotal AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD ComputeVolumeSamplesDirectSH ( ' VTable offset = 84
 BYVAL SHOrderIn AS DWORD
 , BYVAL SHOrderOut AS DWORD
 , BYVAL NumVolSamples AS DWORD
 , BYREF pSampleLocs AS D3DXVECTOR3
 , BYVAL pDataOut AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD ComputeVolumeSamples ( ' VTable offset = 88
 BYVAL pSurfDataIn AS ID3DXPRTBuffer
 , BYVAL SHOrder AS DWORD
 , BYVAL NumVolSamples AS DWORD
 , BYREF pSampleLocs AS D3DXVECTOR3
 , BYVAL pDataOut AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD FreeSSData ( ' VTable offset = 92
 ) AS LONG
 ' =====================================================================================
 METHOD FreeBounceData ( ' VTable offset = 96
 ) AS LONG
 ' =====================================================================================
 METHOD ComputeConvCoeffs ( ' VTable offset = 100
 BYVAL pDataIn AS ID3DXPRTBuffer
 , BYVAL SHOrder AS DWORD
 , BYREF pNormOut AS D3DXVECTOR3
 , BYVAL pDataOut AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD ScaleMeshChunk ( ' VTable offset = 104
 BYVAL uMeshChunk AS DWORD
 , BYVAL fScale AS SINGLE
 , BYVAL pDataOut AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD MultiplyAlbedo ( ' VTable offset = 108
 BYVAL pDataOut AS ID3DXPRTBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD SetCallBack ( ' VTable offset = 112
 BYVAL pCB AS DWORD
 , BYVAL Frequency AS SINGLE
 , BYVAL lpUserContext AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
'// API functions for creating interfaces
'//============================================================================
'//
'// D3DXCreatePRTBuffer:
'// --------------------
'// Generates a PRT Buffer that can be compressed or filled by a simulator
'// This function should be used to create per-vertex or volume buffers.
'// When buffers are created all values are initialized to zero.
'//
'// Parameters:
'// NumSamples
'// Number of sample locations represented
'// NumCoeffs
'// Number of coefficients per sample location (order^2 for SH)
'// NumChannels
'// Number of color channels to represent (1 or 3)
'// ppBuffer
'// Buffer that will be allocated
'//
'//============================================================================
DECLARE FUNCTION D3DXCreatePRTBuffer IMPORT $D3DX_DLLNAME ALIAS "D3DXCreatePRTBuffer" (_
 BYVAL NumSamples AS DWORD
 , BYVAL NumCoeffs AS DWORD
 , BYVAL NumChannels AS DWORD
 , BYREF ppBuffer AS ID3DXPRTBuffer
 ) AS LONG
'//============================================================================
'//
'// D3DXCreatePRTBufferTex:
'// --------------------
'// Generates a PRT Buffer that can be compressed or filled by a simulator
'// This function should be used to create per-pixel buffers.
'// When buffers are created all values are initialized to zero.
'//
'// Parameters:
'// Width
'// Width of texture
'// Height
'// Height of texture
'// NumCoeffs
'// Number of coefficients per sample location (order^2 for SH)
'// NumChannels
'// Number of color channels to represent (1 or 3)
'// ppBuffer
'// Buffer that will be allocated
'//
'//============================================================================
DECLARE FUNCTION D3DXCreatePRTBufferTex IMPORT $D3DX_DLLNAME ALIAS "D3DXCreatePRTBufferTex" (_
 BYVAL Width AS DWORD
 , BYVAL Height AS DWORD
 , BYVAL NumCoeffs AS DWORD
 , BYVAL NumChannels AS DWORD
 , BYREF ppBuffer AS ID3DXPRTBuffer
 ) AS LONG
'//============================================================================
'//
'// D3DXLoadPRTBufferFromFile:
'// --------------------
'// Loads a PRT buffer that has been saved to disk.
'//
'// Parameters:
'// pFilename
'// Name of the file to load
'// ppBuffer
'// Buffer that will be allocated
'//
'//============================================================================
DECLARE FUNCTION D3DXLoadPRTBufferFromFileA IMPORT $D3DX_DLLNAME ALIAS "D3DXLoadPRTBufferFromFileA" (_
 BYREF pFilename AS ASCIIZ
 , BYREF ppBuffer AS ID3DXPRTBuffer
 ) AS LONG
DECLARE FUNCTION D3DXLoadPRTBufferFromFileW IMPORT $D3DX_DLLNAME ALIAS "D3DXLoadPRTBufferFromFileW" (_
 BYREF pFilename AS WSTRINGZ
 , BYREF ppBuffer AS ID3DXPRTBuffer
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO D3DXLoadPRTBufferFromFile = D3DXLoadPRTBufferFromFileW
#ELSE
 MACRO D3DXLoadPRTBufferFromFile = D3DXLoadPRTBufferFromFileA
#ENDIF
'//============================================================================
'//
'// D3DXSavePRTBufferToFile:
'// --------------------
'// Saves a PRTBuffer to disk.
'//
'// Parameters:
'// pFilename
'// Name of the file to save
'// pBuffer
'// Buffer that will be saved
'//
'//============================================================================
DECLARE FUNCTION D3DXSavePRTBufferToFileA IMPORT $D3DX_DLLNAME ALIAS "D3DXSavePRTBufferToFileA" (_
 BYREF pFilename AS ASCIIZ
 , BYVAL pBuffer AS ID3DXPRTBuffer
 ) AS LONG
DECLARE FUNCTION D3DXSavePRTBufferToFileW IMPORT $D3DX_DLLNAME ALIAS "D3DXSavePRTBufferToFileW" (_
 BYREF pFilename AS WSTRINGZ
 , BYVAL pBuffer AS ID3DXPRTBuffer
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO D3DXSavePRTBufferToFile = D3DXSavePRTBufferToFileW
#ELSE
 MACRO D3DXSavePRTBufferToFile = D3DXSavePRTBufferToFileA
#ENDIF
'//============================================================================
'//
'// D3DXLoadPRTCompBufferFromFile:
'// --------------------
'// Loads a PRTComp buffer that has been saved to disk.
'//
'// Parameters:
'// pFilename
'// Name of the file to load
'// ppBuffer
'// Buffer that will be allocated
'//
'//============================================================================
DECLARE FUNCTION D3DXLoadPRTCompBufferFromFileA IMPORT $D3DX_DLLNAME ALIAS "D3DXLoadPRTCompBufferFromFileA" (_
 BYREF pFilename AS ASCIIZ
 , BYREF ppBuffer AS ID3DXPRTCompBuffer
 ) AS LONG
DECLARE FUNCTION D3DXLoadPRTCompBufferFromFileW IMPORT $D3DX_DLLNAME ALIAS "D3DXLoadPRTCompBufferFromFileW" (_
 BYREF pFilename AS WSTRINGZ
 , BYREF ppBuffer AS ID3DXPRTCompBuffer
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO D3DXLoadPRTCompBufferFromFile = D3DXLoadPRTCompBufferFromFileW
#ELSE
 MACRO D3DXLoadPRTCompBufferFromFile = D3DXLoadPRTCompBufferFromFileA
#ENDIF
'//============================================================================
'//
'// D3DXSavePRTCompBufferToFile:
'// --------------------
'// Saves a PRTCompBuffer to disk.
'//
'// Parameters:
'// pFilename
'// Name of the file to save
'// pBuffer
'// Buffer that will be saved
'//
'//============================================================================
DECLARE FUNCTION D3DXSavePRTCompBufferToFileA IMPORT $D3DX_DLLNAME ALIAS "D3DXSavePRTCompBufferToFileA" (_
 BYREF pFilename AS ASCIIZ
 , BYVAL pBuffer AS ID3DXPRTCompBuffer
 ) AS LONG
DECLARE FUNCTION D3DXSavePRTCompBufferToFileW IMPORT $D3DX_DLLNAME ALIAS "D3DXSavePRTCompBufferToFileW" (_
 BYREF pFilename AS WSTRINGZ
 , BYVAL pBuffer AS ID3DXPRTCompBuffer
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO D3DXSavePRTCompBufferToFile = D3DXSavePRTCompBufferToFileW
#ELSE
 MACRO D3DXSavePRTCompBufferToFile = D3DXSavePRTCompBufferToFileA
#ENDIF
'//============================================================================
'//
'// D3DXCreatePRTCompBuffer:
'// --------------------
'// Compresses a PRT buffer (vertex or texel)
'//
'// Parameters:
'// D3DXSHCOMPRESSQUALITYTYPE
'// Quality of compression - low is faster (computes PCA per voronoi cluster)
'// high is slower but better quality (clusters based on distance to affine subspace)
'// NumClusters
'// Number of clusters to compute
'// NumPCA
'// Number of basis vectors to compute
'// pCB
'// Optional Callback function
'// lpUserContext
'// Optional user context
'// pBufferIn
'// Buffer that will be compressed
'// ppBufferOut
'// Compressed buffer that will be created
'//
'//============================================================================
DECLARE FUNCTION D3DXCreatePRTCompBuffer IMPORT $D3DX_DLLNAME ALIAS "D3DXCreatePRTCompBuffer" (_
 BYVAL Quality AS DWORD
 , BYVAL NumClusters AS DWORD
 , BYVAL NumPCA AS DWORD
 , BYVAL pCB AS DWORD
 , BYVAL lpUserContext AS DWORD
 , BYVAL pBufferIn AS ID3DXPRTBuffer
 , BYREF ppBufferOut AS ID3DXPRTCompBuffer
 ) AS LONG
'//============================================================================
'//
'// D3DXCreateTextureGutterHelper:
'// --------------------
'// Generates a "GutterHelper" for a given set of meshes and texture
'// resolution
'//
'// Parameters:
'// Width
'// Width of texture
'// Height
'// Height of texture
'// pMesh
'// Mesh that represents the scene
'// GutterSize
'// Number of texels to over rasterize in texture space
'// this should be at least 1.0
'// ppBuffer
'// GutterHelper that will be created
'//
'//============================================================================
DECLARE FUNCTION D3DXCreateTextureGutterHelper IMPORT $D3DX_DLLNAME ALIAS "D3DXCreateTextureGutterHelper" (_
 BYVAL Width AS DWORD
 , BYVAL Height AS DWORD
 , BYVAL pMesh AS ID3DXMesh
 , BYVAL GutterSize AS SINGLE
 , BYREF ppBuffer AS ID3DXTextureGutterHelper
 ) AS LONG
'//============================================================================
'//
'// D3DXCreatePRTEngine:
'// --------------------
'// Computes a PRTEngine which can efficiently generate PRT simulations
'// of a scene
'//
'// Parameters:
'// pMesh
'// Mesh that represents the scene - must have an AttributeTable
'// where vertices are in a unique attribute.
'// pAdjacency
'// Optional adjacency information
'// ExtractUVs
'// Set this to true if textures are going to be used for albedos
'// or to store PRT vectors
'// pBlockerMesh
'// Optional mesh that just blocks the scene
'// ppEngine
'// PRTEngine that will be created
'//
'//============================================================================
DECLARE FUNCTION D3DXCreatePRTEngine IMPORT $D3DX_DLLNAME ALIAS "D3DXCreatePRTEngine" ( BYVAL pMesh AS ID3DXMesh , BYREF pAdjacency AS QUAD , BYVAL ExtractUVs AS LONG , BYVAL pBlockerMesh AS ID3DXMesh , BYREF ppEngine AS ID3DXPRTEngine ) AS LONG
'//============================================================================
'//
'// D3DXConcatenateMeshes:
'// --------------------
'// Concatenates a group of meshes into one common mesh. This can optionaly transform
'// each sub mesh or its texture coordinates. If no DECL is given it will
'// generate a union of all of the DECL's of the sub meshes, promoting channels
'// and types if neccesary. It will create an AttributeTable if possible, one can
'// call OptimizeMesh with attribute sort and compacting enabled to ensure this.
'//
'// Parameters:
'// ppMeshes
'// Array of pointers to meshes that can store PRT vectors
'// NumMeshes
'// Number of meshes
'// Options
'// Passed through to D3DXCreateMesh
'// pGeomXForms
'// [optional] Each sub mesh is transformed by the corresponding
'// matrix if this array is supplied
'// pTextureXForms
'// [optional] UV coordinates for each sub mesh are transformed
'// by corresponding matrix if supplied
'// pDecl
'// [optional] Only information in this DECL is used when merging
'// data
'// pD3DDevice
'// D3D device that is used to create the new mesh
'// ppMeshOut
'// Mesh that will be created
'//
'//============================================================================
DECLARE FUNCTION D3DXConcatenateMeshes IMPORT $D3DX_DLLNAME ALIAS "D3DXConcatenateMeshes" (_
 BYREF ppMeshes AS ID3DXMesh
 , BYVAL NumMeshes AS DWORD
 , BYVAL Options AS DWORD
 , BYREF pGeomXForms AS D3DXMATRIX
 , BYREF pTextureXForms AS D3DXMATRIX
 , BYREF pDecl AS D3DVERTEXELEMENT9
 , BYVAL pD3DDevice AS IDirect3DDevice9
 , BYREF ppMeshOut AS ID3DXMesh
 ) AS LONG
'//============================================================================
'//
'// D3DXSHPRTCompSuperCluster:
'// --------------------------
'// Used with compressed results of D3DXSHPRTSimulation.
'// Generates "super clusters" - groups of clusters that can be drawn in
'// the same draw call. A greedy algorithm that minimizes overdraw is used
'// to group the clusters.
'//
'// Parameters:
'// pClusterIDs
'// NumVerts cluster ID's (extracted from a compressed buffer)
'// pScene
'// Mesh that represents composite scene passed to the simulator
'// MaxNumClusters
'// Maximum number of clusters allocated per super cluster
'// NumClusters
'// Number of clusters computed in the simulator
'// pSuperClusterIDs
'// Array of length NumClusters, contains index of super cluster
'// that corresponding cluster was assigned to
'// pNumSuperClusters
'// Returns the number of super clusters allocated
'//
'//============================================================================
DECLARE FUNCTION D3DXSHPRTCompSuperCluster IMPORT $D3DX_DLLNAME ALIAS "D3DXSHPRTCompSuperCluster" (_
 BYREF pClusterIDs AS DWORD
 , BYVAL pScene AS ID3DXMesh
 , BYVAL MaxNumClusters AS DWORD
 , BYVAL NumClusters AS DWORD
 , BYREF pSuperClusterIDs AS DWORD
 , BYREF pNumSuperClusters AS DWORD
 ) AS LONG
'//============================================================================
'//
'// D3DXSHPRTCompSplitMeshSC:
'// -------------------------
'// Used with compressed results of the vertex version of the PRT simulator.
'// After D3DXSHRTCompSuperCluster has been called this function can be used
'// to split the mesh into a group of faces/vertices per super cluster.
'// Each super cluster contains all of the faces that contain any vertex
'// classified in one of its clusters. All of the vertices connected to this
'// set of faces are also included with the returned array ppVertStatus
'// indicating whether or not the vertex belongs to the supercluster.
'//
'// Parameters:
'// pClusterIDs
'// NumVerts cluster ID's (extracted from a compressed buffer)
'// NumVertices
'// Number of vertices in original mesh
'// NumClusters
'// Number of clusters (input parameter to compression)
'// pSuperClusterIDs
'// Array of size NumClusters that will contain super cluster ID's (from
'// D3DXSHCompSuerCluster)
'// NumSuperClusters
'// Number of superclusters allocated in D3DXSHCompSuerCluster
'// pInputIB
'// Raw index buffer for mesh - format depends on bInputIBIs32Bit
'// InputIBIs32Bit
'// Indicates whether the input index buffer is 32-bit (otherwise 16-bit
'// is assumed)
'// NumFaces
'// Number of faces in the original mesh (pInputIB is 3 times this length)
'// ppIBData
'// LPD3DXBUFFER holds raw index buffer that will contain the resulting split faces.
'// Format determined by bIBIs32Bit. Allocated by function
'// pIBDataLength
'// Length of ppIBData, assigned in function
'// OutputIBIs32Bit
'// Indicates whether the output index buffer is to be 32-bit (otherwise
'// 16-bit is assumed)
'// ppFaceRemap
'// LPD3DXBUFFER mapping of each face in ppIBData to original faces. Length is
'// *pIBDataLength/3. Optional paramter, allocated in function
'// ppVertData
'// LPD3DXBUFFER contains new vertex data structure. Size of pVertDataLength
'// pVertDataLength
'// Number of new vertices in split mesh. Assigned in function
'// pSCClusterList
'// Array of length NumClusters which pSCData indexes into (Cluster* fields)
'// for each SC, contains clusters sorted by super cluster
'// pSCData
'// Structure per super cluster - contains indices into ppIBData,
'// pSCClusterList and ppVertData
'//
'//============================================================================
DECLARE FUNCTION D3DXSHPRTCompSplitMeshSC IMPORT $D3DX_DLLNAME ALIAS "D3DXSHPRTCompSplitMeshSC" (_
 BYREF pClusterIDs AS DWORD
 , BYVAL NumVertices AS DWORD
 , BYVAL NumClusters AS DWORD
 , BYREF pSuperClusterIDs AS DWORD
 , BYVAL NumSuperClusters AS DWORD
 , BYVAL pInputIB AS DWORD
 , BYVAL InputIBIs32Bit AS LONG
 , BYVAL NumFaces AS DWORD
 , BYREF ppIBData AS ID3DXBuffer
 , BYREF pIBDataLength AS DWORD
 , BYVAL OutputIBIs32Bit AS LONG
 , BYREF ppFaceRemap AS ID3DXBuffer
 , BYREF ppVertData AS ID3DXBuffer
 , BYREF pVertDataLength AS DWORD
 , BYREF pSCClusterList AS DWORD
 , BYREF pSCData AS D3DXSHPRTSPLITMESHCLUSTERDATA
 ) AS LONG
'//////////////////////////////////////////////////////////////////////////////
'//
'// Definitions of .X file templates used by mesh load/save functions
'// that are not RM standard
'//
'//////////////////////////////////////////////////////////////////////////////
$DXFILEOBJ_XSkinMeshHeader = GUID$("{3CF169CE-FF7C-44ab-93C0-F78F62D172E2}")
$DXFILEOBJ_VertexDuplicationIndices = GUID$("{B8D65549-D7C9-4995-89CF-53A9A8B031E3}")
$DXFILEOBJ_FaceAdjacency = GUID$("{A64C844A-E282-4756-8B80-250CDE04398C}")
$DXFILEOBJ_SkinWeights = GUID$("{6F0D123B-BAD2-4167-A0D0-80224F25FABB}")
$DXFILEOBJ_Patch = GUID$("{A3EB5D44-FC22-429d-9AFB-3221CB9719A6}")
$DXFILEOBJ_PatchMesh = GUID$("{D02C95CC-EDBA-4305-9B5D-1820D7704BBF}")
$DXFILEOBJ_PatchMesh9 = GUID$("{B9EC94E1-B9A6-4251-BA18-94893F02C0EA}")
$DXFILEOBJ_PMInfo = GUID$("{B6C3E656-EC8B-4b92-9B62-681659522947}")
$DXFILEOBJ_PMAttributeRange = GUID$("{917E0427-C61E-4a14-9C64-AFE65F9E9844}")
$DXFILEOBJ_PMVSplitRecord = GUID$("{574CCC14-F0B3-4333-822D-93E8A8A08E4C}")
$DXFILEOBJ_FVFData = GUID$("{B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897}")
$DXFILEOBJ_VertexElement = GUID$("{F752461C-1E23-48f6-B9F8-8350850F336F}")
$DXFILEOBJ_DeclData = GUID$("{BF22E553-292C-4781-9FEA-62BD554BDD93}")
$DXFILEOBJ_EffectFloats = GUID$("{F1CFE2B3-0DE3-4e28-AFA1-155A750A282D}")
$DXFILEOBJ_EffectString = GUID$("{D55B097E-BDB6-4c52-B03D-6051C89D0E42}")
$DXFILEOBJ_EffectDWord = GUID$("{622C0ED0-956E-4da9-908A-2AF94F3CE716}")
$DXFILEOBJ_EffectParamFloats = GUID$("{3014B9A0-62F5-478c-9B86-E4AC9F4E418B}")
$DXFILEOBJ_EffectParamString = GUID$("{1DBC4C88-94C1-46ee-9076-2C28818C9481}")
$DXFILEOBJ_EffectParamDWord = GUID$("{E13963BC-AE51-4c5d-B00F-CFA3A9D97CE5}")
$DXFILEOBJ_EffectInstance = GUID$("{E331F7E4-0559-4cc2-8E99-1CEC1657928F}")
$DXFILEOBJ_AnimTicksPerSecond = GUID$("{9E415A43-7BA6-4a73-8743-B73D47E88476}")
$DXFILEOBJ_CompressedAnimationSet = GUID$("{7F9B00B3-F125-4890-876E-1CFFBF697C4D}")
' // Size = 16 bytes
TYPE XFILECOMPRESSEDANIMATIONSET BYTE
 CompressedBlockSize AS DWORD
 TicksPerSec AS SINGLE ' FLOAT
 PlaybackType AS DWORD
 BufferLength AS DWORD
END TYPE
'#define XSKINEXP_TEMPLATES \
' "xof 0303txt 0032\
' template XSkinMeshHeader \
' { \
' <3CF169CE-FF7C-44ab-93C0-F78F62D172E2> \
' WORD nMaxSkinWeightsPerVertex; \
' WORD nMaxSkinWeightsPerFace; \
' WORD nBones; \
' } \
' template VertexDuplicationIndices \
' { \
' <B8D65549-D7C9-4995-89CF-53A9A8B031E3> \
' DWORD nIndices; \
' DWORD nOriginalVertices; \
' array DWORD indices[nIndices]; \
' } \
' template FaceAdjacency \
' { \
' <A64C844A-E282-4756-8B80-250CDE04398C> \
' DWORD nIndices; \
' array DWORD indices[nIndices]; \
' } \
' template SkinWeights \
' { \
' <6F0D123B-BAD2-4167-A0D0-80224F25FABB> \
' STRING transformNodeName; \
' DWORD nWeights; \
' array DWORD vertexIndices[nWeights]; \
' array float weights[nWeights]; \
' Matrix4x4 matrixOffset; \
' } \
' template Patch \
' { \
' <A3EB5D44-FC22-429D-9AFB-3221CB9719A6> \
' DWORD nControlIndices; \
' array DWORD controlIndices[nControlIndices]; \
' } \
' template PatchMesh \
' { \
' <D02C95CC-EDBA-4305-9B5D-1820D7704BBF> \
' DWORD nVertices; \
' array Vector vertices[nVertices]; \
' DWORD nPatches; \
' array Patch patches[nPatches]; \
' [ ... ] \
' } \
' template PatchMesh9 \
' { \
' <B9EC94E1-B9A6-4251-BA18-94893F02C0EA> \
' DWORD Type; \
' DWORD Degree; \
' DWORD Basis; \
' DWORD nVertices; \
' array Vector vertices[nVertices]; \
' DWORD nPatches; \
' array Patch patches[nPatches]; \
' [ ... ] \
' } " \
' "template EffectFloats \
' { \
' <F1CFE2B3-0DE3-4e28-AFA1-155A750A282D> \
' DWORD nFloats; \
' array float Floats[nFloats]; \
' } \
' template EffectString \
' { \
' <D55B097E-BDB6-4c52-B03D-6051C89D0E42> \
' STRING Value; \
' } \
' template EffectDWord \
' { \
' <622C0ED0-956E-4da9-908A-2AF94F3CE716> \
' DWORD Value; \
' } " \
' "template EffectParamFloats \
' { \
' <3014B9A0-62F5-478c-9B86-E4AC9F4E418B> \
' STRING ParamName; \
' DWORD nFloats; \
' array float Floats[nFloats]; \
' } " \
' "template EffectParamString \
' { \
' <1DBC4C88-94C1-46ee-9076-2C28818C9481> \
' STRING ParamName; \
' STRING Value; \
' } \
' template EffectParamDWord \
' { \
' <E13963BC-AE51-4c5d-B00F-CFA3A9D97CE5> \
' STRING ParamName; \
' DWORD Value; \
' } \
' template EffectInstance \
' { \
' <E331F7E4-0559-4cc2-8E99-1CEC1657928F> \
' STRING EffectFilename; \
' [ ... ] \
' } " \
' "template AnimTicksPerSecond \
' { \
' <9E415A43-7BA6-4a73-8743-B73D47E88476> \
' DWORD AnimTicksPerSecond; \
' } \
' template CompressedAnimationSet \
' { \
' <7F9B00B3-F125-4890-876E-1C42BF697C4D> \
' DWORD CompressedBlockSize; \
' FLOAT TicksPerSec; \
' DWORD PlaybackType; \
' DWORD BufferLength; \
' array DWORD CompressedData[BufferLength]; \
' } "
'#define XEXTENSIONS_TEMPLATES \
' "xof 0303txt 0032\
' template FVFData \
' { \
' <B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897> \
' DWORD dwFVF; \
' DWORD nDWords; \
' array DWORD data[nDWords]; \
' } \
' template VertexElement \
' { \
' <F752461C-1E23-48f6-B9F8-8350850F336F> \
' DWORD Type; \
' DWORD Method; \
' DWORD Usage; \
' DWORD UsageIndex; \
' } \
' template DeclData \
' { \
' <BF22E553-292C-4781-9FEA-62BD554BDD93> \
' DWORD nElements; \
' array VertexElement Elements[nElements]; \
' DWORD nDWords; \
' array DWORD data[nDWords]; \
' } \
' template PMAttributeRange \
' { \
' <917E0427-C61E-4a14-9C64-AFE65F9E9844> \
' DWORD iFaceOffset; \
' DWORD nFacesMin; \
' DWORD nFacesMax; \
' DWORD iVertexOffset; \
' DWORD nVerticesMin; \
' DWORD nVerticesMax; \
' } \
' template PMVSplitRecord \
' { \
' <574CCC14-F0B3-4333-822D-93E8A8A08E4C> \
' DWORD iFaceCLW; \
' DWORD iVlrOffset; \
' DWORD iCode; \
' } \
' template PMInfo \
' { \
' <B6C3E656-EC8B-4b92-9B62-681659522947> \
' DWORD nAttributes; \
' array PMAttributeRange attributeRanges[nAttributes]; \
' DWORD nMaxValence; \
' DWORD nMinLogicalVertices; \
' DWORD nMaxLogicalVertices; \
' DWORD nVSplits; \
' array PMVSplitRecord splitRecords[nVSplits]; \
' DWORD nAttributeMispredicts; \
' array DWORD attributeMispredicts[nAttributeMispredicts]; \
' } "
#ENDIF
