Microsoft DirectX 8.1 (Visual Basic)

D3DX8.GeneratePMesh

Generates a progressive mesh.

object.GeneratePMesh( _ 
    Mesh As D3DXMesh, _ 
    Adjacency As Any, _ 
    VertexAttributeWeights As Any, _ 
    VertexWeights As Any, _ 
    MinValue As Long, _ 
    Options As Long) As D3DXPMesh

Parts

object
Object expression that resolves to a D3DX8 object.
Mesh
D3DXMesh object, representing the source mesh.
Adjacency
First element of an array of three Long values per face that specify the three neighbors for each face in the created progressive mesh.
VertexAttributeWeights
a D3DXATTRIBUTEWEIGHTS type, containing the weight for each vertex component. If this parameter is set to ByVal 0, a default type is used. See Remarks.
VertexWeights
First element of an array of vertex weights. If this parameter is set to ByVal 0, all vertex weights are set to 1.0. Note that the higher the vertex weight for a given vertex, the less likely it is to be simplified away.
MinValue
Number of vertices or faces, depending on the which flag is set in the Options parameter, by which to simplify the source mesh.
Options
Specifies simplification options for the mesh. One of the following flags defined by the CONST_D3DXMESHSIMP enumeration can be set.

Return Values

D3DXPMesh object, representing the created progressive mesh.

Error Codes

If the method fails, an error is raised and Err.Number can be set to one of the following values.

D3DERR_INVALIDCALL
D3DXERR_CANNOTATTRSORT
E_OUTOFMEMORY

For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.

Remarks

This method generates a mesh where the level of detail (LOD) can be adjusted from the current value to the MinValue.

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 VertexAttributeWeights is set to ByVal 0, the values are assigned according to the default D3DXATTRIBUTEWEIGHTS type.

Dim AttribruteWeights As D3DXATTRIBUTEWEIGHTS
With _
.position = 1
.Boundary = 1
.Normal = 1
.diffuse = 0
.specular = 0
.Tex(7) = 0
End With

This default type 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 following code fragment shows how to use a D3DXBuffer object to pass adjacency information.

Dim Mesh As D3DXMesh
Dim D3DXbAdjacency As D3DXBuffer
Dim VAttWeights As Any
Dim VWeights As Any
Dim MinV As Long
Dim Opts As Long

' This code fragment assumes that all arguments
' have been properly initialized.
Call D3DX8.GeneratePMesh(Mesh, ByVal D3DXbAdjacency.GetBufferPointer, VAttWeights, Vweights, MinV, Opts )