' ########################################################################################
' Microsoft Windows
' File: d3dx10mesh.inc
' Contents: D3DX10 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_D3DX10mesh_PBI)
#DEFINE PBX_D3DX10mesh_PBI
%EQUATE `D3DX10MESH_INC = 1
#INCLUDE ONCE "Legacy/Graphics/D3DX10.inc"
$IID_ID3DX10BaseMesh = GUID$("{7ED943DD-52E8-40B5-A8D8-76685C406330}")
$IID_ID3DX10MeshBuffer = GUID$("{04B0D117-1041-46B1-AA8A-3952848BA22E}")
$IID_ID3DX10Mesh = GUID$("{4020E5C2-1403-4929-883F-E2E849FAC195}")
$IID_ID3DX10PMesh = GUID$("{8875769A-D579-4088-AAEB-534D1AD84E96}")
$IID_ID3DX10SPMesh = GUID$("{667EA4C7-F1CD-4386-B523-7C0290B83CC5}")
$IID_ID3DX10PatchMesh = GUID$("{3CE6CC22-DBF2-44f4-894D-F9C34A337139}")
'// Mesh options - lower 3 bytes only, upper byte used by D3DX10MESHOPT option flags
' enum D3DX10_MESH
%EQUATE `D3DX10_MESH_32_BIT = &H001 ' // If set, then use 32 bit indices, if not set use 16 bit indices.
%EQUATE `D3DX10_MESH_GS_ADJACENCY = &H004 ' // If set, mesh contains GS adjacency info. Not valid on input.
' // Size = 20 bytes
TYPE D3DX10_ATTRIBUTE_RANGE DWORD
 AttribId AS DWORD ' UINT
 FaceStart AS DWORD ' UINT
 FaceCount AS DWORD ' UINT
 VertexStart AS DWORD ' UINT
 VertexCount AS DWORD ' UINT
END TYPE
' enum D3DX10_MESH_DISCARD_FLAGS
%EQUATE `D3DX10_MESH_DISCARD_ATTRIBUTE_BUFFER = &H01
%EQUATE `D3DX10_MESH_DISCARD_ATTRIBUTE_TABLE = &H02
%EQUATE `D3DX10_MESH_DISCARD_POINTREPS = &H04
%EQUATE `D3DX10_MESH_DISCARD_ADJACENCY = &H08
%EQUATE `D3DX10_MESH_DISCARD_DEVICE_BUFFERS = &H10
' // Size = 68 bytes
TYPE D3DX10_WELD_EPSILONS 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
 Tangent AS SINGLE ' FLOAT
 Binormal AS SINGLE ' FLOAT
 TessFactor AS SINGLE ' FLOAT
END TYPE
' // Size = 16 bytes
TYPE D3DX10_INTERSECT_INFO DWORD
 FaceIndex AS DWORD ' UINT // 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
'// ID3DX10MeshBuffer is used by D3DX10Mesh vertex and index buffers
' ########################################################################################
' ID3DX10MeshBuffer interface
' IID = 04B0D117-1041-46B1-AA8A-3952848BA22E
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ID3DX10MeshBuffer_INTERFACE_DEFINED)
 %ID3DX10MeshBuffer_INTERFACE_DEFINED = 1
INTERFACE ID3DX10MeshBuffer $IID_ID3DX10MeshBuffer
 INHERIT IUnknown
 ' =====================================================================================
 METHOD Map ( ' VTable offset = 12
 BYREF pData AS DWORD
 , BYREF pSize AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD Unmap ( ' VTable offset = 16
 ) AS LONG
 ' =====================================================================================
 METHOD GetSize ( ' VTable offset = 20
 ) AS DWORD ' SIZE_T
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ID3DX10MeshBuffer_INTERFACE_DEFINED__ */
'// D3DX10 Mesh interfaces
' ########################################################################################
' ID3DX10Mesh interface
' IID = 04B0D117-1041-46B1-AA8A-3952848BA22E
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ID3DX10Mesh_INTERFACE_DEFINED)
 %ID3DX10Mesh_INTERFACE_DEFINED = 1
