| VRS - The Virtual Rendering System |
| version 3.3 |
#include <vrs/progressivemesh.h>

| VRS::ProgressiveMesh::ProgressiveMesh | ( | const PolygonSet * | source = 0, |
|
| LoDControlMode | mode = ProgressiveMesh::ViewDependent, |
|||
| double | vertexPairTreshold = 0.0, |
|||
| bool | preserveTopology = true, |
|||
| PlacementPolicy | placement = ProgressiveMesh::Subset | |||
| ) |
A progressive mesh is a datastructure that allows the usage of a large number of representations of a given triangle mesh at different levels of detail. These different representations can be used to accelerate the rendering process by choosing a mesh of appropriate complexity for given view conditions at runtime.
The triangle mesh is specified by an instance of the class PolygonSet. By default, a progressive mesh is in ViewDependent mode, i.e. the complexity of the used mesh representation is controlled automatically according to the current view conditions and a given screen space tolerance specified using the method setScreenSpaceErrorTolerance(). In the ViewIndipendent mode the mesh complexity can be controlled directly using the methods split() and collapse(). The ViewDependentAndSelective allows to perform the simplify different regions of the mesh surface independently. For that, additional information is required. Therefore the memory requirement of a PM in ViewDependentAndSelective mode is higher than that of a PM in another mode.
The creation of a PM representation is only possible for triangle meshes. Since a PolygonSet can contain primitves of several different types, the data is converted into a single triangle mesh at first. Only primitves that allow a conversion into triangles (i.e. primitives of the types Triangles, TriangleStrip, TriangleFan, Quads, QuadStrip and ConvexFace) are taken into account. Primitives of other types are ignored.
Usually the construction of a PM takes O(nlog n) time and O(n) of storage, where n is the number of triangles of the input mesh. Using the threshold parameter can raise these requirements. (see below)
In the following the optional constructor parameters are explained. Note that they serves only to fit special user requirements and can usually be left out:
If the parameter is set to "ViewDependentAndSelective", the neccesary data for selective simplification will be calculated. Since PMs in ViewDependent and PMs in ViewDependentAndSelective mode need different additional data, it is not possible to switch between ViewDependent and ViewDependentAndSelective at runtime. In addition a PM suited for ViewDependentAndSelective mode can only be created from meshes with valid topology and if the topology has been preserved. If the creation of a PM for "ViewDependentAndSelective" mode is impossible, a PM for "ViewDependent" mode will be created.
If you set the mode parameter to "ViewDependentAndSelective", the other parameters are set automatically: Since preserved topology is needed, vertexPairThreshold is set to 0, preserveTopology is set to true. Since the memory requirements of a "ViewDependentAndSelective" PM is clearly higher than that of a "ViewDependent" one, the former is implemented only for subset placement to reduce the size in memory.
If you want to use vertex-pair contraction, be careful with the choice of the threshold parameter. Setting the parameter too high will cause the algorithm to take too much vertex pairs into account. If the threshold exceeds the maximum of all vertex distances of the model, memory and time requirements will increase to O(n^2).
Note: If the input mesh does not fulfill the topological requirements, the flag is automatically set to false. You can check the result by using the hasPreservedTopology() method after the creation of the ProgressiveMesh.
If the input mesh contains texture coordinates the placementPolicy parameter is automatically set to "Subset". Since texture coordinates are not explicitly considered during the simplification, process, using optimal placement would increase the texture stretch due to the geometric simplification.
| virtual VRS::ProgressiveMesh::~ProgressiveMesh | ( | ) | [virtual] |
| VRS::ProgressiveMesh::VRS_SERIALIZABLE_CLASS_ENUM | ( | LoDControlMode | ) |
| VRS::ProgressiveMesh::VRS_SERIALIZABLE_CLASS_ENUM | ( | PlacementPolicy | ) |
| void VRS::ProgressiveMesh::setMode | ( | LoDControlMode | mode | ) |
| LoDControlMode VRS::ProgressiveMesh::getMode | ( | ) | const |
If the ProgressiveMesh is in "ViewIndipendent" mode, you can choose the level of detail manually. In the "ViewDependent" mode the level of detail is choosen automatically according to the specified screen-space error tolerance and the current viewing conditions.
| void VRS::ProgressiveMesh::setMaxDetail | ( | ) |
| void VRS::ProgressiveMesh::setMinDetail | ( | ) |
The following methods serve to control the level of detail manually. They only take effect if the mesh is in ViewIndipendent mode.
| bool VRS::ProgressiveMesh::split | ( | UINT | steps = 1 |
) |
| bool VRS::ProgressiveMesh::collapse | ( | UINT | steps = 1 |
) |
| void VRS::ProgressiveMesh::setScreenSpaceErrorTolerance | ( | double | t | ) |
| double VRS::ProgressiveMesh::getScreenSpaceErrorTolerance | ( | ) | const |
These methods are only useful in "ViewDependent" mode. The tolerance parameter t specifies the maximum distance between the simplified mesh and the full detailed mesh. More exactly, the meaning of the parameter t is as follows: Let p the screen projection of an arbitrary point on the surface of the full detailed mesh under the given viewing conditions. The level of detail is choosen, so that the distance between p and the screen projection of the simplified mesh is only less than t. Note that the exact calculation of the screen-space geometric error is too expensive, so the above mentioned condition is only achieved approximately.
| PolygonSet* VRS::ProgressiveMesh::getSnapshot | ( | ) | const |
Returns a copy of the mesh in the current state in the form of a PolygonSet
| UINT VRS::ProgressiveMesh::getDetailLevel | ( | ) | const |
| UINT VRS::ProgressiveMesh::getMaxDetailLevel | ( | ) | const |
Returns the current state of the mesh. The return value is 0 for the base mesh and the return value of getMaxDetailLevel() for the full-detail state.
| UINT VRS::ProgressiveMesh::getNumActiveVertices | ( | ) | const |
| UINT VRS::ProgressiveMesh::getNumActiveTriangles | ( | ) | const |
| UINT VRS::ProgressiveMesh::getNumVertices | ( | ) | const |
| UINT VRS::ProgressiveMesh::getNumTriangles | ( | ) | const |
Return the number of vertices and triangles of the mesh in the current state or of the full detailed model.
| bool VRS::ProgressiveMesh::hasPreservedTopology | ( | ) | const |
| PlacementPolicy VRS::ProgressiveMesh::getPlacementPolicy | ( | ) | const |
The following methods allow to query some parameters used during the precalculation. The results of these methods possibly differ from your given constructor parameters. See constructor comments for more information.
| bool VRS::ProgressiveMesh::consistent | ( | ) | const |
| UINT VRS::ProgressiveMesh::getNumBoundaryVertices | ( | ) | const |
| UINT VRS::ProgressiveMesh::getNumBoundaryEdges | ( | ) | const |
Some methods to query certain results of the topological analysis of the original data (i.e. the mesh specified by the source parameter of the constructor).
access to the data of the mesh represented in the current state.
| void VRS::ProgressiveMesh::setRefinementSpeed | ( | UINT | frames = 5 |
) |
| UINT VRS::ProgressiveMesh::getRefinementSpeed | ( | ) | const |
since the process of selective refinement can possibly be time consuming, it can be distributed over several consecutive frames in order to trade quality for speed. By default, speed is set to 5, i.e. the refinement process is distributed over 5 frames. The methods takes only effect in ViewDependentAndSelective mode. Since the update process is less time consuming in ViewDependent mode, it is always performed once per frame. The parameter "frames" must lie between 0 and 100. Setting "frames" to 0 freezes the mesh in its current state, i.e. stops the automatic refinement/simplification.
| void VRS::ProgressiveMesh::adaptLevelOfDetail | ( | Engine * | E | ) |
this method is called by the simplifier
| virtual Bounds VRS::ProgressiveMesh::boundingBox | ( | ) | const [virtual] |
| VRS::ProgressiveMesh::VRS_TYPEINFO | ( | ProgressiveMesh | , | |
| Shape | ||||
| ) |
| VRS::ProgressiveMesh::VRS_SERIALIZABLE | ( | ProgressiveMesh | ) |