|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

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:

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 VertexFormat & | getVertexFormat () 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)
MeshPart * | addPart (PrimitiveType primitiveType, Mesh::IndexFormat indexFormat, unsigned int indexCount, bool dynamic=false)
unsigned int | getPartCount () const
MeshPart * | getPart (unsigned int index)
const BoundingBox & | getBoundingBox () const
void | setBoundingBox (const BoundingBox &box)
const BoundingSphere & | getBoundingSphere () const
void | setBoundingSphere (const BoundingSphere &sphere)
virtual | ~Mesh ()

## Static Public Member Functions

static Mesh * | createMesh (const VertexFormat &vertexFormat, unsigned int vertexCount, bool dynamic=false)
static Mesh * | createQuad (const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &p4)
static 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 Mesh * | createQuadFullscreen ()
static Mesh * | createLines (Vector3 *points, unsigned int pointCount)
static Mesh * | createBoundingBox (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

enum gameplay::Mesh::IndexFormat

Defines supported index formats.

enum gameplay::Mesh::PrimitiveType

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:

  primitiveType | The type of primitive data to connect the indices as.
  indexFormat | The format of the indices. SHORT or INT.
  indexCount | The number of indices to be contained in the part.
  dynamic | true 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:

  box | The 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:

  points | The array of points.
  pointCount | The 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:

  vertexFormat | The vertex format.
  vertexCount | The number of vertices.
  dynamic | true 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:

  p1 | The first point.
  p2 | The second point.
  p3 | The third point.
  p4 | The 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:

  x | The x coordinate.
  y | The y coordinate.
  width | The width of the quad.
  height | The height of the quad.
  s1 | The S texture coordinate of the bottom left point.
  t1 | The T texture coordinate of the bottom left point.
  s2 | The S texture coordinate of the top right point.
  t2 | The T texture coordinate of the top right point.

Returns:
  The newly created mesh.

static Mesh* gameplay::Mesh::createQuadFullscreen | ( |  | ) | `[static]`

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.

const BoundingBox& gameplay::Mesh::getBoundingBox | ( |  | ) | const

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.

const BoundingSphere& gameplay::Mesh::getBoundingSphere | ( |  | ) | const

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:

  index | The 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.

PrimitiveType gameplay::Mesh::getPrimitiveType | ( |  | ) | const

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.

const VertexFormat& gameplay::Mesh::getVertexFormat | ( |  | ) | const

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.

void gameplay::Mesh::setBoundingBox | ( | const BoundingBox & | box | ) |

Sets the bounding box for this mesh.

Parameters:

  box | The new bounding box for the mesh.

void gameplay::Mesh::setBoundingSphere | ( | const BoundingSphere & | sphere | ) |

Sets the bounding sphere for this mesh.

Parameters:

  sphere | The new bounding sphere for the mesh.

void gameplay::Mesh::setPrimitiveType | ( | Mesh::PrimitiveType | type | ) |

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:

  type | The 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:

  vertexData | The vertex data to be set.
  vertexStart | The index of the starting vertex (0 by default).
  vertexCount | The number of vertices to be set (default is 0, for all vertices).

All Classes Functions Variables Typedefs Enumerations Enumerator