Developer Documentation
ACG::MeshCompiler Class Reference

Classes

struct  AdjacencyList
 
struct  Subset
 
struct  VertexElementInput
 
struct  VertexSplitter
 
struct  WeldList
 
struct  WeldListEntry
 

Public Member Functions

 MeshCompiler (const VertexDeclaration &_decl)
 
void getIndexAdjBuffer_MT (void *_dst, const int _borderIndex=-1)
 Multi-threaded version of getIndexAdjBuffer. More...
 
void dbgdump (const char *_filename) const
 dump mesh info to text file More...
 
void dbgdumpObj (const char *_filename) const
 dump mesh in wavefront obj format More...
 
void dbgdumpInputBin (const char *_filename, bool _seperateFiles=false) const
 dump input mesh to binary file format More...
 
void dbgdumpInputObj (const char *_filename) const
 dump input mesh to wavefront obj format More...
 
void dbgdumpAdjList (const char *_filename) const
 dump adjacency list to text file More...
 
bool dbgVerify (const char *_filename) const
 test correctness of input <-> output id mappings, unshared per face vertex.. logs errors in file More...
 
std::string vertexToString (const void *v) const
 interpret vertex data according declaration and write to string More...
 
size_t getMemoryUsage (bool _printConsole=true) const
 
std::string checkInputData () const
 check for errors in input data More...
 
Vertex Data Input
void setVertices (size_t _num, const void *_data, size_t _stride=0, bool _internalCopy=false, GLuint _fmt=0, int _elementSize=-1)
 
void setNormals (size_t _num, const void *_data, size_t _stride=0, bool _internalCopy=false, GLuint _fmt=0, int _elementSize=-1)
 
void setTexCoords (size_t _num, const void *_data, size_t _stride=0, bool _internalCopy=false, GLuint _fmt=0, int _elementSize=-1)
 
void setAttribVec (int _attrIdx, size_t _num, const void *_data, size_t _stride=0, bool _internalCopy=false, GLuint _fmt=0, int _elementSize=-1)
 
void setAttrib (int _attrIdx, int _v, const void *_data)
 
int getNumInputAttributes (int _attrIdx) const
 
Flexible Face Data Input
void setFaceInput (MeshCompilerFaceInput *_faceInput)
 
Default Face Data Input
void setNumFaces (const int _numFaces, const int _numIndices)
 Set number of faces and indices if known by user. More...
 
void setIndexBufferInterleaved (int _numTris, int _indexSize, const void *_indices)
 Set index buffer for a triangle mesh. More...
 
void setFaceVerts (int _i, int _v0, int _v1, int _v2)
 Set vertex ids per triangle. More...
 
void setFaceVerts (int _i, int _faceSize, int *_v)
 Set vertex ids per face. More...
 
void setFaceNormals (int _i, int _v0, int _v1, int _v2)
 Set normal ids per triangle. More...
 
void setFaceNormals (int _i, int _faceSize, int *_v)
 Set normal ids per face. More...
 
void setFaceTexCoords (int _i, int _v0, int _v1, int _v2)
 Set texcoord ids per triangle. More...
 
void setFaceTexCoords (int _i, int _faceSize, int *_v)
 Set texcoord ids per face. More...
 
void setFaceAttrib (int _i, int _v0, int _v1, int _v2, int _attrID)
 Set attribute ids per triangle. More...
 
void setFaceAttrib (int _i, int _faceSize, int *_v, int _attrID)
 Set attribute ids per face. More...
 
Face Grouping and Subsets
void setFaceGroup (int _i, short _groupID)
 Specify face groups. More...
 
int findGroupSubset (int _groupID)
 get subset ID of a group More...
 
int getFaceGroup (int _faceID) const
 Get Face Group of the given face. More...
 
int getTriGroup (int _triID) const
 Get Group Id of the triangle. More...
 
int getNumSubsets () const
 Get the number of subsets. More...
 
const SubsetgetSubset (int _i) const
 get a specific subset More...
 
Mesh Compilation
void build (bool _weldVertices=false, bool _optimizeVCache=true, bool _needPerFaceAttribute=false, bool _keepIsolatedVertices=false)
 Build vertex + index buffer. More...
 
int getNumVertices () const
 
void setProvokingVertex (int _v)
 
int getProvokingVertex () const
 
void getVertexBuffer (void *_dst, const int _offset=0, const int _range=-1)
 Get vertex buffer ready for rendering. More...
 
const int * getIndexBuffer () const
 
void getIndexAdjBuffer (void *_dst, const int _borderIndex=-1)
 Get index buffer with adjacency information ready for rendering. More...
 
void getIndexAdjBuffer_BruteForce (void *_dst, const int _borderIndex=-1)
 Slow brute-force version of getIndexAdjBuffer. More...
 
int getNumTriangles () const
 
int getNumFaces () const
 
int getFaceSize (const int _i) const
 Get size of input face. More...
 
const VertexDeclarationgetVertexDeclaration () const
 
void getVertex (int _id, void *_out) const
 
int getIndex (int _i) const
 
Input/Output ID mapping
int mapToOriginalVertexID (const size_t _i, int &_faceID, int &_cornerID) const
 
int mapToOriginalFaceID (const int _triID) const
 
