📄 d3dx9mesh.h
字号:
// 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.
HRESULT WINAPI D3DXUVAtlasCreate(LPD3DXMESH pMesh,
UINT uMaxChartNumber,
FLOAT fMaxStretch,
UINT uWidth,
UINT uHeight,
FLOAT fGutter,
DWORD dwTextureIndex,
CONST DWORD *pdwAdjacency,
CONST DWORD *pdwFalseEdgeAdjacency,
CONST FLOAT *pfIMTArray,
LPD3DXUVATLASCB pStatusCallback,
FLOAT fCallbackFrequency,
LPVOID pUserContext,
DWORD dwOptions,
LPD3DXMESH *ppMeshOut,
LPD3DXBUFFER *ppFacePartitioning,
LPD3DXBUFFER *ppVertexRemapArray,
FLOAT *pfMaxStretchOut,
UINT *puNumChartsOut);
// 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.
HRESULT WINAPI D3DXUVAtlasPartition(LPD3DXMESH pMesh,
UINT uMaxChartNumber,
FLOAT fMaxStretch,
DWORD dwTextureIndex,
CONST DWORD *pdwAdjacency,
CONST DWORD *pdwFalseEdgeAdjacency,
CONST FLOAT *pfIMTArray,
LPD3DXUVATLASCB pStatusCallback,
FLOAT fCallbackFrequency,
LPVOID pUserContext,
DWORD dwOptions,
LPD3DXMESH *ppMeshOut,
LPD3DXBUFFER *ppFacePartitioning,
LPD3DXBUFFER *ppVertexRemapArray,
LPD3DXBUFFER *ppPartitionResultAdjacency,
FLOAT *pfMaxStretchOut,
UINT *puNumChartsOut);
// 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.
HRESULT WINAPI D3DXUVAtlasPack(ID3DXMesh *pMesh,
UINT uWidth,
UINT uHeight,
FLOAT fGutter,
DWORD dwTextureIndex,
CONST DWORD *pdwPartitionResultAdjacency,
LPD3DXUVATLASCB pStatusCallback,
FLOAT fCallbackFrequency,
LPVOID pUserContext,
DWORD dwOptions,
LPD3DXBUFFER pFacePartitioning);
//============================================================================
//
// 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
HRESULT WINAPI D3DXComputeIMTFromPerVertexSignal (
LPD3DXMESH pMesh,
CONST FLOAT *pfVertexSignal, // uSignalDimension floats per vertex
UINT uSignalDimension,
UINT uSignalStride, // stride of signal in bytes
DWORD dwOptions, // reserved for future use
LPD3DXUVATLASCB pStatusCallback,
LPVOID pUserContext,
LPD3DXBUFFER *ppIMTData);
// 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
HRESULT WINAPI D3DXComputeIMTFromSignal(
LPD3DXMESH pMesh,
DWORD dwTextureIndex,
UINT uSignalDimension,
FLOAT fMaxUVDistance,
DWORD dwOptions, // reserved for future use
LPD3DXIMTSIGNALCALLBACK pSignalCallback,
VOID *pUserData,
LPD3DXUVATLASCB pStatusCallback,
LPVOID pUserContext,
LPD3DXBUFFER *ppIMTData);
// 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
HRESULT WINAPI D3DXComputeIMTFromTexture (
LPD3DXMESH pMesh,
LPDIRECT3DTEXTURE9 pTexture,
DWORD dwTextureIndex,
DWORD dwOptions,
LPD3DXUVATLASCB pStatusCallback,
LPVOID pUserContext,
LPD3DXBUFFER *ppIMTData);
// 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
HRESULT WINAPI D3DXComputeIMTFromPerTexelSignal(
LPD3DXMESH pMesh,
DWORD dwTextureIndex,
FLOAT *pfTexelSignal,
UINT uWidth,
UINT uHeight,
UINT uSignalDimension,
UINT uComponents,
DWORD dwOptions,
LPD3DXUVATLASCB pStatusCallback,
LPVOID pUserContext,
LPD3DXBUFFER *ppIMTData);
HRESULT WINAPI
D3DXConvertMeshSubsetToSingleStrip(
LPD3DXBASEMESH MeshIn,
DWORD AttribId,
DWORD IBOptions,
LPDIRECT3DINDEXBUFFER9 *ppIndexBuffer,
DWORD *pNumIndices);
HRESULT WINAPI
D3DXConvertMeshSubsetToStrips(
LPD3DXBASEMESH MeshIn,
DWORD AttribId,
DWORD IBOptions,
LPDIRECT3DINDEXBUFFER9 *ppIndexBuffer,
DWORD *pNumIndices,
LPD3DXBUFFER *ppStripLengths,
DWORD *pNumStrips);
//============================================================================
//
// 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.
//
//============================================================================
HRESULT WINAPI
D3DXOptimizeFaces(
LPCVOID pbIndices,
UINT cFaces,
UINT cVertices,
BOOL b32BitIndices,
DWORD* pFaceRemap);
//============================================================================
//
// 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -