ork::MeshBuffers Class Reference
[render]

A set of AttributeBuffer that represent the vertices and indices of a mesh. More...

#include <MeshBuffers.h>

Inheritance diagram for ork::MeshBuffers:
ork::Object

List of all members.

Public Member Functions

 MeshBuffers ()
 Creates a new mesh without any AttributeBuffer.
virtual ~MeshBuffers ()
 Deletes this mesh.
int getAttributeCount () const
 Returns the number of AttributeBuffer in this mesh.
ptr< AttributeBuffergetAttributeBuffer (int index) const
 Returns the AttributeBuffer whose index is given.
ptr< AttributeBuffergetIndiceBuffer () const
 Returns the indices buffer of this mesh.
void addAttributeBuffer (int index, int size, AttributeType type, bool norm)
 Adds a vertex attribute buffer to this mesh.
void addAttributeBuffer (int index, int size, int vertexsize, AttributeType type, bool norm)
 Adds a vertex attribute buffer to this mesh.
void setIndicesBuffer (ptr< AttributeBuffer > indices)
 Sets the indices array buffer of this mesh.
void reset () const
 Resets the internal state associated with this mesh.

Static Public Member Functions

template<class T >
static void setDefaultAttribute (GLuint index, T defaultValue)
 Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.
template<class T >
static void setDefaultAttribute (GLuint index, int count, T *defaultValue, bool normalize=false)
 Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.
template<class T >
static void setDefaultAttributeI (GLuint index, T defaultValue)
 Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.
template<class T >
static void setDefaultAttributeI (GLuint index, int count, T *defaultValue)
 Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.
template<class T >
static void setDefaultAttributeL (GLuint index, T defaultValue)
 Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.
template<class T >
static void setDefaultAttributeL (GLuint index, int count, T *defaultValue)
 Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.
static void setDefaultAttributeP1 (GLuint index, GLuint defaultValue, bool isSigned, bool normalize=false)
 Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.
static void setDefaultAttributeP2 (GLuint index, GLuint defaultValue, bool isSigned, bool normalize=false)
 Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.
static void setDefaultAttributeP3 (GLuint index, GLuint defaultValue, bool isSigned, bool normalize=false)
 Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.
static void setDefaultAttributeP4 (GLuint index, GLuint defaultValue, bool isSigned, bool normalize=false)
 Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.
static void setDefaultAttributeP (GLuint index, int count, GLuint *defaultValue, bool isSigned, bool normalize=false)
 Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.

Public Attributes

MeshMode mode
 How the list of vertices of this mesh must be interpreted.
int nvertices
 The number of vertices in this mesh.
int nindices
 The number of indices in this mesh.
box3f bounds
 The bounding box of this mesh.
GLint primitiveRestart
 The vertex index used for primitive restart.
GLint patchVertices
 The number of vertices per patch of this mesh, if mode is PATCHES.

Protected Member Functions

virtual void swap (ptr< MeshBuffers > buffers)
 Swaps this mesh with the given one.
void draw (MeshMode m, GLint first, GLsizei count, GLsizei primCount=1, GLint base=0) const
 Draws a part of this mesh one or more times.
void multiDraw (MeshMode m, GLint *firsts, GLsizei *counts, GLsizei primCount, GLint *bases=0) const
 Draws several parts of this mesh.
void drawIndirect (MeshMode m, const Buffer &buf) const
 Draws a part of this mesh one or more times.

Protected Attributes

vector< ptr< AttributeBuffer > > attributeBuffers
 The AttributeBuffer of this mesh.

Detailed Description

A set of AttributeBuffer that represent the vertices and indices of a mesh.

Each attribute buffer represents an attribute (position, normal, color, etc) of the vertices of the mesh. A mesh can have an indices array that allows vertices shared between adjacent primitives to be shared in memory. If there is no indices array shared vertices must be duplicated in the vertices array.


Constructor & Destructor Documentation

ork::MeshBuffers::MeshBuffers (  ) 

Creates a new mesh without any AttributeBuffer.

virtual ork::MeshBuffers::~MeshBuffers (  )  [virtual]

Deletes this mesh.


Member Function Documentation

void ork::MeshBuffers::addAttributeBuffer ( int  index,
int  size,
int  vertexsize,
AttributeType  type,
bool  norm 
)