const int * mapToOriginalFaceIDPtr () const
 
int mapToDrawVertexID (const int _faceID, const int _cornerID) const
 
int mapToDrawTriID (const int _faceID, const int _k=0, int *_numTrisOut=0) const
 
Triangulation properties
bool isTriangleMesh () const
 
bool isFaceEdge (const int _triID, const int _edge) const
 

Private Member Functions

void computeAdjacency (bool _forceRecompute=false)
 
void splitVertices ()
 
void getInputFaceVertex (const int _face, const int _corner, int *_out) const
 
void getInputFaceVertex_Welded (const int _face, const int _corner, int *_out) const
 
void getInputFaceVertexData (const int _face, const int _corner, void *_out) const
 
int getInputIndex (const int &_face, const int &_corner, const int &_attrId) const
 
int getAdjVertexFaceCount (int _vertexID) const
 
int getAdjVertexFace (int _vertexID, int _k) const
 
int getInputIndexSplit (const int _face, const int _corner) const
 
void setInputIndexSplit (const int _face, const int _corner, const int _val)
 
int mapTriToInputFace (const int _tri) const
 
int getInputIndexOffset (const int _face, const int _corner) const
 
int getInputFaceOffset (const int _face) const
 
void prepareData ()
 build() preparation More...
 
void findIsolatedVertices ()
 
void forceUnsharedFaceVertex ()
 
void weldVertices ()
 
void fixWeldMap ()
 
void triangulate ()
 
void resolveTriangulation ()
 
void sortFacesByGroup ()
 
void optimize ()
 
void createVertexMap (bool _keepIsolatedVerts)
 
void createFaceMap ()
 

Private Attributes

VertexElementInput input_ [16]
 
int inputIDPos_
 
int inputIDNorm_
 
int inputIDTexC_
 
int numAttributes_
 
VertexDeclaration decl_
 
int numFaces_
 
int numIndices_
 
std::vector< int > faceStart_
 
std::vector< int > faceSize_
 
std::vector< int > faceData_
 
size_t maxFaceSize_
 
bool constantFaceSize_
 
std::vector< short > faceGroupIDs_
 
int curFaceInputPos_
 
MeshCompilerFaceInputfaceInput_
 
bool deleteFaceInputeData_
 
std::vector< int > faceBufSplit_
 
std::vector< int > faceSortMap_
 
int provokingVertex_
 
bool provokingVertexSetByUser_
 
int numTris_
 
std::vector< int > triIndexBuffer_
 
std::vector< int > isolatedVertices_
 
int numSubsets_
 
std::vector< Subsetsubsets_
 
std::map< int, int > subsetIDMap_
 
AdjacencyList adjacencyVert_
 
MeshCompilerVertexComparevertexCompare_
 
std::vector< int > vertexWeldMapFace_
 
std::vector< int > vertexWeldMapCorner_
 
VertexSplittersplitter_
 
std::vector< int > triToSortFaceMap_
 maps from triangle ID to sorted face ID More...
 
std::vector< int > triOptMap_
 maps from optimized tri ID to unoptimized tri ID More...
 
std::vector< int > vertexMapFace_
 vertex index in vbo -> input (face id, corner id) pair , also inverse of faceBufSplit_ More...
 
std::vector< int > vertexMapCorner_
 
std::vector< int > faceToTriMap_
 input face index -> output tri index More...
 
std::vector< int > faceToTriMapOffset_
 
std::vector< int > triToFaceMap_
 output tri index -> input face index More...
 
size_t numDrawVerts_
 
size_t numIsolatedVerts_
 
std::vector< int > indices_
 index buffer More...
 

Static Private Attributes

static MeshCompilerVertexCompare defaultVertexCompare
 

Detailed Description

Definition at line 240 of file MeshCompiler.hh.

Constructor & Destructor Documentation

◆ MeshCompiler()

ACG::MeshCompiler::MeshCompiler ( const VertexDeclaration _decl)
explicit

Definition at line 1107 of file MeshCompiler.cc.

◆ ~MeshCompiler()

ACG::MeshCompiler::~MeshCompiler ( )
virtual

Definition at line 1152 of file MeshCompiler.cc.

Member Function Documentation

◆ build()

void ACG::MeshCompiler::build ( bool  _weldVertices = false,
bool  _optimizeVCache = true,
bool  _needPerFaceAttribute = false,
bool  _keepIsolatedVertices = false 
)

Build vertex + index buffer.

Parameters
_weldVerticesCompare vertices and attempt to eliminate duplicates. High computation cost
_optimizeVCacheReorder faces for optimized vcache usage. High computation cost
_needPerFaceAttributeUser wants to set per-face attributes in draw vertex buffer. Per-face data can be stored in the provoking vertex of each face. Low computation cost
_keepIsolatedVerticesIsolated vertices should not be discarded in the output vertex buffer

Definition at line 1699 of file MeshCompiler.cc.

◆ checkInputData()

std::string ACG::MeshCompiler::checkInputData ( ) const

check for errors in input data

Definition at line 3830 of file MeshCompiler.cc.

◆ computeAdjacency()

void ACG::MeshCompiler::computeAdjacency ( bool  _forceRecompute = false)
private

Definition at line 154 of file MeshCompiler.cc.

◆ createFaceMap()

void ACG::MeshCompiler::createFaceMap ( )
private

Definition at line 3097 of file MeshCompiler.cc.

◆ createVertexMap()

void ACG::MeshCompiler::createVertexMap ( bool  _keepIsolatedVerts)
private

Definition at line 3042 of file MeshCompiler.cc.

◆ dbgdump()

void ACG::MeshCompiler::dbgdump ( const char *  _filename) const

dump mesh info to text file

Definition at line 2344 of file MeshCompiler.cc.

◆ dbgdumpAdjList()

void ACG::MeshCompiler::dbgdumpAdjList ( const char *  _filename) const

dump adjacency list to text file

Definition at line 3168 of file MeshCompiler.cc.

◆ dbgdumpInputBin()

void ACG::MeshCompiler::dbgdumpInputBin ( const char *  _filename,
bool  _seperateFiles = false 
) const

dump input mesh to binary file format

Definition at line 2706 of file MeshCompiler.cc.

◆ dbgdumpInputObj()

void ACG::MeshCompiler::dbgdumpInputObj ( const char *  _filename) const

dump input mesh to wavefront obj format

Definition at line 2619 of file MeshCompiler.cc.

◆ dbgdumpObj()

void ACG::MeshCompiler::dbgdumpObj ( const char *  _filename) const

dump mesh in wavefront obj format

Definition at line 2566 of file MeshCompiler.cc.

◆ dbgVerify()

bool ACG::MeshCompiler::dbgVerify ( const char *  _filename) const

test correctness of input <-> output id mappings, unshared per face vertex.. logs errors in file

Definition at line 2021 of file MeshCompiler.cc.

◆ findGroupSubset()

int ACG::MeshCompiler::findGroupSubset ( int  _groupID)

get subset ID of a group

Parameters
_groupIDId of the group
Returns
Subset Id

Definition at line 1942 of file MeshCompiler.cc.

◆ findIsolatedVertices()

void ACG::MeshCompiler::findIsolatedVertices ( )
private

Definition at line 578 of file MeshCompiler.cc.

◆ fixWeldMap()

void ACG::MeshCompiler::fixWeldMap ( )
private

Definition at line 558 of file MeshCompiler.cc.

◆ forceUnsharedFaceVertex()

void ACG::MeshCompiler::forceUnsharedFaceVertex ( )
private

Definition at line 788 of file MeshCompiler.cc.

◆ getAdjVertexFace()

int ACG::MeshCompiler::getAdjVertexFace ( int  _vertexID,
int  _k 
) const
private

Definition at line 4032 of file MeshCompiler.cc.

◆ getAdjVertexFaceCount()

int ACG::MeshCompiler::getAdjVertexFaceCount ( int  _vertexID) const
private

Definition at line 4027 of file MeshCompiler.cc.

◆ getFaceGroup()

int ACG::MeshCompiler::getFaceGroup ( int  _faceID) const

Get Face Group of the given face.

Parameters
_faceIDId of the face
Returns
Group Id

Definition at line 1934 of file MeshCompiler.cc.

◆ getFaceSize()

int ACG::MeshCompiler::getFaceSize ( const int  _i) const
inline

Get size of input face.

Parameters
_iIndex
Returns
Size

Definition at line 598 of file MeshCompiler.hh.

◆ getIndex()

int ACG::MeshCompiler::getIndex ( int  _i) const

Get index in final draw index buffer.

Definition at line 3035 of file MeshCompiler.cc.

◆ getIndexAdjBuffer()

void ACG::MeshCompiler::getIndexAdjBuffer ( void *  _dst,
const int  _borderIndex = -1 
)

Get index buffer with adjacency information ready for rendering.

This index buffer can be used to render in GL_TRIANGLES_ADJACENCY mode. For each triangle, it contains the 3 neighboring triangles with a shared edge in addition to the triangle vertices. Each triangle stores 6 indices: 0 - first vertex of triangle 1 - opposite vertex to first edge of adjacent triangle 2 - second vertex of triangle 3 - opposite vertex to second edge of adjacent triangle 4 - third vertex of triangle 5 - opposite vertex to third edge of adjacent triangle

5___4___3 \ /\ / \/__\/ 0\ /2 \/ 1

Parameters
_dst[out] Pointer to memory address where the 32bit index buffer should be copied to. Must have size of at least 6 * numTris * 4 bytes
_borderIndexindex to use for border edges (missing adjacent triangles)

Definition at line 3269 of file MeshCompiler.cc.

◆ getIndexAdjBuffer_BruteForce()

void ACG::MeshCompiler::getIndexAdjBuffer_BruteForce ( void *  _dst,
const int  _borderIndex = -1 
)

Slow brute-force version of getIndexAdjBuffer.

Computes index buffer with adjacency information, but uses a much simpler algorithm. Runtime = O(n^2), but this can be used to verify the result of getIndexAdjBuffer. Results from brute-force and optimized algorithm must be equal for meshes where no edge is shared by more than two triangles.

Parameters
_dst[out] Pointer to memory address where the 32bit index buffer should be copied to. Must have size of at least 6 * numTris * 4 bytes
_borderIndexindex to use for border edges (missing adjacent triangles)

Definition at line 3590 of file MeshCompiler.cc.

◆ getIndexAdjBuffer_MT()

void ACG::MeshCompiler::getIndexAdjBuffer_MT ( void *  _dst,
const int  _borderIndex = -1 
)

Multi-threaded version of getIndexAdjBuffer.

Uses a multi-threaded method based on the vertex-triangle adjacency list to compute the index buffer with adjacency.

Parameters
_dst[out] Pointer to memory address where the 32bit index buffer should be copied to. Must have size of at least 6 * numTris * 4 bytes
_borderIndexindex to use for border edges (missing adjacent triangles)

Definition at line 3454 of file MeshCompiler.cc.

◆ getIndexBuffer()

const int * ACG::MeshCompiler::getIndexBuffer ( ) const
inline

Get index buffer ready for rendering.

Definition at line 545 of file MeshCompiler.hh.

◆ getInputFaceOffset()

int ACG::MeshCompiler::getInputFaceOffset ( const int  _face) const
inlineprivate

Definition at line 987 of file MeshCompiler.hh.

◆ getInputFaceVertex()

void ACG::MeshCompiler::getInputFaceVertex ( const int  _face,
const int  _corner,
int *  _out 
) const
private

i: face index j: corner index _out: output vertex (index for each attribute)

Definition at line 1068 of file MeshCompiler.cc.

◆ getInputFaceVertex_Welded()

void ACG::MeshCompiler::getInputFaceVertex_Welded ( const int  _face,
const int  _corner,
int *  _out 
) const
private

i: face index j: corner index _out: output vertex (index for each attribute) post welding operation

Definition at line 1074 of file MeshCompiler.cc.

◆ getInputFaceVertexData()

void ACG::MeshCompiler::getInputFaceVertexData ( const int  _face,
const int  _corner,
void *  _out 
) const
private

i: face index j: corner index _out: output vertex address (vertex data)

Definition at line 1092 of file MeshCompiler.cc.

◆ getInputIndex()

int ACG::MeshCompiler::getInputIndex ( const int &  _face,
const int &  _corner,
const int &  _attrId 
) const
inlineprivate

Definition at line 724 of file MeshCompiler.hh.

◆ getInputIndexOffset()

int ACG::MeshCompiler::getInputIndexOffset ( const int  _face,
const int  _corner 
) const
private

Definition at line 1161 of file MeshCompiler.cc.

◆ getInputIndexSplit()

int ACG::MeshCompiler::getInputIndexSplit ( const int  _face,
const int  _corner 
) const
private

Definition at line 1183 of file MeshCompiler.cc.

◆ getMemoryUsage()

size_t ACG::MeshCompiler::getMemoryUsage ( bool  _printConsole = true) const

return memory consumption in bytes

Parameters
_printConsoleprint detailed memory costs to command console

Definition at line 3729 of file MeshCompiler.cc.

◆ getNumFaces()

int ACG::MeshCompiler::getNumFaces ( ) const

Get number of input faces.

Definition at line 4016 of file MeshCompiler.cc.

◆ getNumInputAttributes()

int ACG::MeshCompiler::getNumInputAttributes ( int  _attrIdx) const

Get number of attributes in an input buffer

Parameters
_attrIdxAttribute id from VertexDeclaration

Definition at line 1909 of file MeshCompiler.cc.

◆ getNumSubsets()

int ACG::MeshCompiler::getNumSubsets ( ) const
inline

Get the number of subsets.

Returns
Number of subsets

Definition at line 483 of file MeshCompiler.hh.

◆ getNumTriangles()

int ACG::MeshCompiler::getNumTriangles ( ) const
inline

Get number of triangles in final buffer.

Definition at line 587 of file MeshCompiler.hh.

◆ getNumVertices()

int ACG::MeshCompiler::getNumVertices ( ) const
inline

Get number of vertices in final buffer.

Definition at line 512 of file MeshCompiler.hh.

◆ getProvokingVertex()

int ACG::MeshCompiler::getProvokingVertex ( ) const
inline

See glProvokingVertex()

Returns
provoking vertex id

Definition at line 530 of file MeshCompiler.hh.

◆ getSubset()

const MeshCompiler::Subset * ACG::MeshCompiler::getSubset ( int  _i) const

get a specific subset

Parameters
_iId of the subset
Returns
The subset

Definition at line 1947 of file MeshCompiler.cc.

◆ getTriGroup()

int ACG::MeshCompiler::getTriGroup ( int  _triID) const

Get Group Id of the triangle.

Parameters
_triIDId of the triangle
Returns
Group of the triangle

◆ getVertex()

void ACG::MeshCompiler::getVertex ( int  _id,
void *  _out 
) const

Get vertex in final draw vertex buffer.

Definition at line 3006 of file MeshCompiler.cc.

◆ getVertexBuffer()

void ACG::MeshCompiler::getVertexBuffer ( void *  _dst,
const int  _offset = 0,
const int  _range = -1 
)

Get vertex buffer ready for rendering.

Query final vertex buffer data. Support vertex buffer batch uploads.

Parameters
_dst[out] Pointer to memory address where the vertex buffer should be copied to
_offsetBegin of vertex buffer batch
_rangeSize of vertex buffer batch. Copies rest of buffer if _range < 0.

Definition at line 3207 of file MeshCompiler.cc.

◆ getVertexDeclaration()

const VertexDeclaration * ACG::MeshCompiler::getVertexDeclaration ( ) const
inline

Get Vertex declaration.

Definition at line 605 of file MeshCompiler.hh.

◆ isFaceEdge()

bool ACG::MeshCompiler::isFaceEdge ( const int  _triID,
const int  _edge 
) const

Test if a triangle edge is a face edge from the input buffer.

When a convex n-poly is subdivided into (n-2) triangles, new edges are created which do not exist in the input mesh. This function identifies if an edge was already existant in the input mesh or added during triangulation.

Parameters
_triIDtriangle ID in draw buffer
_edgeedge of triangle, edge ordering: v0-v1, v1-v2, v2-v0
Returns
true if the edge is an edge from an input face, false otherwise

Definition at line 4042 of file MeshCompiler.cc.

◆ isTriangleMesh()

bool ACG::MeshCompiler::isTriangleMesh ( ) const

Test if the input mesh consists of triangles only.

Definition at line 4037 of file MeshCompiler.cc.

◆ mapToDrawTriID()

int ACG::MeshCompiler::mapToDrawTriID ( const int  _faceID,
const int  _k = 0,
int *  _numTrisOut = 0 
) const

Mapping from input Face id -> draw triangle id

Parameters
_faceIDFace ID in input data
_ktriangle no. associated to face, offset 0
_numTrisOut[out] Number of triangles associated to face (if input face was n-poly)
Returns
Draw Triangle ID in output vertex buffer

Definition at line 3716 of file MeshCompiler.cc.

◆ mapToDrawVertexID()

int ACG::MeshCompiler::mapToDrawVertexID ( const int  _faceID,
const int  _cornerID 
) const

Mapping from input vertex id -> draw vertex id

Parameters
_faceIDFace ID in input data
_cornerIDCorner of face
Returns
Draw Vertex ID in output vertex buffer

Definition at line 3711 of file MeshCompiler.cc.

◆ mapToOriginalFaceID()

int ACG::MeshCompiler::mapToOriginalFaceID ( const int  _triID) const

Mapping from draw tri id -> input face id

Parameters
_triIDTriangle ID in draw index buffer
Returns
Input Face ID

Definition at line 3660 of file MeshCompiler.cc.

◆ mapToOriginalFaceIDPtr()

const int * ACG::MeshCompiler::mapToOriginalFaceIDPtr ( ) const

Get pointer to the lookup table mapping from tri id -> input face id

Returns
ptr to address of lookup table with size getNumTriangles()

Definition at line 3677 of file MeshCompiler.cc.

◆ mapToOriginalVertexID()

int ACG::MeshCompiler::mapToOriginalVertexID ( const size_t  _i,
int &  _faceID,
int &  _cornerID 
) const

Mapping from draw vertex id -> input vertex id

Parameters
_iVertex ID in draw buffer
_faceID[out] Face ID in face input buffer
_cornerID[out] Corner of face corresponding to vertex.
Returns
Position ID in input buffer

Definition at line 3687 of file MeshCompiler.cc.

◆ mapTriToInputFace()

int ACG::MeshCompiler::mapTriToInputFace ( const int  _tri) const
private

Definition at line 1918 of file MeshCompiler.cc.

◆ optimize()

void ACG::MeshCompiler::optimize ( )
private

Definition at line 1642 of file MeshCompiler.cc.

◆ prepareData()

void ACG::MeshCompiler::prepareData ( )
private

build() preparation

Definition at line 3886 of file MeshCompiler.cc.

◆ resolveTriangulation()

void ACG::MeshCompiler::resolveTriangulation ( )
private

Definition at line 1531 of file MeshCompiler.cc.

◆ setAttrib()

void ACG::MeshCompiler::setAttrib ( int  _attrIdx,
int  _v,
const void *  _data 
)

Set single custom input attributes.

An internal buffer for the requested attribute must be allocated before using this function. See setAttribVec()

Parameters
_attrIdxAttribute id from VertexDeclaration
_vBuffer id of the single attribute
_dataattribute data

Definition at line 1894 of file MeshCompiler.cc.

◆ setAttribVec()

void ACG::MeshCompiler::setAttribVec ( int  _attrIdx,
size_t  _num,
const void *  _data,
size_t  _stride = 0,
bool  _internalCopy = false,
GLuint  _fmt = 0,
int  _elementSize = -1 
)

Set custom input attribute.

Alternatively allocates an internal buffer only, such that data can be provided via setAttrib().

Parameters
_attrIdxAttribute id from VertexDeclaration
_numNumber of attributes
_dataInput data buffer, may be null to only allocate an internal buffer
_strideOffset difference in bytes to the next attribute in _data. Default value 0 indicates no data alignment/memory packing.
_internalCopyCreate an internal buffer and make a copy _data
_fmtdata format of one element (must be set if input data does not match vertex declaration)
_elementSizenumber of elements per attribute (i.e. 3 for vec3 .., -1 if unknown)

Definition at line 269 of file MeshCompiler.cc.

◆ setFaceAttrib() [1/2]

void ACG::MeshCompiler::setFaceAttrib ( int  _i,
int  _faceSize,
int *  _v,
int  _attrID 
)

