Public Member Functions
-
TriMesh (const Format &format=Format().positions().normals().texCoords())
-
TriMesh (const geom::Source &source)
-
TriMesh (const geom::Source &source, const Format &format)
-
voidloadInto (geom::Target *target, const geom::AttribSet &requestedAttribs) const override
-
clone () const override
-
voidclear ()
-
boolhasNormals () const
-
boolhasTangents () const
-
boolhasBitangents () const
-
boolhasColors () const
-
boolhasColorsRgb () const
-
boolhasColorsRgba () const
-
boolhasTexCoords () const
Returns whether the TriMesh has texture coordinates for unit 0.
-
boolhasTexCoords0 () const
Returns whether the TriMesh has texture coordinates for unit 0.
-
boolhasTexCoords1 () const
Returns whether the TriMesh has texture coordinates for unit 1.
-
boolhasTexCoords2 () const
Returns whether the TriMesh has texture coordinates for unit 2.
-
boolhasTexCoords3 () const
Returns whether the TriMesh has texture coordinates for unit 3.
-
voidappendPosition (const vec2 &position)
Appends a position which can be referred to with appendTriangle() or appendIndices()
-
voidappendPosition (const vec3 &position)
Appends a position which can be referred to with appendTriangle() or appendIndices()
-
voidappendPosition (const vec4 &position)
Appends a position which can be referred to with appendTriangle() or appendIndices()
-
voidappendPositions (const vec2 *positions, size_t num)
Appends multiple vertices to the TriMesh which can be referred to with appendTriangle() or appendIndices()
-
voidappendPositions (const vec3 *positions, size_t num)
Appends multiple vertices to the TriMesh which can be referred to with appendTriangle() or appendIndices()
-
voidappendPositions (const vec4 *positions, size_t num)
Appends multiple vertices to the TriMesh which can be referred to with appendTriangle() or appendIndices()
-
voidappendNormal (const vec3 &normal)
Appends a single normal.
-
voidappendNormals (const vec3 *normals, size_t num)
Functions similarly to appendPositions() , appending multiple normals at once.
-
voidappendTangent (const vec3 &tangent)
Appends a single tangent.
-
voidappendTangents (const vec3 *tangents, size_t num)
Functions similarly to appendPositions() , appending multiple tangents at once.
-
voidappendBitangent (const vec3 &bitangent)
Appends a single bitangent.
-
voidappendBitangents (const vec3 *bitangents, size_t num)
Functions similarly to appendPositions() , appending multiple bitangents at once.
-
voidappendColorRgb (const Color &color)
Appends a single RGB color.
-
voidappendColorRgba (const ColorA &color)
Appends a single RGBA color.
-
voidappendTexCoord (const vec2 &v)
Synonym for appendTexCoord0; appends a texture coordinate for unit 0.
-
voidappendTexCoord0 (const vec2 &v)
appends a 2D texture coordinate for unit 0
-
voidappendTexCoord1 (const vec2 &v)
appends a 2D texture coordinate for unit 1
-
voidappendTexCoord2 (const vec2 &v)
appends a 2D texture coordinate for unit 2
-
voidappendTexCoord3 (const vec2 &v)
appends a 2D texture coordinate for unit 3
-
voidappendTexCoord0 (const vec3 &v)
appends a 3D texture coordinate for unit 0
-
voidappendTexCoord1 (const vec3 &v)
appends a 3D texture coordinate for unit 1
-
voidappendTexCoord2 (const vec3 &v)
appends a 3D texture coordinate for unit 2
-
voidappendTexCoord3 (const vec3 &v)
appends a 3D texture coordinate for unit 3
-
voidappendTexCoord0 (const vec4 &v)
appends a 4D texture coordinate for unit 0
-
voidappendTexCoord1 (const vec4 &v)
appends a 4D texture coordinate for unit 1
-
voidappendTexCoord2 (const vec4 &v)
appends a 4D texture coordinate for unit 2
-
voidappendTexCoord3 (const vec4 &v)
appends a 4D texture coordinate for unit 3
-
voidappendColors (const Color *rgbs, size_t num)
Appends multiple RGB colors to the TriMesh .
-
voidappendColors (const ColorA *rgbas, size_t num)
Appends multiple RGBA colors to the TriMesh .
-
voidappendTexCoords0 (const vec2 *texCoords, size_t num)
Appends multiple 2D texcoords for unit 0.
-
voidappendTexCoords1 (const vec2 *texCoords, size_t num)
Appends multiple 2D texcoords for unit 1.
-
voidappendTexCoords2 (const vec2 *texCoords, size_t num)
Appends multiple 2D texcoords for unit 2.
-
voidappendTexCoords3 (const vec2 *texCoords, size_t num)
Appends multiple 2D texcoords for unit 3.
-
voidappendTexCoords0 (const vec3 *texCoords, size_t num)
Appends multiple 3D texcoords for unit 0.
-
voidappendTexCoords1 (const vec3 *texCoords, size_t num)
Appends multiple 3D texcoords for unit 1.
-
voidappendTexCoords2 (const vec3 *texCoords, size_t num)
Appends multiple 3D texcoords for unit 2.
-
voidappendTexCoords3 (const vec3 *texCoords, size_t num)
Appends multiple 3D texcoords for unit 3.
-
voidappendTexCoords0 (const vec4 *texCoords, size_t num)
Appends multiple 4D texcoords for unit 0.
-
voidappendTexCoords1 (const vec4 *texCoords, size_t num)
Appends multiple 4D texcoords for unit 1.
-
voidappendTexCoords2 (const vec4 *texCoords, size_t num)
Appends multiple 4D texcoords for unit 2.
-
voidappendTexCoords3 (const vec4 *texCoords, size_t num)
Appends multiple 4D texcoords for unit 3.
-
voidappendTriangle (uint32_t v0, uint32_t v1, uint32_t v2)
Appends a single triange whose 3 vertices are at indices v0 , v1 and v2 .
-
voidappendIndices (const uint32_t *indices, size_t num)
Appends num indices to the TriMesh pointed to by indices .
-
size_tgetNumIndices () const override
Returns the total number of indices in the TriMesh .
-
size_tgetNumTriangles () const
Returns the total number of triangles contained by the TriMesh .
-
size_tgetNumVertices () const override
Returns the total number of indices contained by the TriMesh .
-
voidgetTriangleVertices (size_t idx, vec3 *a, vec3 *b, vec3 *c) const
Copies the 3 vertices of triangle number idx into a , b and c . Assumes vertices are 3D.
-
voidgetTriangleVertices (size_t idx, vec2 *a, vec2 *b, vec2 *c) const
Copies the 3 vertices of triangle number idx into a , b and c . Assumes vertices are 2D.
-
voidgetTriangleNormals (size_t idx, vec3 *a, vec3 *b, vec3 *c) const
Copies the 3 normals of triangle number idx into a , b and c .
-
voidgetTriangleTangents (size_t idx, vec3 *a, vec3 *b, vec3 *c) const
Copies the 3 tangents of triangle number idx into a , b and c .
-
voidgetTriangleBitangents (size_t idx, vec3 *a, vec3 *b, vec3 *c) const
Copies the 3 bitangents of triangle number idx into a , b and c .
-
const VECDIM< DIM, float >::TYPE *getPositions () const
Returns a pointer to the positions of the mesh as vec<DIM>*. For example, for a TriMesh with 3D vertices, call getPositions<3>() .
-
VECDIM< DIM, float >::TYPE *getPositions ()
Returns a pointer to the positions of theTriMesh as vec<DIM>*. For example, for a TriMesh with 3D vertices, call getPositions<3>() .
-
std::vector< vec3 > &getNormals ()
Returns a reference to the std::vector<vec3> for the TriMesh 's normals.
-
const std::vector< vec3 > &getNormals () const
Returns a reference to the std::vector<vec3> for the TriMesh 's normals.
-
std::vector< vec3 > &getTangents ()
Returns a reference to the std::vector<vec3> for the TriMesh 's tangents.
-
const std::vector< vec3 > &getTangents () const
Returns a reference to the std::vector<vec3> for the TriMesh 's tangents.
-
std::vector< vec3 > &getBitangents ()
Returns a reference to the std::vector<vec3> for the TriMesh 's bitangents.
-
const std::vector< vec3 > &getBitangents () const
Returns a reference to the std::vector<vec3> for the TriMesh 's bitangents.
-
COLORDIM< DIM, float >::TYPE *getColors ()
Returns a pointer to the colors of the TriMesh vec<DIM>*. For example, to get RGB colors, call getColors<3>() .
-
const COLORDIM< DIM, float >::TYPE *getColors () const
Returns a pointer to the colors of the TriMesh vec<DIM>*. For example, to get RGB colors, call getColors<3>() .
-
VECDIM< DIM, float >::TYPE *getTexCoords0 ()
Returns a pointer to the TexCoord0 values of the TriMesh vec<DIM>*. For example, if the TriMesh has 2D TexCoord0 values, use getTexCoords0<2>() .
-
const VECDIM< DIM, float >::TYPE *getTexCoords0 () const
Returns a pointer to the TexCoord0 values of the TriMesh vec<DIM>*. For example, if the TriMesh has 2D TexCoord0 values, use getTexCoords0<2>() .
-
VECDIM< DIM, float >::TYPE *getTexCoords1 ()
Returns a pointer to the TexCoord1 values of the TriMesh vec<DIM>*. For example, if the TriMesh has 2D TexCoord1 values, use getTexCoords1<2>() .
-
const VECDIM< DIM, float >::TYPE *getTexCoords1 () const
Returns a pointer to the TexCoord1 values of the TriMesh vec<DIM>*. For example, if the TriMesh has 2D TexCoord1 values, use getTexCoords1<2>() .
-
VECDIM< DIM, float >::TYPE *getTexCoords2 ()
Returns a pointer to the TexCoord2 values of the TriMesh vec<DIM>*. For example, if the TriMesh has 2D TexCoord2 values, use getTexCoords2<2>() .
-
const VECDIM< DIM, float >::TYPE *getTexCoords2 () const
Returns a pointer to the TexCoord2 values of the TriMesh vec<DIM>*. For example, if the TriMesh has 2D TexCoord2 values, use getTexCoords2<2>() .
-
VECDIM< DIM, float >::TYPE *getTexCoords3 ()
Returns a pointer to the TexCoord3 values of the TriMesh vec<DIM>*. For example, if the TriMesh has 2D TexCoord3 values, use getTexCoords3<2>() .
-
const VECDIM< DIM, float >::TYPE *getTexCoords3 () const
Returns a pointer to the TexCoord3 values of the TriMesh vec<DIM>*. For example, if the TriMesh has 2D TexCoord3 values, use getTexCoords3<2>() .
-
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] }.
-
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] }.
-
const std::vector< float > &getBufferPositions () const
Returns a const reference to the position buffer.
-
std::vector< float > &getBufferPositions ()
Returns a reference to the position buffer.
-
const std::vector< float > &getBufferColors () const
Returns a const reference to the colors buffer.
-
std::vector< float > &getBufferColors ()
Returns a reference to the colors buffer.
-
const std::vector< float > &getBufferTexCoords0 () const
Returns a const reference to the texCoords0 buffer.
-
std::vector< float > &getBufferTexCoords0 ()
Returns a reference to the texCoords0 buffer.
-
const std::vector< float > &getBufferTexCoords1 () const
Returns a const reference to the texCoords1 buffer.
-
std::vector< float > &getBufferTexCoords1 ()
Returns a reference to the texCoords1 buffer.
-
const std::vector< float > &getBufferTexCoords2 () const
Returns a const reference to the texCoords2 buffer.
-
std::vector< float > &getBufferTexCoords2 ()
Returns a reference to the texCoords2 buffer.
-
const std::vector< float > &getBufferTexCoords3 () const
Returns a const reference to the texCoords3 buffer.
-
std::vector< float > &getBufferTexCoords3 ()
Returns a reference to the texCoords3 buffer.
-
calcBoundingBox () const
Calculates the bounding box of all vertices. Fails if the positions are not 3D.
-
calcBoundingBox (const mat4 &transform) const
Calculates the bounding box of all vertices as transformed by transform . Fails if the positions are not 3D.
-
voidread (const DataSourceRef &dataSource)
Fills this TriMesh with the data from a binary file, which was created with TriMesh::write() .
-
voidwrite (const DataTargetRef &dataTarget) const
Writes this TriMesh out to a binary data file.
-
voidwrite (const DataTargetRef &dataTarget, bool writeNormals, bool writeTangents) const
Writes this TriMesh out to a binary data file. If writeNormals or writeTangents is
true
, normals and/or tangents are written to the file. -
voidwrite (const DataTargetRef &dataTarget, const std::set< geom::Attrib > &attribs) const
Writes this TriMesh out to a binary data file. You can specify which attributes to write by supplying a list of attribs .
-
boolrecalculateNormals (bool smooth=false, bool weighted=false)
Adds or replaces normals by calculating them from the vertices and faces. If smooth is TRUE, similar vertices are grouped together to calculate their average. This will not change the mesh, nor will it affect texture mapping. If weighted is TRUE, larger polygons contribute more to the calculated normal. Renormalization requires 3D vertices.
-
boolrecalculateTangents ()
Adds or replaces tangents by calculating them from the normals and texture coordinates. Requires 3D normals and 2D texture coordinates.
-
boolrecalculateBitangents ()
Adds or replaces bitangents by calculating them from the normals and tangents. Requires 3D normals and tangents.
-
voidsubdivide (int division=2, bool normalize=false)
TODO: optimize memory allocations.
Subdivide each triangle of the TriMesh into division times division triangles. Division less than 2 leaves the mesh unaltered. Optionally, vertices are normalized if normalize is TRUE.
-
getPrimitive () const override
Create TriMesh from vectors of vertex data.
-
uint8_tgetAttribDims (geom::Attrib attr) const override
-
getAvailableAttribs () const override
Static Public Member Functions
-
create ()
-
create (const Format &format)
-
create (const geom::Source &source)
-
create (const geom::Source &source, const Format &format)
-
formatFromSource (const geom::Source &source)
Creates a suitable TriMesh::Format for representing a geom::Source source .
Protected Member Functions
-
voidinitFromFormat (const TriMesh::Format &format)
-
voidloadFromSource (const geom::Source &source)
-
voidgetAttribPointer (geom::Attrib attr, const float **resultPtr, size_t *resultStrideBytes, uint8_t *resultDims) const
-
voidcopyAttrib (geom::Attrib attr, uint8_t dims, size_t stride, const float *srcData, size_t count)
-
boolverticesEqual (uint32_t indexA, uint32_t indexB) const
Returns whether or not the vertex, color etc. at both indices is the same.
-
voidreadImplV2 (const IStreamRef &in)
-
voidreadImplV1 (const IStreamRef &in)
-
voidwrite (const DataTargetRef &dataTarget, uint32_t writeMask) const
Writes this TriMesh out to a binary data file. The writeMask parameter can be used to specify what data should be included (e.g. toMask(POSITION) | toMask(COLOR) ) or what should be excluded (e.g. ~toMask( NORMAL ) & ~toMask( TEX_COORD_0) ).
-
voidcopyIndicesNonIndexed (uint16_t *dest) const
Builds a sequential list of vertices to simulate an indexed geometry when Source is non-indexed. Assumes dest contains storage for getNumVertices() entries.
-
voidcopyIndicesNonIndexed (uint32_t *dest) const
Builds a sequential list of vertices to simulate an indexed geometry when Source is non-indexed. Assumes dest contains storage for getNumVertices() entries.
-
voidforceCopyIndicesTrianglesImpl (T *dest) const
-
uint32_ttoMask (geom::Attrib attrib)
Converts a geom::Attrib to an attribute bitmask.
-
fromMask (uint32_t attrib)
Converts an attribute bitmask to a geom::Attrib .
Protected Attributes
-
uint8_tmPositionsDims
-
uint8_tmNormalsDims
-
uint8_tmTangentsDims
-
uint8_tmBitangentsDims
-
uint8_tmColorsDims
-
uint8_tmTexCoords0Dims
-
uint8_tmTexCoords1Dims
-
uint8_tmTexCoords2Dims
-
uint8_tmTexCoords3Dims
-
std::vector< float >mPositions
-
std::vector< float >mColors
-
std::vector< vec3 >mNormals
-
std::vector< vec3 >mTangents
-
std::vector< vec3 >mBitangents
-
std::vector< float >mTexCoords0
-
std::vector< float >mTexCoords1
-
std::vector< float >mTexCoords2
-
std::vector< float >mTexCoords3
-
std::vector< uint32_t >mIndices