INTERFACE ID3DX10Mesh $IID_ID3DX10Mesh
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetFaceCount ( ' VTable offset = 12
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetVertexCount ( ' VTable offset = 16
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetVertexBufferCount ( ' VTable offset = 20
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetFlags ( ' VTable offset = 24
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetVertexDescription ( ' VTable offset = 28
 BYREF ppDesc AS D3D10_INPUT_ELEMENT_DESC
 , BYREF pDeclCount AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetVertexData ( ' VTable offset = 32
 BYVAL iBuffer AS DWORD
 , BYVAL pData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetVertexBuffer ( ' VTable offset = 36
 BYVAL iBuffer AS DWORD
 , BYREF ppVertexBuffer AS ID3DX10MeshBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD SetAttributeData ( ' VTable offset = 40
 BYVAL pData AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetAttributeBuffer ( ' VTable offset = 44
 BYREF ppAttributeBuffer AS ID3DX10MeshBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD SetAttributeTable ( ' VTable offset = 48
 BYREF pAttribTable AS D3DX10_ATTRIBUTE_RANGE
 , BYVAL cAttribTableSize AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetAttributeTable ( ' VTable offset = 52
 BYREF pAttribTable AS D3DX10_ATTRIBUTE_RANGE
 , BYREF pAttribTableSize AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GenerateAdjacencyAndPointReps ( ' VTable offset = 56
 BYVAL Epsilon AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD GenerateGSAdjacency ( ' VTable offset = 60
 ) AS LONG
 ' =====================================================================================
 METHOD SetAdjacencyData ( ' VTable offset = 64
 BYREF pAdjacency AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetAdjacencyBuffer ( ' VTable offset = 68
 BYREF ppAdjacency AS ID3DX10MeshBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD SetPointRepData ( ' VTable offset = 72
 BYREF pPointReps AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetPointRepBuffer ( ' VTable offset = 76
 BYREF ppPointReps AS ID3DX10MeshBuffer
 ) AS LONG
 ' =====================================================================================
 METHOD Discard ( ' VTable offset = 80
 BYVAL dwDiscard AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD CloneMesh ( ' VTable offset = 84
 BYVAL Flags AS DWORD
 , BYREF pPosSemantic AS ASCIIZ
 , BYREF pDesc AS D3D10_INPUT_ELEMENT_DESC
 , BYVAL DeclCount AS DWORD
 , BYREF ppCloneMesh AS ID3DX10Mesh
 ) AS LONG
 ' =====================================================================================
 METHOD Optimize ( ' VTable offset = 88
 BYVAL Flags AS DWORD
 , BYREF pFaceRemap AS DWORD
 , BYVAL ppVertexRemap AS ID3D10Blob
 ) AS LONG
 ' =====================================================================================
 METHOD GenerateAttributeBufferFromTable ( ' VTable offset = 92
 ) AS LONG
 ' =====================================================================================
 METHOD Intersect ( ' VTable offset = 96
 BYREF pRayPos AS D3DXVECTOR3
 , BYREF pRayDir AS D3DXVECTOR3
 , BYREF pHitCount AS DWORD
 , BYREF pFaceIndex AS DWORD
 , BYREF pU AS SINGLE
 , BYREF pV AS SINGLE
 , BYREF pDist AS SINGLE
 , BYREF ppAllHits AS ID3D10Blob
 ) AS LONG
 ' =====================================================================================
 METHOD IntersectSubset ( ' VTable offset = 100
 BYREF pRayPos AS D3DXVECTOR3
 , BYREF pRayDir AS D3DXVECTOR3
 , BYREF pHitCount AS DWORD
 , BYREF pFaceIndex AS DWORD
 , BYREF pU AS SINGLE
 , BYREF pV AS SINGLE
 , BYREF pDist AS SINGLE
 , BYREF ppAllHits AS ID3D10Blob
 ) AS LONG
 ' =====================================================================================
 METHOD CommitToDevice ( ' VTable offset = 104
 ) AS LONG
 ' =====================================================================================
 METHOD DrawSubset ( ' VTable offset = 108
 BYVAL AttribId AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD DrawSubsetInstanced ( ' VTable offset = 112
 BYVAL AttribId AS DWORD
 , BYVAL InstanceCount AS DWORD
 , BYVAL StartInstanceLocation AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetDeviceVertexBuffer ( ' VTable offset = 116
 BYVAL iBuffer AS DWORD
 , BYREF ppVertexBuffer AS ID3D10Buffer
 ) AS LONG
 ' =====================================================================================
 METHOD GetDeviceIndexBuffer ( ' VTable offset = 120
 BYVAL iBuffer AS DWORD
 , BYREF ppIndexBuffer AS ID3D10Buffer
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ID3DX10Mesh_INTERFACE_DEFINED__ */
'// Flat API
DECLARE FUNCTION D3DX10CreateMesh IMPORT $D3DX10_DLLNAME ALIAS "D3DX10CreateMesh" ( BYVAL pDevice AS ID3D10Device , BYREF pDeclaration AS D3D10_INPUT_ELEMENT_DESC , BYVAL DeclCount AS QUAD , BYREF pPositionSemantic AS ASCIIZ , BYVAL VertexCount AS QUAD , BYVAL FaceCount AS QUAD , BYVAL Options AS QUAD , BYREF ppMesh AS ID3DX10Mesh ) AS LONG
'// ID3DX10Mesh::Optimize options - upper byte only, lower 3 bytes used from _D3DX10MESH option flags
' enum D3DX10_MESHOPT
%EQUATE `D3DX10_MESHOPT_COMPACT = &H01000000
%EQUATE `D3DX10_MESHOPT_ATTR_SORT = &H02000000
%EQUATE `D3DX10_MESHOPT_VERTEX_CACHE = &H04000000
%EQUATE `D3DX10_MESHOPT_STRIP_REORDER = &H08000000
%EQUATE `D3DX10_MESHOPT_IGNORE_VERTS = &H10000000 ' // optimize faces only, don't touch vertices
%EQUATE `D3DX10_MESHOPT_DO_NOT_SPLIT = &H20000000 ' // do not split vertices shared between attribute groups when attribute sorting
%EQUATE `D3DX10_MESHOPT_DEVICE_INDEPENDENT = &H00400000 ' // Only affects VCache. uses a static known good cache size for all cards
'// D3DX10_MESHOPT_SHAREVB has been removed, please use D3DX10MESH_VB_SHARE instead
' ########################################################################################
' ID3DX10SkinInfo interface
' IID = 420BD604-1C76-4A34-A466-E45D0658A32C
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ID3DX10SkinInfo_INTERFACE_DEFINED)
 %ID3DX10SkinInfo_INTERFACE_DEFINED = 1
$IID_ID3DX10SkinInfo = GUID$("{420BD604-1C76-4A34-A466-E45D0658A32C}")
'// scaling modes for ID3DX10SkinInfo::Compact() & ID3DX10SkinInfo::UpdateMesh()
%EQUATE `D3DX10_SKININFO_NO_SCALING = 0
%EQUATE `D3DX10_SKININFO_SCALE_TO_1 = 1
%EQUATE `D3DX10_SKININFO_SCALE_TO_TOTAL = 2
' // Size = 12 bytes
TYPE D3DX10_SKINNING_CHANNEL DWORD
 SrcOffset AS DWORD ' UINT
 DestOffset AS DWORD ' UINT
 IsNormal AS LONG
END TYPE
INTERFACE ID3DX10SkinInfo $IID_ID3DX10SkinInfo
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetNumVertices ( ' VTable offset = 12
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetNumBones ( ' VTable offset = 16
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetMaxBoneInfluences ( ' VTable offset = 20
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD AddVertices ( ' VTable offset = 24
 BYVAL Count AS DWORD
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD RemapVertices ( ' VTable offset = 28
 BYVAL NewVertexCount AS DWORD
 , BYREF pVertexRemap AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD AddBones ( ' VTable offset = 32
 BYVAL Count AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD RemoveBone ( ' VTable offset = 36
 BYVAL Index AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD RemapBones ( ' VTable offset = 40
 BYVAL NewBoneCount AS DWORD
 , BYREF pBoneRemap AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD AddBoneInfluences ( ' VTable offset = 44
 BYVAL BoneIndex AS DWORD
 , BYVAL InfluenceCount AS DWORD
 , BYREF pIndices AS DWORD
 , BYREF pWeights AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD ClearBoneInfluences ( ' VTable offset = 48
 BYVAL BoneIndex AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetBoneInfluenceCount ( ' VTable offset = 52
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD GetBoneInfluences ( ' VTable offset = 56
 BYVAL BoneIndex AS DWORD
 , BYVAL Offset AS DWORD
 , BYVAL Count AS DWORD
 , BYREF pDestIndices AS DWORD
 , BYREF pDestWeights AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD FindBoneInfluenceIndex ( ' VTable offset = 60
 BYVAL BoneIndex AS DWORD
 , BYVAL VertexIndex AS DWORD
 , BYREF pInfluenceIndex AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetBoneInfluence ( ' VTable offset = 64
 BYVAL BoneIndex AS DWORD
 , BYVAL InfluenceIndex AS DWORD
 , BYVAL Weight AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD GetBoneInfluence ( ' VTable offset = 68
 BYVAL BoneIndex AS DWORD
 , BYVAL InfluenceIndex AS DWORD
 , BYREF pWeight AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD Compact ( ' VTable offset = 72
 BYVAL MaxPerVertexInfluences AS DWORD
 , BYVAL ScaleMode AS DWORD
 , BYVAL MinWeight AS SINGLE
 ) AS LONG
 ' =====================================================================================
 METHOD DoSoftwareSkinning ( ' VTable offset = 76
 BYVAL StartVertex AS DWORD
 , BYVAL VertexCount AS DWORD
 , BYVAL pSrcVertices AS DWORD
 , BYVAL SrcStride AS DWORD
 , BYVAL pDestVertices AS DWORD
 , BYVAL DestStride AS DWORD
 , BYREF pBoneMatrices AS D3DXMATRIX
 , BYREF pInverseTransposeBoneMatrices AS D3DXMATRIX
 , BYREF pChannelDescs AS D3DX10_SKINNING_CHANNEL
 , BYVAL NumChannels AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ID3DX10SkinInfo_INTERFACE_DEFINED__ */
DECLARE FUNCTION D3DX10CreateSkinInfo IMPORT $D3DX10_DLLNAME ALIAS "D3DX10CreateSkinInfo" ( BYREF ppSkinInfo AS ID3DX10SkinInfo ) AS LONG
' // Size = 60 bytes
TYPE D3DX10_ATTRIBUTE_WEIGHTS 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
#ENDIF