Adds a vertex attribute buffer to this mesh.

This method assumes that this vertex attribute is stored interleaved with others in a shared buffer. For instance, for a mesh with a position, normal and color attributes, the data layout is position, normal and color of first vertex, position, normal and color of second vertex, and so on for other vertices.

Parameters:
index a vertex attribute index.
size the number of components in attributes of this kind.
vertexsize the total size of all the vertex attributes.
type the type of each component in attributes of this kind.
norm if the attribute components must be normalized to 0..1.
void ork::MeshBuffers::addAttributeBuffer ( int  index,
int  size,
AttributeType  type,
bool  norm 
)

Adds a vertex attribute buffer to this mesh.

This method assumes that this vertex attribute is stored in its own buffer.

Parameters:
index a vertex attribute index.
size the number of components in attributes of this kind.
type the type of each component in attributes of this kind.
norm if the attribute components must be normalized to 0..1.
void ork::MeshBuffers::draw ( MeshMode  m,
GLint  first,
GLsizei  count,
GLsizei  primCount = 1,
GLint  base = 0 
) const [protected]

Draws a part of this mesh one or more times.

Parameters:
m how the mesh vertices must be interpreted.
first the first vertex to draw, or the first indice to draw if this mesh has indices.
count the number of vertices to draw, or the number of indices to draw if this mesh has indices.
primCount the number of times this mesh must be drawn (with geometry instancing).
base the base vertex to use. Only used for meshes with indices.
void ork::MeshBuffers::drawIndirect ( MeshMode  m,
const Buffer buf 
) const [protected]

Draws a part of this mesh one or more times.

Parameters:
m how the mesh vertices must be interpreted.
buf a CPU or GPU buffer containing the 'count', 'primCount', 'first' and 'base' parameters, in this order, as 32 bit integers.
ptr<AttributeBuffer> ork::MeshBuffers::getAttributeBuffer ( int  index  )  const

Returns the AttributeBuffer whose index is given.

Parameters:
index an index between 0 and getAttributeCount (exclusive).
int ork::MeshBuffers::getAttributeCount (  )  const

Returns the number of AttributeBuffer in this mesh.

This is the number of attributes per vertex.

ptr<AttributeBuffer> ork::MeshBuffers::getIndiceBuffer (  )  const

Returns the indices buffer of this mesh.

void ork::MeshBuffers::multiDraw ( MeshMode  m,
GLint *  firsts,
GLsizei *  counts,
GLsizei  primCount,
GLint *  bases = 0 
) const [protected]

Draws several parts of this mesh.

Each part is specified with a first and count parameter as in draw(). These values are passed in arrays of primCount values.

Parameters:
m how the mesh vertices must be interpreted.
firsts an array of primCount 'first vertex' to draw, or an array of 'first indice' to draw if this mesh has indices.
counts an array of number of vertices to draw, or an array of number of indices to draw if this mesh has indices.
primCount the number of parts of this mesh to draw.
bases the base vertices to use. Only used for meshes with indices.
void ork::MeshBuffers::reset (  )  const

Resets the internal state associated with this mesh.

For internal use only.

template<class T >
static void ork::MeshBuffers::setDefaultAttribute ( GLuint  index,
int  count,
T *  defaultValue,
bool  normalize = false 
) [inline, static]

Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.

Parameters:
index a vertex attribute index. This attribute must be declared with a floating point type in the program.
count the number of elements in the 'defaultValue' array.
defaultValue the default value to use for this attribute.
normalize true to normalize the components of 'defaultValue'.
template<class T >
static void ork::MeshBuffers::setDefaultAttribute ( GLuint  index,
defaultValue 
) [inline, static]

Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.

Parameters:
index a vertex attribute index. This attribute must be declared with a floating point type in the program.
defaultValue the default value to use for this attribute.
template<class T >
static void ork::MeshBuffers::setDefaultAttributeI ( GLuint  index,
int  count,
T *  defaultValue 
) [inline, static]

Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.

Parameters:
index a vertex attribute index. This attribute must be declared with an integer or unsigned integer type in the program.
count the number of elements in the 'defaultValue' array.
defaultValue the default value to use for this attribute.
template<class T >
static void ork::MeshBuffers::setDefaultAttributeI ( GLuint  index,
defaultValue 
) [inline, static]

Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.

