Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | List of all members
cinder::TriMesh Class Reference

#include <TriMesh.h>

Public Member Functions

void clear ()
 
bool hasNormals () const
 
bool hasColorsRGB () const
 
bool hasColorsRGBA () const
 
bool hasTexCoords () const
 
void appendVertex (const Vec3f &v)
 Creates a vertex which can be referred to with appendTriangle() or appendIndices() More...
 
void appendVertices (const Vec3f *verts, size_t num)
 Appends multiple vertices to the TriMesh which can be referred to with appendTriangle() or appendIndices() More...
 
void appendVertices (const Vec4d *verts, size_t num)
 Appends multiple vertices to the TriMesh which can be referred to with appendTriangle() or appendIndices() More...
 
void appendNormal (const Vec3f &v)
 Appends a normal. More...
 
void appendNormals (const Vec3f *normals, size_t num)
 appendNormals functions similarly to the appendVertices method, appending multiple normals to be associated with the triangle faces. More...
 
void appendNormals (const Vec4d *normals, size_t num)
 appendNormals functions similarly to the appendVertices method, appending multiple normals to be associated with the triangle faces. More...
 
void appendColorRgb (const Color &rgb)
 this sets the color used by a triangle generated by the TriMesh More...
 
void appendColorRgba (const ColorA &rgba)
 this sets the color used by a triangle generated by the TriMesh More...
 
void appendTexCoord (const Vec2f &v)
 appends a texture coordinate in [-1,1] space to be applied to generated triangles. More...
 
void appendColorsRgb (const Color *rgbs, size_t num)
 Appends multiple RGB colors to the TriMesh. More...
 
void appendColorsRgba (const ColorA *rgbas, size_t num)
 Appends multiple RGBA colors to the TriMesh. More...
 
void appendTexCoords (const Vec2f *texcoords, size_t num)
 Appends multiple texcoords to the TriMesh. More...
 
void appendTriangle (uint32_t v0, uint32_t v1, uint32_t v2)
 after creating three vertices, pass the indices of the three vertices to create a triangle from them. More...
 
void appendIndices (const uint32_t *indices, size_t num)
 Appends num vertices to the TriMesh pointed to by indices. More...
 
size_t getNumIndices () const
 Returns the total number of indices contained by a TriMesh. This should be number of triangles/3. More...
 
size_t getNumTriangles () const
 Returns the total number of triangles contained by a TriMesh. This should be number of indices*3. More...
 
size_t getNumVertices () const
 Returns the total number of indices contained by a TriMesh. This should be number of triangles/3. More...
 
void getTriangleVertices (size_t idx, Vec3f *a, Vec3f *b, Vec3f *c) const
 Puts the 3 vertices of triangle number idx into a, b and c. More...
 
std::vector< Vec3f > & getVertices ()
 Returns all the vertices for a mesh in a std::vector as Vec3f objects. More...
 
const std::vector< Vec3f > & getVertices () const
 Returns all the vertices for a mesh in a std::vector as Vec3f objects. More...
 
std::vector< Vec3f > & getNormals ()
 Returns all the normals for a mesh in a std::vector as Vec3f objects. There will be one of these for each triangle face in the mesh. More...
 
const std::vector< Vec3f > & getNormals () const
 Returns all the normals for a mesh in a std::vector as Vec3f objects. There will be one of these for each triangle face in the mesh. More...
 
std::vector< Color > & getColorsRGB ()
 Returns a std::vector of RGB colors of the triangles faces. There will be one of these for each triangle face in the mesh. More...
 
const std::vector< Color > & getColorsRGB () const
 Returns a std::vector of RGB colors of the triangles faces. There will be one of these for each triangle face in the mesh. More...
 
std::vector< ColorA > & getColorsRGBA ()
 Returns a std::vector of RGBA colors of the triangles faces. There will be one of these for each triangle face in the mesh. More...
 
const std::vector< ColorA > & getColorsRGBA () const
 Returns a std::vector of RGBA colors of the triangles faces. There will be one of these for each triangle face in the mesh. More...
 
