overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Static Public Member Functions
gameplay::MeshBatch Class Reference

#include <MeshBatch.h>

List of all members.

Public Member Functions

 ~MeshBatch ()
unsigned int getCapacity () const
void setCapacity (unsigned int capacity)
MaterialgetMaterial () const
template<class T >
void add (const T *vertices, unsigned int vertexCount, const unsigned short *indices=NULL, unsigned int indexCount=0)
void add (const float *vertices, unsigned int vertexCount, const unsigned short *indices=NULL, unsigned int indexCount=0)
void start ()
bool isStarted () const
void finish ()
void draw ()

Static Public Member Functions

static MeshBatchcreate (const VertexFormat &vertexFormat, Mesh::PrimitiveType primitiveType, const char *materialPath, bool indexed, unsigned int initialCapacity=1024, unsigned int growSize=1024)
static MeshBatchcreate (const VertexFormat &vertexFormat, Mesh::PrimitiveType primitiveType, Material *material, bool indexed, unsigned int initialCapacity=1024, unsigned int growSize=1024)

Detailed Description

Defines a class for rendering multiple mesh into a single draw call on the graphics device.


Constructor & Destructor Documentation

Destructor.


Member Function Documentation

template<class T >
void gameplay::MeshBatch::add ( const T *  vertices,
unsigned int  vertexCount,
const unsigned short *  indices = NULL,
unsigned int  indexCount = 0 
)

Adds a group of primitives to the batch.

The vertex list passed in should be a pointer of structs, where the struct T represents the format of a single vertex (e.g. {x,y,z,u,v}).

If the batch was created with 'indexed' set to true, then valid index data should be passed in this method. However, if 'indexed' was set to false, the indices and indexCount parameters can be omitted since only vertex data will be used.

If the batch created to draw triangle strips, this method assumes that separate calls to add specify separate triangle strips. In this case, this method will automatically stitch separate triangle strips together using degenerate (zero-area) triangles.

Parameters:
verticesArray of vertices.
vertexCountNumber of vertices.
indicesArray of indices into the vertex array (should be NULL for non-indexed batches).
indexCountNumber of indices (should be zero for non-indexed batches).
void gameplay::MeshBatch::add ( const float *  vertices,
unsigned int  vertexCount,
const unsigned short *  indices = NULL,
unsigned int  indexCount = 0 
)

Adds a group of primitives to the batch.

The vertex list passed in should be a pointer of floats where every X floats represent a single vertex (e.g. {x,y,z,u,v}).

If the batch was created with 'indexed' set to true, then valid index data should be passed in this method. However, if 'indexed' was set to false, the indices and indexCount parameters can be omitted since only vertex data will be used.

If the batch created to draw triangle strips, this method assumes that separate calls to add specify separate triangle strips. In this case, this method will automatically stitch separate triangle strips together using degenerate (zero-area) triangles.

Parameters:
verticesArray of vertices.
vertexCountNumber of vertices.
indicesArray of indices into the vertex array (should be NULL for non-indexed batches).
indexCountNumber of indices (should be zero for non-indexed batches).
static MeshBatch* gameplay::MeshBatch::create ( const VertexFormat vertexFormat,
Mesh::PrimitiveType  primitiveType,
const char *  materialPath,
bool  indexed,
unsigned int  initialCapacity = 1024,
unsigned int  growSize = 1024 
) [static]

Creates a new mesh batch.

Parameters:
vertexFormatThe format of vertices in the new batch.
primitiveTypeThe type of primitives that will be added to the batch.
materialPathPath to a material file to be used for drawing the batch.
indexedTrue if the batched primitives will contain index data, false otherwise.
initialCapacityThe initial capacity of the batch, in triangles.
growSizeAmount to grow the batch by when it overflows (a value of zero prevents batch growing).
Returns:
A new mesh batch.
static MeshBatch* gameplay::MeshBatch::create ( const VertexFormat vertexFormat,
Mesh::PrimitiveType  primitiveType,
Material material,
bool  indexed,
unsigned int  initialCapacity = 1024,
unsigned int  growSize = 1024 
) [static]

Creates a new mesh batch.

Parameters:
vertexFormatThe format of vertices in the new batch.
primitiveTypeThe type of primitives that will be added to the batch.
materialMaterial to be used for drawing the batch.
indexedTrue if the batched primitives will contain index data, false otherwise.
initialCapacityThe initial capacity of the batch, in triangles.
growSizeAmount to grow the batch by when it overflows (a value of zero prevents batch growing).
Returns:
A new mesh batch.

Draws the primitives currently in batch.

Indicates that batching is complete and prepares the batch for drawing.

unsigned int gameplay::MeshBatch::getCapacity ( ) const

Returns the current capacity of the batch.

Returns:
The batch capacity.

Returns the material for this mesh batch.

Returns:
The material used to draw the batch.

Determines if the batch has been started and not yet finished.

void gameplay::MeshBatch::setCapacity ( unsigned int  capacity)

Explicitly sets a new capacity for the batch.

Parameters:
capacityThe new batch capacity.

Starts batching.

This method should be called before calling add() to add primitives to the batch. After all primitives have been added to the batch, call the finish() method to complete the batch.

Calling this method will clear any primitives currently in the batch and set the position of the batch back to the beginning.

 All Classes Functions Variables Typedefs Enumerations Enumerator