D3DXSimplifyMesh function

Generates a simplified mesh using the provided weights that come as close as possible to the given MinValue.

Syntax

HRESULT D3DXSimplifyMesh(
  _In_        LPD3DXMESH           pMesh,
  _In_  const DWORD                *pAdjacency,
  _In_  const D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights,
  _In_  const FLOAT                *pVertexWeights,
  _In_        DWORD                MinValue,
  _In_        DWORD                Options,
  _Out_       LPD3DXMESH           *ppMesh
);

Parameters

pMesh [in]

Type: LPD3DXMESH

Pointer to an ID3DXMesh interface, representing the source mesh.

pAdjacency [in]

Type: const DWORD*

Pointer to an array of three DWORDs per face that specify the three neighbors for each face in the mesh to be simplified.

pVertexAttributeWeights [in]

Type: const D3DXATTRIBUTEWEIGHTS*

Pointer to a D3DXATTRIBUTEWEIGHTS structure, containing the weight for each vertex component. If this parameter is set to NULL, a default structure is used. See Remarks.

pVertexWeights [in]

Type: const FLOAT*

Pointer to an array of vertex weights. If this parameter is set to NULL, all vertex weights are set to 1.0.

MinValue [in]

Type: DWORD

Number of vertices or faces, depending on the flag set in the Options parameter, by which to simplify the source mesh.

Options [in]

Type: DWORD

Specifies simplification options for the mesh. One of the flags in D3DXMESHSIMP can be set.

ppMesh [out]

Type: LPD3DXMESH*

Address of a pointer to an ID3DXMesh interface, representing the returned simplification mesh.

Return value

Type: HRESULT

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Remarks

This function generates a mesh that has MinValue vertices or faces.

If the simplification process cannot reduce the mesh to MinValue, the call still succeeds because MinValue is a desired minimum, not an absolute minimum.

If pVertexAttributeWeights is set to NULL, the following values are assigned to the default D3DXATTRIBUTEWEIGHTS structure.

D3DXATTRIBUTEWEIGHTS AttributeWeights;
    
AttributeWeights.Position  = 1.0;
AttributeWeights.Boundary =  1.0;
AttributeWeights.Normal   =  1.0;
AttributeWeights.Diffuse  =  0.0;
AttributeWeights.Specular =  0.0;
AttributeWeights.Tex[8]   =  {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};

This default structure is what most applications should use because it considers only geometric and normal adjustment. Only in special cases will the other member fields need to be modified.

Requirements

Requirement Value
Header
D3DX9Mesh.h
Library
D3dx9.lib

See also

Mesh Functions