Subversion Repositories Games.Chess Giants

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  4. //
  5. //  File:       d3dx10mesh.h
  6. //  Content:    D3DX10 mesh types and functions
  7. //
  8. //////////////////////////////////////////////////////////////////////////////
  9.  
  10. #include "d3dx10.h"
  11.  
  12. #ifndef __D3DX10MESH_H__
  13. #define __D3DX10MESH_H__
  14.  
  15. // {7ED943DD-52E8-40b5-A8D8-76685C406330}
  16. DEFINE_GUID(IID_ID3DX10BaseMesh,
  17. 0x7ed943dd, 0x52e8, 0x40b5, 0xa8, 0xd8, 0x76, 0x68, 0x5c, 0x40, 0x63, 0x30);
  18.  
  19. // {04B0D117-1041-46b1-AA8A-3952848BA22E}
  20. DEFINE_GUID(IID_ID3DX10MeshBuffer,
  21. 0x4b0d117, 0x1041, 0x46b1, 0xaa, 0x8a, 0x39, 0x52, 0x84, 0x8b, 0xa2, 0x2e);
  22.  
  23. // {4020E5C2-1403-4929-883F-E2E849FAC195}
  24. DEFINE_GUID(IID_ID3DX10Mesh,
  25. 0x4020e5c2, 0x1403, 0x4929, 0x88, 0x3f, 0xe2, 0xe8, 0x49, 0xfa, 0xc1, 0x95);
  26.  
  27. // {8875769A-D579-4088-AAEB-534D1AD84E96}
  28. DEFINE_GUID(IID_ID3DX10PMesh,
  29. 0x8875769a, 0xd579, 0x4088, 0xaa, 0xeb, 0x53, 0x4d, 0x1a, 0xd8, 0x4e, 0x96);
  30.  
  31. // {667EA4C7-F1CD-4386-B523-7C0290B83CC5}
  32. DEFINE_GUID(IID_ID3DX10SPMesh,
  33. 0x667ea4c7, 0xf1cd, 0x4386, 0xb5, 0x23, 0x7c, 0x2, 0x90, 0xb8, 0x3c, 0xc5);
  34.  
  35. // {3CE6CC22-DBF2-44f4-894D-F9C34A337139}
  36. DEFINE_GUID(IID_ID3DX10PatchMesh,
  37. 0x3ce6cc22, 0xdbf2, 0x44f4, 0x89, 0x4d, 0xf9, 0xc3, 0x4a, 0x33, 0x71, 0x39);
  38.  
  39.  
  40. // Mesh options - lower 3 bytes only, upper byte used by _D3DX10MESHOPT option flags
  41. enum _D3DX10_MESH {
  42.     D3DX10_MESH_32_BIT                  = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices.
  43.     D3DX10_MESH_GS_ADJACENCY                    = 0x004, // If set, mesh contains GS adjacency info. Not valid on input.
  44.  
  45. };
  46.  
  47. typedef struct _D3DX10_ATTRIBUTE_RANGE
  48. {
  49.     UINT  AttribId;
  50.     UINT  FaceStart;
  51.     UINT  FaceCount;
  52.     UINT  VertexStart;
  53.     UINT  VertexCount;
  54. } D3DX10_ATTRIBUTE_RANGE;
  55.  
  56. typedef D3DX10_ATTRIBUTE_RANGE* LPD3DX10_ATTRIBUTE_RANGE;
  57.  
  58. typedef enum _D3DX10_MESH_DISCARD_FLAGS
  59. {
  60.     D3DX10_MESH_DISCARD_ATTRIBUTE_BUFFER = 0x01,
  61.     D3DX10_MESH_DISCARD_ATTRIBUTE_TABLE = 0x02,
  62.     D3DX10_MESH_DISCARD_POINTREPS = 0x04,
  63.     D3DX10_MESH_DISCARD_ADJACENCY = 0x08,
  64.     D3DX10_MESH_DISCARD_DEVICE_BUFFERS = 0x10,
  65.  
  66. } D3DX10_MESH_DISCARD_FLAGS;
  67.  
  68. typedef struct _D3DX10_WELD_EPSILONS
  69. {
  70.     FLOAT Position;                 // NOTE: This does NOT replace the epsilon in GenerateAdjacency
  71.                                             // in general, it should be the same value or greater than the one passed to GeneratedAdjacency
  72.     FLOAT BlendWeights;
  73.     FLOAT Normal;
  74.     FLOAT PSize;
  75.     FLOAT Specular;
  76.     FLOAT Diffuse;
  77.     FLOAT Texcoord[8];
  78.     FLOAT Tangent;
  79.     FLOAT Binormal;
  80.     FLOAT TessFactor;
  81. } D3DX10_WELD_EPSILONS;
  82.  
  83. typedef D3DX10_WELD_EPSILONS* LPD3DX10_WELD_EPSILONS;
  84.  
  85. typedef struct _D3DX10_INTERSECT_INFO
  86. {
  87.     UINT  FaceIndex;                // index of face intersected
  88.     FLOAT U;                        // Barycentric Hit Coordinates    
  89.     FLOAT V;                        // Barycentric Hit Coordinates
  90.     FLOAT Dist;                     // Ray-Intersection Parameter Distance
  91. } D3DX10_INTERSECT_INFO, *LPD3DX10_INTERSECT_INFO;
  92.  
  93. // ID3DX10MeshBuffer is used by D3DX10Mesh vertex and index buffers
  94. #undef INTERFACE
  95. #define INTERFACE ID3DX10MeshBuffer
  96.  
  97. DECLARE_INTERFACE_(ID3DX10MeshBuffer, IUnknown)
  98. {
  99.     // IUnknown
  100.     STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  101.     STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  102.     STDMETHOD_(ULONG, Release)(THIS) PURE;
  103.    
  104.     // ID3DX10MeshBuffer
  105.     STDMETHOD(Map)(THIS_ void **ppData, SIZE_T *pSize) PURE;
  106.     STDMETHOD(Unmap)(THIS) PURE;
  107.     STDMETHOD_(SIZE_T, GetSize)(THIS) PURE;
  108. };
  109.  
  110. // D3DX10 Mesh interfaces
  111. #undef INTERFACE
  112. #define INTERFACE ID3DX10Mesh
  113.  
  114. DECLARE_INTERFACE_(ID3DX10Mesh, IUnknown)
  115. {
  116.     // IUnknown
  117.     STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  118.     STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  119.     STDMETHOD_(ULONG, Release)(THIS) PURE;
  120.  
  121.     // ID3DX10Mesh
  122.     STDMETHOD_(UINT, GetFaceCount)(THIS) PURE;
  123.     STDMETHOD_(UINT, GetVertexCount)(THIS) PURE;
  124.     STDMETHOD_(UINT, GetVertexBufferCount)(THIS) PURE;
  125.     STDMETHOD_(UINT, GetFlags)(THIS) PURE;
  126.     STDMETHOD(GetVertexDescription)(THIS_ CONST D3D10_INPUT_ELEMENT_DESC **ppDesc, UINT *pDeclCount) PURE;
  127.  
  128.     STDMETHOD(SetVertexData)(THIS_ UINT iBuffer, CONST void *pData) PURE;
  129.     STDMETHOD(GetVertexBuffer)(THIS_ UINT iBuffer, ID3DX10MeshBuffer **ppVertexBuffer) PURE;
  130.  
  131.     STDMETHOD(SetIndexData)(THIS_ CONST void *pData, UINT cIndices) PURE;
  132.     STDMETHOD(GetIndexBuffer)(THIS_ ID3DX10MeshBuffer **ppIndexBuffer) PURE;
  133.  
  134.     STDMETHOD(SetAttributeData)(THIS_ CONST UINT *pData) PURE;
  135.     STDMETHOD(GetAttributeBuffer)(THIS_ ID3DX10MeshBuffer **ppAttributeBuffer) PURE;
  136.  
  137.     STDMETHOD(SetAttributeTable)(THIS_ CONST D3DX10_ATTRIBUTE_RANGE *pAttribTable, UINT  cAttribTableSize) PURE;
  138.     STDMETHOD(GetAttributeTable)(THIS_ D3DX10_ATTRIBUTE_RANGE *pAttribTable, UINT  *pAttribTableSize) PURE;
  139.  
  140.     STDMETHOD(GenerateAdjacencyAndPointReps)(THIS_ FLOAT Epsilon) PURE;
  141.     STDMETHOD(GenerateGSAdjacency)(THIS) PURE;
  142.  
  143.     STDMETHOD(SetAdjacencyData)(THIS_ CONST UINT *pAdjacency) PURE;
  144.     STDMETHOD(GetAdjacencyBuffer)(THIS_ ID3DX10MeshBuffer **ppAdjacency) PURE;
  145.  
  146.     STDMETHOD(SetPointRepData)(THIS_ CONST UINT *pPointReps) PURE;
  147.     STDMETHOD(GetPointRepBuffer)(THIS_ ID3DX10MeshBuffer **ppPointReps) PURE;
  148.    
  149.     STDMETHOD(Discard)(THIS_ D3DX10_MESH_DISCARD_FLAGS dwDiscard) PURE;
  150.     STDMETHOD(CloneMesh)(THIS_ UINT Flags, LPCSTR pPosSemantic, CONST D3D10_INPUT_ELEMENT_DESC *pDesc, UINT  DeclCount, ID3DX10Mesh** ppCloneMesh) PURE;
  151.  
  152.     STDMETHOD(Optimize)(THIS_ UINT Flags, UINT * pFaceRemap, LPD3D10BLOB *ppVertexRemap) PURE;
  153.     STDMETHOD(GenerateAttributeBufferFromTable)(THIS) PURE;
  154.    
  155.         STDMETHOD(Intersect)(THIS_ D3DXVECTOR3 *pRayPos, D3DXVECTOR3 *pRayDir,
  156.                                         UINT *pHitCount, UINT *pFaceIndex, float *pU, float *pV, float *pDist, ID3D10Blob **ppAllHits);
  157.     STDMETHOD(IntersectSubset)(THIS_ UINT AttribId, D3DXVECTOR3 *pRayPos, D3DXVECTOR3 *pRayDir,
  158.                                         UINT *pHitCount, UINT *pFaceIndex, float *pU, float *pV, float *pDist, ID3D10Blob **ppAllHits);
  159.    
  160.     // ID3DX10Mesh - Device functions
  161.     STDMETHOD(CommitToDevice)(THIS) PURE;
  162.     STDMETHOD(DrawSubset)(THIS_ UINT AttribId) PURE;
  163.     STDMETHOD(DrawSubsetInstanced)(THIS_ UINT AttribId, UINT InstanceCount, UINT StartInstanceLocation) PURE;
  164.  
  165.     STDMETHOD(GetDeviceVertexBuffer)(THIS_ UINT iBuffer, ID3D10Buffer **ppVertexBuffer) PURE;
  166.     STDMETHOD(GetDeviceIndexBuffer)(THIS_ ID3D10Buffer **ppIndexBuffer) PURE;
  167. };
  168.  
  169.  
  170. // Flat API
  171. #ifdef __cplusplus
  172. extern "C" {
  173. #endif //__cplusplus
  174.  
  175. HRESULT WINAPI
  176.     D3DX10CreateMesh(
  177.         ID3D10Device *pDevice,
  178.         CONST D3D10_INPUT_ELEMENT_DESC *pDeclaration,
  179.         UINT  DeclCount,
  180.         LPCSTR pPositionSemantic,
  181.         UINT  VertexCount,
  182.         UINT  FaceCount,
  183.         UINT  Options,
  184.         ID3DX10Mesh **ppMesh);
  185.  
  186. #ifdef __cplusplus
  187. }
  188. #endif //__cplusplus
  189.  
  190.  
  191. // ID3DX10Mesh::Optimize options - upper byte only, lower 3 bytes used from _D3DX10MESH option flags
  192. enum _D3DX10_MESHOPT {
  193.     D3DX10_MESHOPT_COMPACT       = 0x01000000,
  194.     D3DX10_MESHOPT_ATTR_SORT     = 0x02000000,
  195.     D3DX10_MESHOPT_VERTEX_CACHE   = 0x04000000,
  196.     D3DX10_MESHOPT_STRIP_REORDER  = 0x08000000,
  197.     D3DX10_MESHOPT_IGNORE_VERTS   = 0x10000000,  // optimize faces only, don't touch vertices
  198.     D3DX10_MESHOPT_DO_NOT_SPLIT    = 0x20000000,  // do not split vertices shared between attribute groups when attribute sorting
  199.     D3DX10_MESHOPT_DEVICE_INDEPENDENT = 0x00400000,  // Only affects VCache.  uses a static known good cache size for all cards
  200.                            
  201.     // D3DX10_MESHOPT_SHAREVB has been removed, please use D3DX10MESH_VB_SHARE instead
  202.  
  203. };
  204.  
  205.  
  206. //////////////////////////////////////////////////////////////////////////
  207. // ID3DXSkinInfo
  208. //////////////////////////////////////////////////////////////////////////
  209.  
  210. // {420BD604-1C76-4a34-A466-E45D0658A32C}
  211. DEFINE_GUID(IID_ID3DX10SkinInfo,
  212. 0x420bd604, 0x1c76, 0x4a34, 0xa4, 0x66, 0xe4, 0x5d, 0x6, 0x58, 0xa3, 0x2c);
  213.  
  214. // scaling modes for ID3DX10SkinInfo::Compact() & ID3DX10SkinInfo::UpdateMesh()
  215. #define D3DX10_SKININFO_NO_SCALING 0
  216. #define D3DX10_SKININFO_SCALE_TO_1 1
  217. #define D3DX10_SKININFO_SCALE_TO_TOTAL 2
  218.  
  219. typedef struct _D3DX10_SKINNING_CHANNEL
  220. {
  221.     UINT            SrcOffset;
  222.     UINT            DestOffset;
  223.     BOOL            IsNormal;
  224. } D3DX10_SKINNING_CHANNEL;
  225.  
  226. #undef INTERFACE
  227. #define INTERFACE ID3DX10SkinInfo
  228.  
  229. typedef struct ID3DX10SkinInfo *LPD3DX10SKININFO;
  230.  
  231. DECLARE_INTERFACE_(ID3DX10SkinInfo, IUnknown)
  232. {
  233.     // IUnknown
  234.     STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  235.     STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  236.     STDMETHOD_(ULONG, Release)(THIS) PURE;
  237.  
  238.     STDMETHOD_(UINT , GetNumVertices)(THIS) PURE;
  239.     STDMETHOD_(UINT , GetNumBones)(THIS) PURE;
  240.     STDMETHOD_(UINT , GetMaxBoneInfluences)(THIS) PURE;
  241.  
  242.     STDMETHOD(AddVertices)(THIS_ UINT  Count) PURE;
  243.     STDMETHOD(RemapVertices)(THIS_ UINT  NewVertexCount, UINT  *pVertexRemap) PURE;
  244.  
  245.     STDMETHOD(AddBones)(THIS_ UINT  Count) PURE;
  246.     STDMETHOD(RemoveBone)(THIS_ UINT  Index) PURE;
  247.     STDMETHOD(RemapBones)(THIS_ UINT  NewBoneCount, UINT  *pBoneRemap) PURE;
  248.  
  249.     STDMETHOD(AddBoneInfluences)(THIS_ UINT  BoneIndex, UINT  InfluenceCount, UINT  *pIndices, float *pWeights) PURE;
  250.     STDMETHOD(ClearBoneInfluences)(THIS_ UINT  BoneIndex) PURE;
  251.     STDMETHOD_(UINT , GetBoneInfluenceCount)(THIS_ UINT  BoneIndex) PURE;
  252.     STDMETHOD(GetBoneInfluences)(THIS_ UINT  BoneIndex, UINT  Offset, UINT  Count, UINT  *pDestIndices, float *pDestWeights) PURE;
  253.     STDMETHOD(FindBoneInfluenceIndex)(THIS_ UINT  BoneIndex, UINT  VertexIndex, UINT  *pInfluenceIndex) PURE;
  254.     STDMETHOD(SetBoneInfluence)(THIS_ UINT  BoneIndex, UINT  InfluenceIndex, float Weight) PURE;
  255.     STDMETHOD(GetBoneInfluence)(THIS_ UINT  BoneIndex, UINT  InfluenceIndex, float *pWeight) PURE;
  256.  
  257.     STDMETHOD(Compact)(THIS_ UINT  MaxPerVertexInfluences, UINT  ScaleMode, float MinWeight) PURE;
  258.     STDMETHOD(DoSoftwareSkinning)(UINT  StartVertex, UINT  VertexCount, void *pSrcVertices, UINT  SrcStride, void *pDestVertices, UINT  DestStride, D3DXMATRIX *pBoneMatrices, D3DXMATRIX *pInverseTransposeBoneMatrices, D3DX10_SKINNING_CHANNEL *pChannelDescs, UINT  NumChannels) PURE;
  259. };
  260.  
  261. #ifdef __cplusplus
  262. extern "C" {
  263. #endif //__cplusplus
  264.  
  265. HRESULT WINAPI
  266.     D3DX10CreateSkinInfo(LPD3DX10SKININFO* ppSkinInfo);
  267.        
  268. #ifdef __cplusplus
  269. }
  270. #endif //__cplusplus
  271.  
  272. typedef struct _D3DX10_ATTRIBUTE_WEIGHTS
  273. {
  274.     FLOAT Position;
  275.     FLOAT Boundary;
  276.     FLOAT Normal;
  277.     FLOAT Diffuse;
  278.     FLOAT Specular;
  279.     FLOAT Texcoord[8];
  280.     FLOAT Tangent;
  281.     FLOAT Binormal;
  282. } D3DX10_ATTRIBUTE_WEIGHTS, *LPD3DX10_ATTRIBUTE_WEIGHTS;
  283.  
  284. #endif //__D3DX10MESH_H__
  285.  
  286.  
  287.