std::vector< Vec2f > & getTexCoords ()
 Returns a std::vector of Texture coordinates as Vec2fs. There will be one texture coord for each vertex in the TriMesh. More...
 
const std::vector< Vec2f > & getTexCoords () const
 Returns a std::vector of Texture coordinates as Vec2fs. There will be one texture coord for each vertex in the TriMesh. More...
 
std::vector< uint32_t > & getIndices ()
 Trimesh indices are ordered such that the indices of triangle T are { indices[T*3+0], indices[T*3+1], indices[T*3+2] }. More...
 
const std::vector< uint32_t > & getIndices () const
 Trimesh indices are ordered such that the indices of triangle T are { indices[T*3+0], indices[T*3+1], indices[T*3+2] }. More...
 
AxisAlignedBox3f calcBoundingBox () const
 Calculates the bounding box of all vertices. More...
 
AxisAlignedBox3f calcBoundingBox (const Matrix44f &transform) const
 Calculates the bounding box of all vertices as transformed by transform. More...
 
void read (DataSourceRef in)
 This reads a TriMesh in from a data file that was serialized using the write() function. More...
 
void write (DataTargetRef out) const
 This writes a TriMesh to a proprietary file format to be read using the read() function. More...
 
void recalculateNormals ()
 Adds or replaces normals by calculating them from the vertices and faces. More...
 

Member Function Documentation

void cinder::TriMesh::clear ( )
bool cinder::TriMesh::hasNormals ( ) const
bool cinder::TriMesh::hasColorsRGB ( ) const
bool cinder::TriMesh::hasColorsRGBA ( ) const
bool cinder::TriMesh::hasTexCoords ( ) const
void cinder::TriMesh::appendVertex ( const Vec3f v)

Creates a vertex which can be referred to with appendTriangle() or appendIndices()

void cinder::TriMesh::appendVertices ( const Vec3f verts,
size_t  num 
)

Appends multiple vertices to the TriMesh which can be referred to with appendTriangle() or appendIndices()

void cinder::TriMesh::appendVertices ( const Vec4d verts,
size_t  num 
)

Appends multiple vertices to the TriMesh which can be referred to with appendTriangle() or appendIndices()

void cinder::TriMesh::appendNormal ( const Vec3f v)

Appends a normal.

void cinder::TriMesh::appendNormals ( const Vec3f normals,
size_t  num 
)

appendNormals functions similarly to the appendVertices method, appending multiple normals to be associated with the triangle faces.

Normals and triangles are associated by index, so if you have created 3 vertices and one Triangle, you would append a single normal for the face of the triangles

void cinder::TriMesh::appendNormals ( const Vec4d normals,
size_t  num 
)

appendNormals functions similarly to the appendVertices method, appending multiple normals to be associated with the triangle faces.

Normals and triangles are associated by index, so if you have created 3 vertices and one Triangle, you would append a single normal for the face of the triangles

void cinder::TriMesh::appendColorRgb ( const Color rgb)

this sets the color used by a triangle generated by the TriMesh

void cinder::TriMesh::appendColorRgba ( const ColorA rgba)

this sets the color used by a triangle generated by the TriMesh

void cinder::TriMesh::appendTexCoord ( const Vec2f v)

appends a texture coordinate in [-1,1] space to be applied to generated triangles.

The coordinates are associated with the vertexes of the TriMesh, not the generated triangles when they are drawn

void cinder::TriMesh::appendColorsRgb ( const Color rgbs,
size_t  num 
)

Appends multiple RGB colors to the TriMesh.

void cinder::TriMesh::appendColorsRgba ( const ColorA rgbas,
size_t  num 
)

Appends multiple RGBA colors to the TriMesh.

void cinder::TriMesh::appendTexCoords ( const Vec2f texcoords,
size_t  num 
)

Appends multiple texcoords to the TriMesh.

void cinder::TriMesh::appendTriangle ( uint32_t  v0,
uint32_t  v1,
uint32_t  v2 
)