Parameters:
index a vertex attribute index. This attribute must be declared with an integer or unsigned integer type in the program.
defaultValue the default value to use for this attribute.
template<class T >
static void ork::MeshBuffers::setDefaultAttributeL ( GLuint  index,
int  count,
T *  defaultValue 
) [inline, static]

Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.

Parameters:
index a vertex attribute index. This attribute must be declared with a double point type in the program.
count the number of elements in the 'defaultValue' array.
defaultValue the default value to use for this attribute.
template<class T >
static void ork::MeshBuffers::setDefaultAttributeL ( GLuint  index,
defaultValue 
) [inline, static]

Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.

Parameters:
index a vertex attribute index. This attribute must be declared with a double type in the program.
defaultValue the default value to use for this attribute.
static void ork::MeshBuffers::setDefaultAttributeP ( GLuint  index,
int  count,
GLuint *  defaultValue,
bool  isSigned,
bool  normalize = false 
) [static]

Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.

This method only sets the first 'count' components of the specified attribute.

Parameters:
index a vertex attribute index. This attribute must be declared with a floating point type in the program.
count the number of components of the attribute to set.
defaultValue the default value to use for this attribute, in packed format.
isSigned true to use the signed packed format, false to use the unsigned packed format.
normalize true to normalize the components of 'defaultValue'.
static void ork::MeshBuffers::setDefaultAttributeP1 ( GLuint  index,
GLuint  defaultValue,
bool  isSigned,
bool  normalize = false 
) [static]

Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.

This method only sets the first component of the specified attribute.

Parameters:
index a vertex attribute index. This attribute must be declared with a floating point type in the program.
defaultValue the default value to use for this attribute, in packed format.
isSigned true to use the signed packed format, false to use the unsigned packed format.
normalize true to normalize the components of 'defaultValue'.
static void ork::MeshBuffers::setDefaultAttributeP2 ( GLuint  index,
GLuint  defaultValue,
bool  isSigned,
bool  normalize = false 
) [static]

Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.

This method only sets the first two components of the specified attribute.

Parameters:
index a vertex attribute index. This attribute must be declared with a floating point type in the program.
defaultValue the default value to use for this attribute, in packed format.
isSigned true to use the signed packed format, false to use the unsigned packed format.
normalize true to normalize the components of 'defaultValue'.
static void ork::MeshBuffers::setDefaultAttributeP3 ( GLuint  index,
GLuint  defaultValue,
bool  isSigned,
bool  normalize = false 
) [static]

Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.

This method only sets the first three components of the specified attribute.

Parameters:
index a vertex attribute index. This attribute must be declared with a floating point type in the program.
defaultValue the default value to use for this attribute, in packed format.
isSigned true to use the signed packed format, false to use the unsigned packed format.
normalize true to normalize the components of 'defaultValue'.
static void ork::MeshBuffers::setDefaultAttributeP4 ( GLuint  index,
GLuint  defaultValue,
bool  isSigned,
bool  normalize = false 
) [static]

Sets the default value for the given attribute when a MeshBuffers does not specify any Buffer for this attribute.

This method sets the four components of the specified attribute.

Parameters:
index a vertex attribute index. This attribute must be declared with a floating point type in the program.
defaultValue the default value to use for this attribute, in packed format.
isSigned true to use the signed packed format, false to use the unsigned packed format.
normalize true to normalize the components of 'defaultValue'.
void ork::MeshBuffers::setIndicesBuffer ( ptr< AttributeBuffer indices  ) 

Sets the indices array buffer of this mesh.

virtual void ork::MeshBuffers::swap ( ptr< MeshBuffers buffers  )  [protected, virtual]

Swaps this mesh with the given one.


Member Data Documentation

The AttributeBuffer of this mesh.

The bounding box of this mesh.

How the list of vertices of this mesh must be interpreted.

The number of indices in this mesh.

The number of vertices in this mesh.

The number of vertices per patch of this mesh, if mode is PATCHES.

The vertex index used for primitive restart.

-1 means no restart.


Generated on Mon Oct 18 09:36:09 2010 for ork by  doxygen 1.6.1