public

Inheritance Graph

graph BT
	Mesh
	Mesh --> ReferenceCounter
	click Mesh "classRendering_1_1Mesh"
	click ReferenceCounter "classUtil_1_1ReferenceCounter"

Description

Class for polygonal meshes. A mesh consisting of four components:

  • MeshVertexData : The vertices of the mesh stored in local and/or graphics memory

  • MeshIndexData : The indices of the used vertices stored in local and/or graphics memory

  • DataStrategy: A strategy that determines where the data is stored and how the mesh is rendered (e.g. as VBO or VertexArray)

  • Filename: (optional) The filename from which the mesh was loaded.

Create a new mesh:

Mesh * mesh = new Mesh;                         // create a mesh

MeshIndexData & id = mesh->openMeshIndexData();   // get access to index data
id.allocate(numberOfIndices);                     // allocate memory for indices (using triangles)
for(uint32_t i = 0; i < numberOfIndices; ++i) {
    id[i] = someIndex(...);                       // access the indices
}
id.updateIndexRange();                            // recalculate index range

MeshVertexData & vd = mesh->openMeshVertexData(); // get access to vertex data
VertexDescription desc;                           // create a vertexDescription
vd.allocate(numberOfVertices);                    // allocate memory for vertices
uint8_t * binaryMeshVertexData = vd.data();       // access the vertices
createMeshVertexData(...);
vd.updateBoundingBox();                           // recalculate bounding box

Note: After an existing mesh has been changed, vd.markAsChanged() and id.markAsChanged() have to be called so that the VBO can be updated. After allocate(…) this is not necessary.

Main

   
   
  Mesh()
   
  Mesh( MeshIndexData meshIndexData, MeshVertexData meshVertexData)
   
  Mesh(const VertexDescription & desc, uint32_t vertexCount, uint32_t indexCount)
   
  Mesh(const Mesh & void)
   
  Mesh( Mesh && void)
   
Mesh * clone() const
   
void swap( Mesh & m)
   
size_t getMainMemoryUsage() const
   
size_t getGraphicsMemoryUsage() const
   
bool empty() const
   
void _display( RenderingContext & context, uint32_t firstElement, uint32_t elementCount)
   
uint32_t getPrimitiveCount(uint32_t numElements) const

MeshIndexData

   
   
MeshIndexData & _getIndexData()
   
const MeshIndexData & _getIndexData() const
   
MeshIndexData & openIndexData()
   
uint32_t getIndexCount() const
   
bool isUsingIndexData() const
If useIndexData is false, the mesh’s indexData.
   
void setUseIndexData(const bool b)

Filename

   
   
const Util::FileName & getFileName() const
   
void setFileName(const Util::FileName & f)

MeshVertexData

   
   
MeshVertexData & _getVertexData()
   
const MeshVertexData & _getVertexData() const
   
MeshVertexData & openVertexData()
   
uint32_t getVertexCount() const
   
const VertexDescription & getVertexDescription() const
   
const Geometry::Box & getBoundingBox() const

DataStrategy

   
   
MeshDataStrategy * getDataStrategy() const
Return the current data strategy.
   
void setDataStrategy( MeshDataStrategy * newStrategy)
Set a new data strategy.

DrawMode

   
   
enum draw_mode_t {DRAW_POINTS, DRAW_LINE_STRIP, DRAW_LINE_LOOP, DRAW_LINES, DRAW_TRIANGLES}
   
draw_mode_t getDrawMode() const
   
void setDrawMode( draw_mode_t newMode)
   
uint32_t getGLDrawMode() const
   
void setGLDrawMode(uint32_t glDrawMode)

Documentation

function
Rendering::Mesh::Mesh

public
   
   
Mesh( )

Defined in Rendering/Mesh/Mesh.h:75


function
Rendering::Mesh::Mesh

public
     
     
Mesh( MeshIndexData meshIndexData,
  MeshVertexData meshVertexData
)    

Defined in Rendering/Mesh/Mesh.h:76


function
Rendering::Mesh::Mesh

public
     
     
Mesh( const VertexDescription & desc,
  uint32_t vertexCount,
  uint32_t indexCount
)    

Defined in Rendering/Mesh/Mesh.h:77


function
Rendering::Mesh::Mesh

public
     
     
Mesh( const Mesh & void )

Defined in Rendering/Mesh/Mesh.h:78


function
Rendering::Mesh::Mesh

public
     
     
Mesh( Mesh && void )

Defined in Rendering/Mesh/Mesh.h:79


function
Rendering::Mesh::clone

public const
   
   
Mesh * clone( ) const

Defined in Rendering/Mesh/Mesh.h:81


function
Rendering::Mesh::swap

public
     
     
void swap( Mesh & m )

Defined in Rendering/Mesh/Mesh.h:83


function
Rendering::Mesh::getMainMemoryUsage

public const
   
   
size_t getMainMemoryUsage( ) const

Return the amount of main memory currently occupied by this mesh.

Note: If the mesh data is currently not present in main memory, only a small number is returned (probablysizeof(Mesh)).

Returns

Amount of memory in bytes

Defined in Rendering/Mesh/Mesh.h:91


function
Rendering::Mesh::getGraphicsMemoryUsage

public const
   
   
size_t getGraphicsMemoryUsage( ) const

Return the amount of graphics memory currently occupied by this mesh.

Note: If the mesh data is currently not uploaded to the graphics card, zero is returned.

Returns

Amount of memory in bytes

Defined in Rendering/Mesh/Mesh.h:99


function
Rendering::Mesh::empty

public const inline
   
   
bool empty( ) const

Returns true if no data is set.

Defined in Rendering/Mesh/Mesh.h:102


function
Rendering::Mesh::_display

public
     
     
void _display( RenderingContext & context,
  uint32_t firstElement,
  uint32_t elementCount
)    

Display the mesh as VBO or VertexArray (determined by current data strategy).

  • If the mesh uses indices ( isUsingIndexData() ==true),firstElementandelementCountare the first index and the number of indices to be drawn.

  • If the mesh does not us indices ( isUsingIndexData() ==false),firstElementandelementCountare the first vertex and the number of vertices to be drawn. Calls:> dataStrategy->displayMesh(…)> dataStrategy::doDisplayMesh(…)> vertexData.bind() & indexData.drawElements(…) OR (if no indexData is present) vertexData.drawArray(…)

    Note: AttentionThe function has to be called from within the GL-thread!

Note: Except if you know what you are doing, use renderingContext.displayMesh(mesh) instead.

Defined in Rendering/Mesh/Mesh.h:115


function
Rendering::Mesh::getPrimitiveCount

public const
     
     
uint32_t getPrimitiveCount( uint32_t numElements ) const

Return the number of primitives stored in this mesh. The number depends on the number of indices, the number of vertices, and the draw mode. To retrieve the type of primitives, call getDrawMode() .

Parameters

numElements
If zero, the number of indices or the number of vertices will be used. If non-zero, use the number of elements to do the calculation.

Defined in Rendering/Mesh/Mesh.h:126


function
Rendering::Mesh::_getIndexData

public inline
   
   
MeshIndexData & _getIndexData( )

Returns a reference to the indexData member.

Note: In most cases: openIndexData() is what you want (that why the _ is in the name…)

Defined in Rendering/Mesh/Mesh.h:138


function
Rendering::Mesh::_getIndexData

public const inline
   
   
const MeshIndexData & _getIndexData( ) const

Defined in Rendering/Mesh/Mesh.h:139


function
Rendering::Mesh::openIndexData

public
   
   
MeshIndexData & openIndexData( )

Returns a reference to the indexData member and assures that if the mesh contains index data, this data can be accessed via MeshIndexData.data()

Defined in Rendering/Mesh/Mesh.h:143


function
Rendering::Mesh::getIndexCount

public const inline
   
   
uint32_t getIndexCount( ) const

Defined in Rendering/Mesh/Mesh.h:145


function
Rendering::Mesh::isUsingIndexData

public const inline
   
   
bool isUsingIndexData( ) const

If useIndexData is false, the mesh’s indexData.