after creating three vertices, pass the indices of the three vertices to create a triangle from them.

Until this is done, unlike in an OpenGL triangle strip, the triangle will not actually be generated and stored by the TriMesh

void cinder::TriMesh::appendIndices ( const uint32_t *  indices,
size_t  num 
)

Appends num vertices to the TriMesh pointed to by indices.

size_t cinder::TriMesh::getNumIndices ( ) const

Returns the total number of indices contained by a TriMesh. This should be number of triangles/3.

size_t cinder::TriMesh::getNumTriangles ( ) const

Returns the total number of triangles contained by a TriMesh. This should be number of indices*3.

size_t cinder::TriMesh::getNumVertices ( ) const

Returns the total number of indices contained by a TriMesh. This should be number of triangles/3.

void cinder::TriMesh::getTriangleVertices ( size_t  idx,
Vec3f a,
Vec3f b,
Vec3f c 
) const

Puts the 3 vertices of triangle number idx into a, b and c.

std::vector<Vec3f>& cinder::TriMesh::getVertices ( )

Returns all the vertices for a mesh in a std::vector as Vec3f objects.

const std::vector<Vec3f>& cinder::TriMesh::getVertices ( ) const

Returns all the vertices for a mesh in a std::vector as Vec3f objects.

std::vector<Vec3f>& cinder::TriMesh::getNormals ( )

Returns all the normals for a mesh in a std::vector as Vec3f objects. There will be one of these for each triangle face in the mesh.

const std::vector<Vec3f>& cinder::TriMesh::getNormals ( ) const

Returns all the normals for a mesh in a std::vector as Vec3f objects. There will be one of these for each triangle face in the mesh.

std::vector<Color>& cinder::TriMesh::getColorsRGB ( )

Returns a std::vector of RGB colors of the triangles faces. There will be one of these for each triangle face in the mesh.

const std::vector<Color>& cinder::TriMesh::getColorsRGB ( ) const

Returns a std::vector of RGB colors of the triangles faces. There will be one of these for each triangle face in the mesh.

std::vector<ColorA>& cinder::TriMesh::getColorsRGBA ( )

Returns a std::vector of RGBA colors of the triangles faces. There will be one of these for each triangle face in the mesh.

const std::vector<ColorA>& cinder::TriMesh::getColorsRGBA ( ) const

Returns a std::vector of RGBA colors of the triangles faces. There will be one of these for each triangle face in the mesh.

std::vector<Vec2f>& cinder::TriMesh::getTexCoords ( )

Returns a std::vector of Texture coordinates as Vec2fs. There will be one texture coord for each vertex in the TriMesh.

const std::vector<Vec2f>& cinder::TriMesh::getTexCoords ( ) const

Returns a std::vector of Texture coordinates as Vec2fs. There will be one texture coord for each vertex in the TriMesh.

std::vector<uint32_t>& cinder::TriMesh::getIndices ( )

Trimesh indices are ordered such that the indices of triangle T are { indices[T*3+0], indices[T*3+1], indices[T*3+2] }.

const std::vector<uint32_t>& cinder::TriMesh::getIndices ( ) const

Trimesh indices are ordered such that the indices of triangle T are { indices[T*3+0], indices[T*3+1], indices[T*3+2] }.

AxisAlignedBox3f cinder::TriMesh::calcBoundingBox ( ) const

Calculates the bounding box of all vertices.

AxisAlignedBox3f cinder::TriMesh::calcBoundingBox ( const Matrix44f transform) const

Calculates the bounding box of all vertices as transformed by transform.

void cinder::TriMesh::read ( DataSourceRef  in)

This reads a TriMesh in from a data file that was serialized using the write() function.

void cinder::TriMesh::write ( DataTargetRef  out) const

This writes a TriMesh to a proprietary file format to be read using the read() function.

void cinder::TriMesh::recalculateNormals ( )

Adds or replaces normals by calculating them from the vertices and faces.


The documentation for this class was generated from the following files: