SimplificationMesh.SimplificationMesh(Mesh,Int32[],AttributeWeights,Single[]) Constructor (Microsoft.DirectX.Direct3D)

How Do I...?

  • Simplify a Mesh

Creates a new instance of the SimplificationMesh class.


Visual Basic Public Sub New( _
    ByVal mesh As Mesh, _
    ByVal adjacency() As Integer, _
    ByVal vertexAttributeWeights As AttributeWeights, _
    ByVal vertexWeights() As Single _
C# public SimplificationMesh(
    Mesh mesh,
    int[] adjacency,
    AttributeWeights vertexAttributeWeights,
    float[] vertexWeights
C++ public:
    array<int>^ adjacency,
    AttributeWeights vertexAttributeWeights,
    array<float>^ vertexWeights
JScript public function SimplificationMesh(
    mesh : Mesh,
    adjacency : int[],
    vertexAttributeWeights : AttributeWeights,
    vertexWeights : float[]


mesh Microsoft.DirectX.Direct3D.Mesh
A Mesh object that represents the mesh to simplify.
adjacency System.Int32[]
Array of three Int32Leave Site values per face that specify the three neighbors for each face in the created simplification mesh.
vertexAttributeWeights Microsoft.DirectX.Direct3D.AttributeWeights
An param_AttributeWeights_vertexAttributeWeights object that contains the weight for each vertex component. If this parameter is omitted, a default structure is used. See Remarks.
vertexWeights System.Single[]
Array of vertex weights. If this parameter is omitted, all vertex weights are set to 1.0. Note that the higher the vertex weight is for a given vertex, the less likely it is to be simplified away.


If param_AttributeWeights_vertexAttributeWeights is omitted, the following values are assigned to the default AttributeWeights structure (C# code shown).

AttributeWeights aWeights;

aWeights.Position  = 1.0;
aWeights.Boundary =  1.0;
aWeights.Normal   =  1.0;
aWeights.Diffuse  =  0.0;
aWeights.Specular =  0.0;
aWeights.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 do the other member fields need to be modified.



The method call is invalid. For example, a method's parameter might contain an invalid value.


Attribute sort is not supported as an optimization technique.

OutOfMemoryExceptionLeave Site

Microsoft Direct3D could not allocate sufficient memory to complete the call.

How Do I...?

Simplify a Mesh

This example demonstrates how to simplify a mesh.

The mesh is simplified by 25 vertices.

In the following C# code example, mesh is assumed to be a Mesh instance that has been properly loaded and cleaned, adjacency is a GraphicsStream instance that contains the mesh adjacency data, and device is the rendering Device.


SimplificationMesh simplifiedMesh = new SimplificationMesh(mesh, adjacency);

simplifiedMesh.ReduceVertices(mesh.NumberVertices - 25);

mesh = simplifiedMesh.Clone(simplifiedMesh.Options.Value, 
                            simplifiedMesh.VertexFormat, device);