Defined in Rendering/Mesh/Mesh.h:150


function
Rendering::Mesh::setUseIndexData

public inline
     
     
void setUseIndexData( const bool b )

Defined in Rendering/Mesh/Mesh.h:151


function
Rendering::Mesh::getFileName

public const inline
   
   
const Util::FileName & getFileName( ) const

Defined in Rendering/Mesh/Mesh.h:160


function
Rendering::Mesh::setFileName

public inline
     
     
void setFileName( const Util::FileName & f )

Defined in Rendering/Mesh/Mesh.h:161


function
Rendering::Mesh::_getVertexData

public inline
   
   
MeshVertexData & _getVertexData( )

Returns a reference to the vertexData member.

Note: In most cases: openVertexData() is what you want (that why the _ is in the name…)

Defined in Rendering/Mesh/Mesh.h:172


function
Rendering::Mesh::_getVertexData

public const inline
   
   
const MeshVertexData & _getVertexData( ) const

Defined in Rendering/Mesh/Mesh.h:173


function
Rendering::Mesh::openVertexData

public
   
   
MeshVertexData & openVertexData( )

Returns a reference to the vertexData member and assures that if the mesh contains vertex data, this data can be accessed via MeshVertexData.data()

Defined in Rendering/Mesh/Mesh.h:177


function
Rendering::Mesh::getVertexCount

public const inline
   
   
uint32_t getVertexCount( ) const

Defined in Rendering/Mesh/Mesh.h:179


function
Rendering::Mesh::getVertexDescription

public const inline
   
   
const VertexDescription & getVertexDescription( ) const

Defined in Rendering/Mesh/Mesh.h:180


function
Rendering::Mesh::getBoundingBox

public const inline
   
   
const Geometry::Box & getBoundingBox( ) const

Defined in Rendering/Mesh/Mesh.h:181


function
Rendering::Mesh::getDataStrategy

public const inline
   
   
MeshDataStrategy * getDataStrategy( ) const

Return the current data strategy.

Defined in Rendering/Mesh/Mesh.h:191


function
Rendering::Mesh::setDataStrategy

public
     
     
void setDataStrategy( MeshDataStrategy * newStrategy )

Set a new data strategy.

Defined in Rendering/Mesh/Mesh.h:196


enum
Rendering::Mesh::draw_mode_t

public
 
 
enum draw_mode_t
Enumerator   Description
Enumerator   Description
DRAW_POINTS   Corresponds toGL_POINTS.
DRAW_LINE_STRIP   Corresponds toGL_LINE_STRIP.
DRAW_LINE_LOOP   Corresponds toGL_LINE_LOOP.
DRAW_LINES   Corresponds toGL_LINES.
DRAW_TRIANGLES   Corresponds toGL_TRIANGLES.

Enumeration of draw modes

See also: parametermodeof functionglDrawElements

Defined in Rendering/Mesh/Mesh.h:212


function
Rendering::Mesh::getDrawMode

public const inline
   
   
draw_mode_t getDrawMode( ) const

Defined in Rendering/Mesh/Mesh.h:227


function
Rendering::Mesh::setDrawMode

public inline
     
     
void setDrawMode( draw_mode_t newMode )

Defined in Rendering/Mesh/Mesh.h:230


function
Rendering::Mesh::getGLDrawMode

public const
   
   
uint32_t getGLDrawMode( ) const

Convert the draw mode to an OpenGL constant.

Parameters

:

Defined in Rendering/Mesh/Mesh.h:243


function
Rendering::Mesh::setGLDrawMode

public
     
     
void setGLDrawMode( uint32_t glDrawMode )

Convert an OpenGL constant to the draw mode. SetdrawModeto

  • DRAW_POINTSifglDrawModeisGL_POINTS

  • DRAW_LINE_STRIPifglDrawModeisGL_LINE_STRIP

  • DRAW_LINE_LOOPifglDrawModeisGL_LINE_LOOP

  • DRAW_LINESifglDrawModeisGL_LINES

  • DRAW_TRIANGLESotherwise

Defined in Rendering/Mesh/Mesh.h:253