Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ogre::ProgressiveMesh Class Reference

This class reduces the complexity of the geometry it is given. More...

#include <OgreProgressiveMesh.h>

Collaboration diagram for Ogre::ProgressiveMesh:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::vector< IndexData * > LODFaceList
enum  VertexReductionQuota { VRQ_CONSTANT, VRQ_PROPORTIONAL }
 The way to derive the quota of vertices which are reduced at each LOD. More...


Public Methods

 ProgressiveMesh (const VertexData *vertexData, const IndexData *indexData)
 Constructor, takes the geometry data and index buffer.

virtual ~ProgressiveMesh ()
virtual void addExtraVertexPositionBuffer (const VertexData *vertexData)
 Adds an extra vertex position buffer.

virtual void build (ushort numLevels, LODFaceList *outList, VertexReductionQuota quota=VRQ_PROPORTIONAL, Real reductionValue=0.5f)
 Builds the progressive mesh with the specified number of levels.


Protected Types

typedef std::vector< PMTriangleTriangleList
typedef std::vector< PMFaceVertexFaceVertexList
typedef std::vector< PMVertexCommonVertexList
typedef std::vector< RealWorstCostList
typedef std::vector< PMWorkingDataWorkingDataList

Protected Methods

void addWorkingData (const VertexData *vertexData, const IndexData *indexData)
 Internal method for building PMWorkingData from geometry data.

void initialiseEdgeCollapseCosts (void)
 Internal method for initialising the edge collapse costs.

Real computeEdgeCollapseCost (PMVertex *src, PMVertex *dest)
 Internal calculation method for deriving a collapse cost from u to v.

Real computeEdgeCostAtVertexForBuffer (WorkingDataList::iterator idata, size_t vertIndex)
 Internal method evaluates all collapse costs from this vertex and picks the lowest for a single buffer.

void computeEdgeCostAtVertex (size_t vertIndex)
 Internal method evaluates all collapse costs from this vertex for every buffer and returns the worst.

void computeAllCosts (void)
 Internal method to compute edge collapse costs for all buffers /.

size_t getNextCollapser (void)
 Internal method for getting the index of next best vertex to collapse.

void bakeNewLOD (IndexData *pData)
 Internal method builds an new LOD based on the current state.

void collapse (PMVertex *collapser)
 Internal method, collapses vertex onto it's saved collapse target.

void dumpContents (const String &log)
 Internal debugging method.


Protected Attributes

const VertexDatampVertexData
const IndexDatampIndexData
size_t mCurrNumIndexes
size_t mNumCommonVertices
WorkingDataList mWorkingData
 Multiple copies, 1 per vertex buffer.

WorstCostList mWorstCosts
 The worst collapse cost from all vertex buffers for each vertex.


Detailed Description

This class reduces the complexity of the geometry it is given.

This class is dedicated to reducing the number of triangles in a given mesh taking into account seams in both geometry and texture co-ordinates and meshes which have multiple frames.

The primary use for this is generating LOD versions of Mesh objects, but it can be used by any geometry provider. The only limitation at the moment is that the provider uses a common vertex buffer for all LODs and one index buffer per LOD. Therefore at the moment this class can only handle indexed geometry.

NB the interface of this class will certainly change when compiled vertex buffers are supported.

Definition at line 55 of file OgreProgressiveMesh.h.


Member Typedef Documentation

typedef std::vector<PMVertex> Ogre::ProgressiveMesh::CommonVertexList [protected]
 

Definition at line 183 of file OgreProgressiveMesh.h.

typedef std::vector<PMFaceVertex> Ogre::ProgressiveMesh::FaceVertexList [protected]
 

Definition at line 182 of file OgreProgressiveMesh.h.

typedef std::vector<IndexData*> Ogre::ProgressiveMesh::LODFaceList
 

Definition at line 68 of file OgreProgressiveMesh.h.

typedef std::vector<PMTriangle> Ogre::ProgressiveMesh::TriangleList [protected]
 

Definition at line 181 of file OgreProgressiveMesh.h.

typedef std::vector<PMWorkingData> Ogre::ProgressiveMesh::WorkingDataList [protected]
 

Definition at line 194 of file OgreProgressiveMesh.h.

typedef std::vector<Real> Ogre::ProgressiveMesh::WorstCostList [protected]
 

Definition at line 184 of file OgreProgressiveMesh.h.


Member Enumeration Documentation

enum Ogre::ProgressiveMesh::VertexReductionQuota
 

The way to derive the quota of vertices which are reduced at each LOD.

Enumeration values:
VRQ_CONSTANT  A set number of vertices are removed at each reduction.
VRQ_PROPORTIONAL  A proportion of the remaining number of vertices are removed at each reduction.

Definition at line 60 of file OgreProgressiveMesh.h.


Constructor & Destructor Documentation

Ogre::ProgressiveMesh::ProgressiveMesh const VertexData   vertexData,
const IndexData   indexData
 

Constructor, takes the geometry data and index buffer.

Remarks:
DO NOT pass write-only, unshadowed buffers to this method! They will not work. Pass only shadowed buffers, or better yet perform mesh reduction as an offline process using DefaultHardwareBufferManager to manage vertex buffers in system memory.

