igor::iMeshBuilder Class Reference

#include <iMeshBuilder.h>

Public Member Functions

 iMeshBuilder ()
 
 ~iMeshBuilder ()
 
void setMatrix (const iaMatrixf &matrix)
 
void multMatrix (const iaMatrixf &matrix)
 
void getMatrix (iaMatrixf &matrix)
 
void calcBoundingBox (iAABoxd &bbox) const
 
uint32 addVertex (const iaVector3f &vertex)
 
uint32 addVertex (const iaVector4f &vertex)
 
void setNormal (uint32 index, const iaVector3f &normal)
 
void accumulateNormal (uint32 index, const iaVector3f &normal)
 
void setColor (uint32 index, const iaColor4f &color)
 
void setTexCoord (const iaVector2f &texCoord, uint32 unit)
 
void setTexCoord (uint32 index, const iaVector2f &texCoord, uint32 unit)
 
uint32 addTriangle (const uint32 indexA, const uint32 indexB, const uint32 indexC, const uint32 indexOffset=0)
 
void setJoinVertexes (bool joinVertexes=true)
 
void normalizeNormals ()
 
bool getJoinVertexes ()
 
uint32 getVertexCount () const
 
uint32 getTrianglesCount () const
 
uint32 getTextureUnitCount () const
 
const std::vector< iaVector3f > & getVertexes () const
 
const std::vector< iaVector3f > & getNormals () const
 
const std::vector< iIndexedTriangle > & getTriangles () const
 
bool hasNormals () const
 
bool hasColors () const
 
void calcNormals (bool sharpEdges=false)
 
iMeshPtr createMesh ()
 
iMeshPtr createMesh (const std::vector< uint32 > &triangles)
 
void clear ()
 
void copyTriangles (std::vector< uint32 > srcTriangleIndexes, iMeshBuilder &dst)
 
void calcSphericalTexcoordsByNormals (int texunit, float32 scale=1.0f)
 
void calcSphericalTexcoordsByPosition (const iaVector3f &center, int texunit, float32 scale=1.0f)
 
void calcPlanarTextureCoordinates (const iaVector3f &center, iaAxis direction, int texunit, float32 scale=1.0f)
 
void cleanup ()
 

Detailed Description

builds up a mesh and spits out iMesh

Constructor & Destructor Documentation

◆ iMeshBuilder()

igor::iMeshBuilder::iMeshBuilder ( )

does nothing

◆ ~iMeshBuilder()

igor::iMeshBuilder::~iMeshBuilder ( )

does nothing

Member Function Documentation

◆ accumulateNormal()

void igor::iMeshBuilder::accumulateNormal ( uint32  index,
const iaVector3f normal 
)

accumulates normal values for specified index

Parameters
indexthe index of vertex to manipulate
normalthe normal vector to accumulate

◆ addTriangle()

uint32 igor::iMeshBuilder::addTriangle ( const uint32  indexA,
const uint32  indexB,
const uint32  indexC,
const uint32  indexOffset = 0 
)

adds indexes of a triangle to the data

Parameters
indexAfirst point of triangle
indexBsecond point of triangle
indexCthird point of triangle
indexOffsetindex offset
Returns
index of triangle created

◆ addVertex() [1/2]

uint32 igor::iMeshBuilder::addVertex ( const iaVector3f vertex)

adds vertex to data

Parameters
vertexthe vertex to add
Returns
index of vertex added

◆ addVertex() [2/2]

uint32 igor::iMeshBuilder::addVertex ( const iaVector4f vertex)

adds vertex to data

ignores the 4th component

Parameters
vertexthe vertex to add
Returns
index of vertex added

◆ calcBoundingBox()

void igor::iMeshBuilder::calcBoundingBox ( iAABoxd bbox) const

calculating the bounding box

◆ calcNormals()

void igor::iMeshBuilder::calcNormals ( bool  sharpEdges = false)

calculates normals for mesh

Parameters
sharpEdgesif true sharp edges will cause plit of neighbor triangles for more realistic representation

◆ calcPlanarTextureCoordinates()

void igor::iMeshBuilder::calcPlanarTextureCoordinates ( const iaVector3f center,
iaAxis  direction,
int  texunit,
float32  scale = 1.0f 
)

calculates planar texture coordinates from specified axis aligned direction

Parameters
centerit kind of works like an offset
directionthe axis in which we project the texture coordinates
texunitthe destination texture unit
scalethe texture coordinate scale

◆ calcSphericalTexcoordsByNormals()

void igor::iMeshBuilder::calcSphericalTexcoordsByNormals ( int  texunit,
float32  scale = 1.0f 
)

calculates spherical texture coordinates based on vertex normal orientation

Parameters
texunittexture unit to put the result in
scalescaling the texture coordinates

◆ calcSphericalTexcoordsByPosition()

void igor::iMeshBuilder::calcSphericalTexcoordsByPosition ( const iaVector3f center,
int  texunit,
float32  scale = 1.0f 
)

calculates spherical texture coordinate based on vertex position relative to center

Parameters
centerthe center the calculation bases on
texunitthe texture unit to put the result in
scalescaling the texture coordinates

◆ cleanup()

void igor::iMeshBuilder::cleanup ( )

tries to repair what is inconsistent

◆ clear()

void igor::iMeshBuilder::clear ( )

clears data and set transformation matrix to identity

◆ copyTriangles()

void igor::iMeshBuilder::copyTriangles ( std::vector< uint32 srcTriangleIndexes,
iMeshBuilder dst 
)

copies the triangles in the index list to an other iMeshBuilder

Parameters
srcTriangleIndexeslist of triangle indexes to copy

◆ createMesh() [1/2]

iMeshPtr igor::iMeshBuilder::createMesh ( )

creates and returns a mesh based on current data

Returns
shared pointer to iMesh

◆ createMesh() [2/2]

iMeshPtr igor::iMeshBuilder::createMesh ( const std::vector< uint32 > &  triangles)

creates ans returns a mesh based on current data filtered by given triangles list

Parameters
triangleslist of triangle IDs that end up in the mesh
Returns
shared pointer to mesh

◆ getJoinVertexes()

bool igor::iMeshBuilder::getJoinVertexes ( )
Returns
join vertexes flag

◆ getMatrix()

void igor::iMeshBuilder::getMatrix ( iaMatrixf matrix)

returns transformation matrix affecting next vertex to be set

Parameters
[out]matrixreturned matrix

◆ getNormals()

const std::vector< iaVector3f > & igor::iMeshBuilder::getNormals ( ) const
Returns
list of vertex normals

◆ getTextureUnitCount()

uint32 igor::iMeshBuilder::getTextureUnitCount ( ) const
Returns
texture unit count

◆ getTriangles()

const std::vector< iIndexedTriangle > & igor::iMeshBuilder::getTriangles ( ) const
Returns
list of indexed triangles

◆ getTrianglesCount()

uint32 igor::iMeshBuilder::getTrianglesCount ( ) const
Returns
triangle count

◆ getVertexCount()

uint32 igor::iMeshBuilder::getVertexCount ( ) const
Returns
vertex count

◆ getVertexes()

const std::vector< iaVector3f > & igor::iMeshBuilder::getVertexes ( ) const
Returns
list of vertex positions

◆ hasColors()

bool igor::iMeshBuilder::hasColors ( ) const
Returns
true if data contains colors

◆ hasNormals()

bool igor::iMeshBuilder::hasNormals ( ) const
Returns
true: if mesh has _normals; false: mesh has no _normals

◆ multMatrix()

void igor::iMeshBuilder::multMatrix ( const iaMatrixf matrix)

multiplies current matrix with given matrix

Parameters
matrixmatrix to multiply with

◆ normalizeNormals()

void igor::iMeshBuilder::normalizeNormals ( )

normalizes all normals

◆ setColor()

void igor::iMeshBuilder::setColor ( uint32  index,
const iaColor4f color 
)

sets color of last added vertex

Parameters
colorthe color to add

◆ setJoinVertexes()

void igor::iMeshBuilder::setJoinVertexes ( bool  joinVertexes = true)

set's if added vertexes will be joined when heaving same position

can only be set before the first vertex was added

Parameters
joinVertexeson off flag

◆ setMatrix()

void igor::iMeshBuilder::setMatrix ( const iaMatrixf matrix)

sets transformation matrix affecting next vertex to be set

Parameters
matrixtransformation matrix

◆ setNormal()

void igor::iMeshBuilder::setNormal ( uint32  index,
const iaVector3f normal 
)

sets normal of last added vertex

Parameters
normalthe normal to add

◆ setTexCoord() [1/2]

void igor::iMeshBuilder::setTexCoord ( const iaVector2f texCoord,
uint32  unit 
)

sets texture coordinate of last added vertex

Parameters
texCoordthe texture coordinate to add
unitthe texture unit to add the texture coodinate to

◆ setTexCoord() [2/2]

void igor::iMeshBuilder::setTexCoord ( uint32  index,
const iaVector2f texCoord,
uint32  unit 
)

sets texture coordinate of vertex specified by index

Parameters
indexthe vertex's index
texCoordthe texture coordinate to add
unitthe texture unit to add the texture coodinate to

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