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

#include <Mesh.h>

Inheritance diagram for gameplay::Mesh:
gameplay::Ref

List of all members.

Public Types

enum  IndexFormat { INDEX8 = GL_UNSIGNED_BYTE, INDEX16 = GL_UNSIGNED_SHORT, INDEX32 = GL_UNSIGNED_INT }
enum  PrimitiveType {
  TRIANGLES = GL_TRIANGLES, TRIANGLE_STRIP = GL_TRIANGLE_STRIP, LINES = GL_LINES, LINE_STRIP = GL_LINE_STRIP,
  POINTS = GL_POINTS
}

Public Member Functions

const char * getUrl () const
const VertexFormatgetVertexFormat () const
unsigned int getVertexCount () const
unsigned int getVertexSize () const
VertexBufferHandle getVertexBuffer () const
bool isDynamic () const
PrimitiveType getPrimitiveType () const
void setPrimitiveType (Mesh::PrimitiveType type)
void setVertexData (const float *vertexData, unsigned int vertexStart=0, unsigned int vertexCount=0)
MeshPartaddPart (PrimitiveType primitiveType, Mesh::IndexFormat indexFormat, unsigned int indexCount, bool dynamic=false)
unsigned int getPartCount () const
MeshPartgetPart (unsigned int index)
const BoundingBoxgetBoundingBox () const
void setBoundingBox (const BoundingBox &box)
const BoundingSpheregetBoundingSphere () const
void setBoundingSphere (const BoundingSphere &sphere)
virtual ~Mesh ()

Static Public Member Functions

static MeshcreateMesh (const VertexFormat &vertexFormat, unsigned int vertexCount, bool dynamic=false)
static MeshcreateQuad (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &p4)
static MeshcreateQuad (float x, float y, float width, float height, float s1=0.0f, float t1=0.0f, float s2=1.0f, float t2=1.0f)
static MeshcreateQuadFullscreen ()
static MeshcreateLines (Vector3 *points, unsigned int pointCount)
static MeshcreateBoundingBox (const BoundingBox &box)

Detailed Description

Defines a mesh supporting various vertex formats and 1 or more MeshPart(s) to define how the vertices are connected.


Member Enumeration Documentation

Defines supported index formats.

Defines supported primitive types.


Constructor & Destructor Documentation

virtual gameplay::Mesh::~Mesh ( ) [virtual]

Destructor.


Member Function Documentation

MeshPart* gameplay::Mesh::addPart ( PrimitiveType  primitiveType,
Mesh::IndexFormat  indexFormat,
unsigned int  indexCount,
bool  dynamic = false 
)

Creates and adds a new part of primitive data defining how the vertices are connected.

Parameters:
primitiveTypeThe type of primitive data to connect the indices as.
indexFormatThe format of the indices. SHORT or INT.
indexCountThe number of indices to be contained in the part.
dynamictrue if the index data is dynamic; false otherwise.
Returns:
The newly created/added mesh part.
static Mesh* gameplay::Mesh::createBoundingBox ( const BoundingBox box) [static]

Creates a bounding box mesh when passed a BoundingBox.

The mesh contains only position data using lines to connect the vertices.

Parameters:
boxThe BoundingBox that will be used to create the mesh.
Returns:
The newly created bounding box mesh.
static Mesh* gameplay::Mesh::createLines ( Vector3 points,
unsigned int  pointCount 
) [static]

Creates lines between 2 or more points passed in as a Vector3 array.

The mesh contains only position data using lines to connect the vertices. This is useful for drawing basic color elements into a scene.

Parameters:
pointsThe array of points.
pointCountThe number of points.
Returns:
The newly created mesh.
static Mesh* gameplay::Mesh::createMesh ( const VertexFormat vertexFormat,
unsigned int  vertexCount,
bool  dynamic = false 
) [static]

Constructs a new mesh with the specified vertex format.

Parameters:
vertexFormatThe vertex format.
vertexCountThe number of vertices.
dynamictrue if the mesh is dynamic; false otherwise.
Returns:
The created mesh.
static Mesh* gameplay::Mesh::createQuad ( const Vector3 p1,
const Vector3 p2,
const Vector3 p3,
const Vector3 p4 
) [static]

Creates a new textured 3D quad.

The specified points should describe a triangle strip with the first 3 points forming a triangle wound in counter-clockwise direction, with the second triangle formed from the last three points in clockwise direction.

Parameters:
p1The first point.
p2The second point.
p3The third point.
p4The fourth point.
Returns:
The created mesh.
static Mesh* gameplay::Mesh::createQuad ( float  x,
float  y,
float  width,
float  height,
float  s1 = 0.0f,
float  t1 = 0.0f,
float  s2 = 1.0f,
float  t2 = 1.0f 
) [static]

Constructs a new textured 2D quad.

Parameters:
xThe x coordinate.
yThe y coordinate.
widthThe width of the quad.
heightThe height of the quad.
s1The S texture coordinate of the bottom left point.
t1The T texture coordinate of the bottom left point.
s2The S texture coordinate of the top right point.
t2The T texture coordinate of the top right point.
Returns:
The newly created mesh.

Creates a new full-screen 2D quad.

The returned mesh's vertex format includes a 2-element (x,y) position and a 2-element texture coordinate.

This method returns a mesh describing a fullscreen quad using normalized device coordinates for vertex positions.

Returns:
The newly created mesh.

Returns the bounding box for the points in this mesh.

Only meshes loaded from bundle files are imported with valid bounding volumes. Programmatically created meshes will contain empty bounding volumes until the setBoundingBox and/or setBoundingSphere methods are called to specify the mesh's local bounds.

Meshes that are attached to a Model with a MeshSkin will have a bounding volume that is not necessarily tight fighting on the Mesh vertices. Instead, the bounding volume will be an approximation that contains all possible vertex positions in all possible poses after skinning is applied. This is necessary since skinning vertices result in vertex positions that lie outside the original mesh bounds and could otherwise result in a bounding volume that does not fully contain an animated/skinned mesh.

Returns:
The bounding box for the mesh.

Returns the bounding sphere for the points in the mesh.

Only meshes loaded from bundle files are imported with valid bounding volumes. Programmatically created meshes will contain empty bounding volumes until the setBoundingBox and/or setBoundingSphere methods are called to specify the mesh's local bounds.

Meshes that are attached to a Model with a MeshSkin will have a bounding volume that is not necessarily tight fighting on the Mesh vertices. Instead, the bounding volume will be an approximation that contains all possible vertex positions in all possible poses after skinning is applied. This is necessary since skinning vertices result in vertex positions that lie outside the original mesh bounds and could otherwise result in a bounding volume that does not fully contain an animated/skinned mesh.

Returns:
The bounding sphere for the mesh.
MeshPart* gameplay::Mesh::getPart ( unsigned int  index)

Gets a MeshPart by index.

Parameters:
indexThe index of the MeshPart to get.
Returns:
The MeshPart at the specified index.
unsigned int gameplay::Mesh::getPartCount ( ) const

Gets the number of mesh parts contained within the mesh.

Returns:
The number of mesh parts contained within the mesh.

Returns the primitive type of the vertices in the mesh.

The default primitive type for a Mesh is TRIANGLES.

Returns:
The primitive type.
See also:
setPrimitiveType(PrimitiveType)
const char* gameplay::Mesh::getUrl ( ) const

Returns a URL from which the mesh was loaded from.

For meshes loaded from a Bundle, this URL will point to the file and ID of the mesh within the bundle. For all other meshes, an empty string will be returned.

VertexBufferHandle gameplay::Mesh::getVertexBuffer ( ) const

Returns a handle to the vertex buffer for the mesh.

Returns:
The vertex buffer object handle.
unsigned int gameplay::Mesh::getVertexCount ( ) const

Gets the number of vertices in the mesh.

Returns:
The number of vertices in the mesh.

Gets the vertex format for the mesh.

Returns:
The vertex format.
unsigned int gameplay::Mesh::getVertexSize ( ) const

Gets the size of a single vertex in the mesh.

Returns:
The size of 1 vertex in the mesh.
bool gameplay::Mesh::isDynamic ( ) const

Determines if the mesh is dynamic.

Returns:
true if the mesh is dynamic; false otherwise.

Sets the bounding box for this mesh.

Parameters:
boxThe new bounding box for the mesh.

Sets the bounding sphere for this mesh.

Parameters:
sphereThe new bounding sphere for the mesh.

Sets the primitive type for the vertices in the mesh.

The primitive type for a Mesh is only meaningful for meshes that do not have any MeshParts. When there are no MeshParts associated with a mesh, the Mesh is drawn as non-indexed geometry and the PrimitiveType of the Mesh determines how the vertices are interpreted when drawn.

Parameters:
typeThe new primitive type.
void gameplay::Mesh::setVertexData ( const float *  vertexData,
unsigned int  vertexStart = 0,
unsigned int  vertexCount = 0 
)

Sets the specified vertex data into the mapped vertex buffer.

Parameters:
vertexDataThe vertex data to be set.
vertexStartThe index of the starting vertex (0 by default).
vertexCountThe number of vertices to be set (default is 0, for all vertices).
 All Classes Functions Variables Typedefs Enumerations Enumerator