Definition at line 62 of file OgreProgressiveMesh.cpp.

References addWorkingData(), mpIndexData, mpVertexData, mWorstCosts, and Ogre::VertexData::vertexCount.

Ogre::ProgressiveMesh::~ProgressiveMesh   [virtual]
 

Definition at line 74 of file OgreProgressiveMesh.cpp.


Member Function Documentation

void Ogre::ProgressiveMesh::addExtraVertexPositionBuffer const VertexData   vertexData [virtual]
 

Adds an extra vertex position buffer.

Remarks:
As well as the main vertex buffer, the client of this class may add extra versions of the vertex buffer which will also be taken into account when the cost of simplifying the mesh is taken into account. This is because the cost of simplifying an animated mesh cannot be calculated from just the reference position, multiple positions needs to be assessed in order to find the best simplification option.

DO NOT pass write-only, unshadowed buffers to this method! They will not work. Pass only shadowed buffers, or better yet perform mesh reduction as an offline process using DefaultHardwareBufferManager to manage vertex buffers in system memory.

Parameters:
buffer  Pointer to x/y/z buffer with vertex positions. The number of vertices must be the same as in the original GeometryData passed to the constructor.

Definition at line 78 of file OgreProgressiveMesh.cpp.

References addWorkingData(), and mpIndexData.

void Ogre::ProgressiveMesh::addWorkingData const VertexData   vertexData,
const IndexData   indexData
[protected]
 

Internal method for building PMWorkingData from geometry data.

Definition at line 172 of file OgreProgressiveMesh.cpp.

References Ogre::VertexElement::baseVertexPointerToElement(), Ogre::VertexDeclaration::findElementBySemantic(), Ogre::VertexBufferBinding::getBuffer(), Ogre::VertexElement::getSource(), Ogre::IndexData::indexBuffer, Ogre::IndexData::indexCount, Ogre::ProgressiveMesh::PMWorkingData::mFaceVertList, mNumCommonVertices, Ogre::ProgressiveMesh::PMWorkingData::mTriList, Ogre::ProgressiveMesh::PMWorkingData::mVertList, mWorkingData, Ogre::Real, Ogre::ProgressiveMesh::PMVertex::removed, Ogre::ProgressiveMesh::PMVertex::seam, Ogre::ProgressiveMesh::PMVertex::setDetails(), Ogre::ProgressiveMesh::PMVertex::toBeRemoved, Ogre::VertexData::vertexBufferBinding, Ogre::VertexData::vertexCount, Ogre::VertexData::vertexDeclaration, Ogre::VES_POSITION, Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z.

Referenced by addExtraVertexPositionBuffer(), and ProgressiveMesh().

void Ogre::ProgressiveMesh::bakeNewLOD IndexData   pData [protected]
 

Internal method builds an new LOD based on the current state.

Definition at line 656 of file OgreProgressiveMesh.cpp.

References Ogre::IndexData::indexBuffer, Ogre::IndexData::indexCount, Ogre::IndexData::indexStart, mCurrNumIndexes, mpIndexData, and mWorkingData.

Referenced by build().

void Ogre::ProgressiveMesh::build ushort    numLevels,
LODFaceList   outList,
VertexReductionQuota    quota = VRQ_PROPORTIONAL,
Real    reductionValue = 0.5f
[virtual]
 

Builds the progressive mesh with the specified number of levels.

Parameters:
numLevels  The number of levels to include in the output excluding the full detail version.
outList  Pointer to a list of LOD geometry data which will be completed by the application. Each entry is a reduced form of the mesh, in decreasing order of detail.
quota  The way to derive the number of vertices removed at each LOD
reductionValue  Either the proportion of vertices to remove at each level, or a fixed number of vertices to remove at each level, depending on the value of quota

Definition at line 83 of file OgreProgressiveMesh.cpp.

References bakeNewLOD(), collapse(), Ogre::ProgressiveMesh::PMVertex::collapseTo, computeAllCosts(), dumpContents(), getNextCollapser(), Ogre::ProgressiveMesh::PMVertex::index, Ogre::IndexData::indexCount, Ogre::ProgressiveMesh::PMVertex::isBorder(), mCurrNumIndexes, mNumCommonVertices, mpIndexData, mWorkingData, Ogre::Real, Ogre::ProgressiveMesh::PMVertex::removed, Ogre::ushort, and VRQ_PROPORTIONAL.

Referenced by Ogre::Mesh::generateLodLevels().

void Ogre::ProgressiveMesh::collapse PMVertex   collapser [protected]
 

Internal method, collapses vertex onto it's saved collapse target.

Remarks:
This updates the working triangle list to drop a triangle and recalculates the edge collapse costs around the collapse target. This also updates all the working vertex lists for the relevant buffer.

Definition at line 507 of file OgreProgressiveMesh.cpp.

References Ogre::ProgressiveMesh::PMVertex::collapseCost, Ogre::ProgressiveMesh::PMVertex::collapseTo, computeEdgeCostAtVertex(), Ogre::ProgressiveMesh::PMVertex::face, Ogre::ProgressiveMesh::PMVertex::index, mCurrNumIndexes, mWorstCosts, Ogre::ProgressiveMesh::PMVertex::neighbor, NEVER_COLLAPSE_COST, Ogre::ProgressiveMesh::PMVertex::notifyRemoved(), and Ogre::ProgressiveMesh::PMVertex::toBeRemoved.

Referenced by build().

void Ogre::ProgressiveMesh::computeAllCosts void    [protected]
 

Internal method to compute edge collapse costs for all buffers /.

Definition at line 497 of file OgreProgressiveMesh.cpp.

References computeEdgeCostAtVertex(), initialiseEdgeCollapseCosts(), mpVertexData, and Ogre::VertexData::vertexCount.

Referenced by build().

Real Ogre::ProgressiveMesh::computeEdgeCollapseCost PMVertex   src,
PMVertex   dest
[protected]
 

Internal calculation method for deriving a collapse cost from u to v.

Definition at line 282 of file OgreProgressiveMesh.cpp.

References Ogre::Vector3::dotProduct(), Ogre::ProgressiveMesh::PMVertex::face, Ogre::ProgressiveMesh::PMVertex::isBorder(), Ogre::ProgressiveMesh::PMVertex::isManifoldEdgeWith(), Ogre::ProgressiveMesh::PMVertex::neighbor, NEVER_COLLAPSE_COST, Ogre::Vector3::normalise(), Ogre::ProgressiveMesh::PMVertex::position, Ogre::Real, and Ogre::ProgressiveMesh::PMVertex::seam.

Referenced by computeEdgeCostAtVertexForBuffer().

void Ogre::ProgressiveMesh::computeEdgeCostAtVertex size_t    vertIndex [protected]
 

Internal method evaluates all collapse costs from this vertex for every buffer and returns the worst.

Definition at line 623 of file OgreProgressiveMesh.cpp.

References computeEdgeCostAtVertexForBuffer(), mWorkingData, mWorstCosts, and Ogre::Real.

Referenced by collapse(), and computeAllCosts().

Real Ogre::ProgressiveMesh::computeEdgeCostAtVertexForBuffer WorkingDataList::iterator    idata,
size_t    vertIndex
[protected]
 

Internal method evaluates all collapse costs from this vertex and picks the lowest for a single buffer.

Definition at line 458 of file OgreProgressiveMesh.cpp.

References computeEdgeCollapseCost(), NEVER_COLLAPSE_COST, and Ogre::Real.

Referenced by computeEdgeCostAtVertex().

void Ogre::ProgressiveMesh::dumpContents const String   log [protected]
 

Internal debugging method.

Definition at line 932 of file OgreProgressiveMesh.cpp.

References mNumCommonVertices, mWorkingData, and mWorstCosts.

Referenced by build().

size_t Ogre::ProgressiveMesh::getNextCollapser void    [protected]
 

Internal method for getting the index of next best vertex to collapse.

Definition at line 638 of file OgreProgressiveMesh.cpp.

References mNumCommonVertices, mWorstCosts, NEVER_COLLAPSE_COST, and Ogre::Real.

Referenced by build().

void Ogre::ProgressiveMesh::initialiseEdgeCollapseCosts void    [protected]
 

Internal method for initialising the edge collapse costs.

Definition at line 440 of file OgreProgressiveMesh.cpp.

References mWorkingData, and NEVER_COLLAPSE_COST.

Referenced by computeAllCosts().


Member Data Documentation

size_t Ogre::ProgressiveMesh::mCurrNumIndexes [protected]
 

Definition at line 112 of file OgreProgressiveMesh.h.

Referenced by bakeNewLOD(), build(), and collapse().

size_t Ogre::ProgressiveMesh::mNumCommonVertices [protected]
 

Definition at line 113 of file OgreProgressiveMesh.h.

Referenced by addWorkingData(), build(), dumpContents(), and getNextCollapser().

const IndexData* Ogre::ProgressiveMesh::mpIndexData [protected]
 

Definition at line 110 of file OgreProgressiveMesh.h.

Referenced by addExtraVertexPositionBuffer(), bakeNewLOD(), build(), and ProgressiveMesh().

const VertexData* Ogre::ProgressiveMesh::mpVertexData [protected]
 

Definition at line 109 of file OgreProgressiveMesh.h.

Referenced by computeAllCosts(), and ProgressiveMesh().

WorkingDataList Ogre::ProgressiveMesh::mWorkingData [protected]
 

Multiple copies, 1 per vertex buffer.

Definition at line 196 of file OgreProgressiveMesh.h.

Referenced by addWorkingData(), bakeNewLOD(), build(), computeEdgeCostAtVertex(), dumpContents(), and initialiseEdgeCollapseCosts().

WorstCostList Ogre::ProgressiveMesh::mWorstCosts [protected]
 

The worst collapse cost from all vertex buffers for each vertex.

Definition at line 199 of file OgreProgressiveMesh.h.

Referenced by collapse(), computeEdgeCostAtVertex(), dumpContents(), getNextCollapser(), and ProgressiveMesh().


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

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:19:18 2004