Set attribute ids per face.

Parameters
_iFace id
_faceSizeSize of face, ie. number of vertices of face
_vElement ids
_attrIDWhich attribute: index of VertexDeclaration element array

Definition at line 1217 of file MeshCompiler.cc.

◆ setFaceAttrib() [2/2]

void ACG::MeshCompiler::setFaceAttrib ( int  _i,
int  _v0,
int  _v1,
int  _v2,
int  _attrID 
)

Set attribute ids per triangle.

Parameters
_iFace id
_v01st element id
_v12nd element id
_v23rd element id
_attrIDWhich attribute: index of VertexDeclaration element array

Definition at line 1231 of file MeshCompiler.cc.

◆ setFaceGroup()

void ACG::MeshCompiler::setFaceGroup ( int  _i,
short  _groupID 
)

Specify face groups.

Faces with the same group ID will be chunked together in the sorting process. This feature may be used for material/texture subsets.

Parameters
_iFace ID
_groupIDCustom group ID

Definition at line 3199 of file MeshCompiler.cc.

◆ setFaceInput()

void ACG::MeshCompiler::setFaceInput ( MeshCompilerFaceInput _faceInput)

Set Face data input

Making use of the MeshCompilerFaceInput interface completly overrides the default input behavior. Any subsequent call to default input data functions such as setNumFaces(), setFaceVerts() etc. will be ignored

Parameters
_faceInputuser defined face input (no internal copy made, do not delete while using MeshCompiler)

Definition at line 3982 of file MeshCompiler.cc.

◆ setFaceNormals() [1/2]

void ACG::MeshCompiler::setFaceNormals ( int  _i,
int  _faceSize,
int *  _v 
)

Set normal ids per face.

Parameters
_iFace id
_faceSizeSize of face, ie. number of vertices of face
_vNormal ids

Definition at line 2983 of file MeshCompiler.cc.

◆ setFaceNormals() [2/2]

void ACG::MeshCompiler::setFaceNormals ( int  _i,
int  _v0,
int  _v1,
int  _v2 
)

Set normal ids per triangle.

Parameters
_iFace ID
_v01st normal id
_v12nd normal id
_v23rd normal id

Definition at line 2988 of file MeshCompiler.cc.

◆ setFaceTexCoords() [1/2]

void ACG::MeshCompiler::setFaceTexCoords ( int  _i,
int  _faceSize,
int *  _v 
)

Set texcoord ids per face.

Parameters
_iFace id
_faceSizeSize of face, ie. number of vertices of face
_vTexcoord ids

Definition at line 2995 of file MeshCompiler.cc.

◆ setFaceTexCoords() [2/2]

void ACG::MeshCompiler::setFaceTexCoords ( int  _i,
int  _v0,
int  _v1,
int  _v2 
)

Set texcoord ids per triangle.

Parameters
_iFace ID
_v01st texcoord id
_v12nd texcoord id
_v23rd texcoord id

Definition at line 3000 of file MeshCompiler.cc.

◆ setFaceVerts() [1/2]

void ACG::MeshCompiler::setFaceVerts ( int  _i,
int  _faceSize,
int *  _v 
)

Set vertex ids per face.

Parameters
_iFace id
_faceSizeSize of face, ie. number of vertices of face
_vVertex ids

Definition at line 2972 of file MeshCompiler.cc.

◆ setFaceVerts() [2/2]

void ACG::MeshCompiler::setFaceVerts ( int  _i,
int  _v0,
int  _v1,
int  _v2 
)

Set vertex ids per triangle.

Parameters
_iFace ID
_v01st vertex id
_v12nd vertex id
_v23rd vertex id

Definition at line 2977 of file MeshCompiler.cc.

◆ setIndexBufferInterleaved()

void ACG::MeshCompiler::setIndexBufferInterleaved ( int  _numTris,
int  _indexSize,
const void *  _indices 
)

Set index buffer for a triangle mesh.

This should only be used if the input vertex buffer is interleaved already.

Parameters
_numTrisNumber of triangles.
_indexSizeSize in bytes of one index.
_indicesPointer to a buffer containing the index data.

Definition at line 3987 of file MeshCompiler.cc.

◆ setInputIndexSplit()

void ACG::MeshCompiler::setInputIndexSplit ( const int  _face,
const int  _corner,
const int  _val 
)
private

Definition at line 1172 of file MeshCompiler.cc.

◆ setNormals()

void ACG::MeshCompiler::setNormals ( size_t  _num,
const void *  _data,
size_t  _stride = 0,
bool  _internalCopy = false,
GLuint  _fmt = 0,
int  _elementSize = -1 
)

set input normals

Parameters
_numNumber of normals
_dataPointer to normals data
_strideDifference in bytes between two normals positions in _data. Default value 0 indicates a tight float3 position array without any other data or memory alignment.
_internalCopyMemory optimization flag: select true if the provided data address is only temporarily valid. Otherwise an internal copy must be made.
_fmtdata format of one element (must be set if input data does not match vertex declaration)
_elementSizenumber of elements per attribute (i.e. 3 for vec3 .., -1 if unknown)

Definition at line 258 of file MeshCompiler.cc.

◆ setNumFaces()

void ACG::MeshCompiler::setNumFaces ( const int  _numFaces,
const int  _numIndices 
)

Set number of faces and indices if known by user.

User may give a rough estimate of face/index count. A more accurate estimation improves efficiency: too low numbers result in performance hit, too high numbers in memory consumption

Parameters
_numFacesNumber of faces. Value 0 accepted at cost of performance
_numIndicesNumber of indices, i.e. 3 * numFaces for triangle meshes. Value 0 accepted at cost of performance

Definition at line 1202 of file MeshCompiler.cc.

◆ setProvokingVertex()

void ACG::MeshCompiler::setProvokingVertex ( int  _v)

See glProvokingVertex()

Specifiy the vertex to be used as the source of data for flat shading. The default value is 2, meaning that the last vertex of each triangle will be used. setProvokingVertex() must be called prior to build(), if a different provoking vertex is desired. Additionally build() has to set its _needPerFaceAttribute parameter to true to enable provoking vertices. The provoking vertex of a face is a vertex, which is not shared with any other face in the mesh.

Parameters
_vtriangle vertex where the provoking vertex should be stored [0, 1, 2]

Definition at line 4021 of file MeshCompiler.cc.

◆ setTexCoords()

void ACG::MeshCompiler::setTexCoords ( size_t  _num,
const void *  _data,
size_t  _stride = 0,
bool  _internalCopy = false,
GLuint  _fmt = 0,
int  _elementSize = -1 
)

set input texture coords

Parameters
_numNumber of texture coords
_dataPointer to texture coord data
_strideDifference in bytes between two texture coordinate positions in _data. Default value 0 indicates a tight float3 position array without any other data or memory alignment.
_internalCopyMemory optimization flag: select true if the provided data address is only temporarily valid. Otherwise an internal copy must be made.
_fmtdata format of one element (must be set if input data does not match vertex declaration)
_elementSizenumber of elements per attribute (i.e. 3 for vec3 .., -1 if unknown)

Definition at line 263 of file MeshCompiler.cc.

◆ setVertices()

void ACG::MeshCompiler::setVertices ( size_t  _num,
const void *  _data,
size_t  _stride = 0,
bool  _internalCopy = false,
GLuint  _fmt = 0,
int  _elementSize = -1 
)

set input vertex positions

Parameters
_numNumber of vertex positions
_dataPointer to vertex data
_strideDifference in bytes between two vertex positions in _data. Default value 0 indicates a tight float3 position array without any other data or memory alignment.
_internalCopyMemory optimization flag: select true if the provided data address is only temporarily valid. Otherwise an internal copy must be made.
_fmtdata format of one element (must be set if input data does not match vertex declaration)
_elementSizenumber of elements per attribute (i.e. 3 for vec3 .., -1 if unknown)

Definition at line 253 of file MeshCompiler.cc.

◆ sortFacesByGroup()

void ACG::MeshCompiler::sortFacesByGroup ( )
private

Definition at line 1571 of file MeshCompiler.cc.

◆ splitVertices()

void ACG::MeshCompiler::splitVertices ( )
private

Definition at line 601 of file MeshCompiler.cc.

◆ triangulate()

void ACG::MeshCompiler::triangulate ( )
private

Definition at line 1401 of file MeshCompiler.cc.

◆ vertexToString()

std::string ACG::MeshCompiler::vertexToString ( const void *  v) const

interpret vertex data according declaration and write to string

Definition at line 1952 of file MeshCompiler.cc.

◆ weldVertices()

void ACG::MeshCompiler::weldVertices ( )
private

Definition at line 376 of file MeshCompiler.cc.

Member Data Documentation

◆ adjacencyVert_

AdjacencyList ACG::MeshCompiler::adjacencyVert_
private

Definition at line 851 of file MeshCompiler.hh.

◆ constantFaceSize_

bool ACG::MeshCompiler::constantFaceSize_
private

Definition at line 798 of file MeshCompiler.hh.

◆ curFaceInputPos_

int ACG::MeshCompiler::curFaceInputPos_
private

Definition at line 800 of file MeshCompiler.hh.

◆ decl_

VertexDeclaration ACG::MeshCompiler::decl_
private

Definition at line 786 of file MeshCompiler.hh.

◆ defaultVertexCompare

MeshCompilerVertexCompare ACG::MeshCompiler::defaultVertexCompare
staticprivate

Definition at line 880 of file MeshCompiler.hh.

◆ deleteFaceInputeData_

bool ACG::MeshCompiler::deleteFaceInputeData_
private

Definition at line 803 of file MeshCompiler.hh.

◆ faceBufSplit_

std::vector<int> ACG::MeshCompiler::faceBufSplit_
private

Definition at line 805 of file MeshCompiler.hh.

◆ faceData_

std::vector<int> ACG::MeshCompiler::faceData_
private

Definition at line 796 of file MeshCompiler.hh.

◆ faceGroupIDs_

std::vector<short> ACG::MeshCompiler::faceGroupIDs_
private

Definition at line 799 of file MeshCompiler.hh.

◆ faceInput_

MeshCompilerFaceInput* ACG::MeshCompiler::faceInput_
private

Definition at line 802 of file MeshCompiler.hh.

◆ faceSize_

std::vector<int> ACG::MeshCompiler::faceSize_
private

Definition at line 795 of file MeshCompiler.hh.

◆ faceSortMap_

std::vector<int> ACG::MeshCompiler::faceSortMap_
private

Definition at line 806 of file MeshCompiler.hh.

◆ faceStart_

std::vector<int> ACG::MeshCompiler::faceStart_
private

Definition at line 794 of file MeshCompiler.hh.

◆ faceToTriMap_

std::vector<int> ACG::MeshCompiler::faceToTriMap_
private

input face index -> output tri index

Definition at line 957 of file MeshCompiler.hh.

◆ faceToTriMapOffset_

std::vector<int> ACG::MeshCompiler::faceToTriMapOffset_
private

Definition at line 958 of file MeshCompiler.hh.

◆ indices_

std::vector<int> ACG::MeshCompiler::indices_
private

index buffer

Definition at line 974 of file MeshCompiler.hh.

◆ input_

VertexElementInput ACG::MeshCompiler::input_[16]
private

Definition at line 778 of file MeshCompiler.hh.

◆ inputIDNorm_

int ACG::MeshCompiler::inputIDNorm_
private

Definition at line 782 of file MeshCompiler.hh.

◆ inputIDPos_

int ACG::MeshCompiler::inputIDPos_
private

Definition at line 781 of file MeshCompiler.hh.

◆ inputIDTexC_

int ACG::MeshCompiler::inputIDTexC_
private

Definition at line 783 of file MeshCompiler.hh.

◆ isolatedVertices_

std::vector<int> ACG::MeshCompiler::isolatedVertices_
private

Definition at line 814 of file MeshCompiler.hh.

◆ maxFaceSize_

size_t ACG::MeshCompiler::maxFaceSize_
private

Definition at line 797 of file MeshCompiler.hh.

◆ numAttributes_

int ACG::MeshCompiler::numAttributes_
private

Definition at line 785 of file MeshCompiler.hh.

◆ numDrawVerts_

size_t ACG::MeshCompiler::numDrawVerts_
private

vertices in vbo

Definition at line 968 of file MeshCompiler.hh.

◆ numFaces_

int ACG::MeshCompiler::numFaces_
private

Definition at line 791 of file MeshCompiler.hh.

◆ numIndices_

int ACG::MeshCompiler::numIndices_
private

Definition at line 792 of file MeshCompiler.hh.

◆ numIsolatedVerts_

size_t ACG::MeshCompiler::numIsolatedVerts_
private

isolated vertices

Definition at line 971 of file MeshCompiler.hh.

◆ numSubsets_

int ACG::MeshCompiler::numSubsets_
private

Definition at line 817 of file MeshCompiler.hh.

◆ numTris_

int ACG::MeshCompiler::numTris_
private

Definition at line 810 of file MeshCompiler.hh.

◆ provokingVertex_

int ACG::MeshCompiler::provokingVertex_
private

Definition at line 807 of file MeshCompiler.hh.

◆ provokingVertexSetByUser_

bool ACG::MeshCompiler::provokingVertexSetByUser_
private

Definition at line 808 of file MeshCompiler.hh.

◆ splitter_

VertexSplitter* ACG::MeshCompiler::splitter_
private

Definition at line 939 of file MeshCompiler.hh.

◆ subsetIDMap_

std::map<int, int> ACG::MeshCompiler::subsetIDMap_
private

Definition at line 819 of file MeshCompiler.hh.

◆ subsets_

std::vector<Subset> ACG::MeshCompiler::subsets_
private

Definition at line 818 of file MeshCompiler.hh.

◆ triIndexBuffer_

std::vector<int> ACG::MeshCompiler::triIndexBuffer_
private

Definition at line 811 of file MeshCompiler.hh.

◆ triOptMap_

std::vector<int> ACG::MeshCompiler::triOptMap_
private

maps from optimized tri ID to unoptimized tri ID

Definition at line 949 of file MeshCompiler.hh.

◆ triToFaceMap_

std::vector<int> ACG::MeshCompiler::triToFaceMap_
private

output tri index -> input face index

Definition at line 961 of file MeshCompiler.hh.

◆ triToSortFaceMap_

std::vector<int> ACG::MeshCompiler::triToSortFaceMap_
private

maps from triangle ID to sorted face ID

Definition at line 946 of file MeshCompiler.hh.

◆ vertexCompare_

MeshCompilerVertexCompare* ACG::MeshCompiler::vertexCompare_
private

Definition at line 881 of file MeshCompiler.hh.

◆ vertexMapCorner_

std::vector<int> ACG::MeshCompiler::vertexMapCorner_
private

Definition at line 954 of file MeshCompiler.hh.

◆ vertexMapFace_

std::vector<int> ACG::MeshCompiler::vertexMapFace_
private

vertex index in vbo -> input (face id, corner id) pair , also inverse of faceBufSplit_

Definition at line 953 of file MeshCompiler.hh.

◆ vertexWeldMapCorner_

std::vector<int> ACG::MeshCompiler::vertexWeldMapCorner_
private

Definition at line 886 of file MeshCompiler.hh.

◆ vertexWeldMapFace_

std::vector<int> ACG::MeshCompiler::vertexWeldMapFace_
private

Definition at line 885 of file MeshCompiler.hh.


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