Classes | Public Member Functions

PolyVox::MeshDecimator< VertexType > Class Template Reference

The MeshDecimator reduces the number of triangles in a mesh. More...

#include <MeshDecimator.h>

Collaboration diagram for PolyVox::MeshDecimator< VertexType >:

List of all members.

Classes

struct  InitialVertexMetadata
struct  IntVertex
struct  Triangle

Public Member Functions

 MeshDecimator (const SurfaceMesh< VertexType > *pInputMesh, SurfaceMesh< VertexType > *pOutputMesh, float fEdgeCollapseThreshold=0.95f)
 Constructor.
void execute ()
 Performs the decimation.

Detailed Description

template<typename VertexType>
class PolyVox::MeshDecimator< VertexType >

The MeshDecimator reduces the number of triangles in a mesh.

Meshes generated by the PolyVox surface extractors typically have a very high number of triangles in them. This can pose difficulties both for the rendering storage of such meshes. The MeshDecimator provides a way of reducing the triangle count with minimal visual effect.

The MeshDecimator is based on the principle of edge collapse, and currently works with meshes generated by the SurfaceExtractor or CubicSurfaceExtractor. It does not work with meshes generated by the CubicSurfaceExtractorWithNormals, although this may be addressed in the future. The algorithm iterates over each pair of connected vertices in the mesh and attemps to determine if they can be collapsed into a single vertex.

The main criteria used in deciding whether two vertices can collapse is whether they have the same normal. In the case of the cubic surfaces the normals must be exactly the same, whereas in the case of the Marching Cubes surfaces a threshold is used to determine whether two normals are 'close enough'. Additional constraints apply to vertices which lie on the edges of regions or on the boundary between two regions - these vertices are much less likely to be collapsed.

Given a mesh called 'mesh', you can create a decimated version as follows:

 SurfaceMesh<PositionMaterial> decimatedMesh;
 MeshDecimator<PositionMaterial> decimator(&mesh, &decimatedMesh);
 decimator.execute();

The above applies for a cubic mesh, for a Marching Cubes mesh you need to parametise the MeshDecimator and resulting SurfaceMesh on the 'PositionMaterialNormal' type instead of the 'PositionMaterial' type.

Definition at line 68 of file MeshDecimator.h.


Constructor & Destructor Documentation

template<typename VertexType >
PolyVox::MeshDecimator< VertexType >::MeshDecimator ( const SurfaceMesh< VertexType > *  pInputMesh,
SurfaceMesh< VertexType > *  pOutputMesh,
float  fEdgeCollapseThreshold = 0.95f 
)

Constructor.

Builds a MeshDecimator.

Parameters:
pInputMesh A pointer to the mesh to be decimated.
pOutputMesh A pointer to where the result should be stored. Any existing contents will be deleted.
fEdgeCollapseThreshold This is only use in the case of a Marching Cubes surface and controls how close two normals must be to collapse. The dot product between the normals is computed and compared to this threshold. A threshold of 1.0 means nothing will collapse, a threshold of 0.0 means everything will collapse.

Definition at line 37 of file MeshDecimator.inl.


Member Function Documentation

template<typename VertexType >
void PolyVox::MeshDecimator< VertexType >::execute ( void   ) 

Performs the decimation.

Definition at line 46 of file MeshDecimator.inl.


The documentation for this class was generated from the following files: