53 #include "VertexDeclaration.hh"
61 #include <ACG/GL/gl.hh>
143 virtual int getNumFaces()
const = 0;
149 virtual int getNumIndices()
const = 0;
154 virtual int getFaceSize(
const int _faceID)
const = 0;
163 virtual int getSingleFaceAttr(
const int _faceID,
const int _faceCorner,
const int _attrID)
const;
171 virtual bool getFaceAttr(
const int _faceID,
const int _attrID,
int* _out)
const {
return false;}
178 virtual int*
getFaceAttr(
const int _faceID,
const int _attrID)
const {
return 0;}
205 int getNumFaces()
const {
return numFaces_;}
208 int getFaceSize(
const int _faceID)
const {
return faceSize_[_faceID];}
210 int getSingleFaceAttr(
const int _faceID,
const int _faceCorner,
const int _attrID)
const;
212 bool getFaceAttr(
const int _faceID,
const int _attrID,
int* _out)
const;
214 void dbgWriteToObjFile(FILE* _file,
int _posAttrID = 0,
int _normalAttrID = -1,
int _texcAttrID = -1);
217 void setFaceData(
int _faceID,
int _size,
int* _data,
int _attrID = 0);
226 std::vector<int> faceOffset_;
227 std::vector<int> faceSize_;
230 std::vector<int> faceData_[16];
240 virtual bool equalVertex(
const void* v0,
const void* v1,
const VertexDeclaration* _decl);
268 void setVertices(
int _num,
const void* _data,
int _stride = 0,
bool _internalCopy =
false, GLuint _fmt = 0,
int _elementSize = -1);
279 void setNormals(
int _num,
const void* _data,
int _stride = 0,
bool _internalCopy =
false, GLuint _fmt = 0,
int _elementSize = -1);
290 void setTexCoords(
int _num,
const void* _data,
int _stride = 0,
bool _internalCopy =
false, GLuint _fmt = 0,
int _elementSize = -1);
303 void setAttribVec(
int _attrIdx,
int _num,
const void* _data,
int _stride = 0,
bool _internalCopy =
false, GLuint _fmt = 0,
int _elementSize = -1);
312 void setAttrib(
int _attrIdx,
int _v,
const void* _data);
319 int getNumInputAttributes(
int _attrIdx)
const;
352 void setNumFaces(
const int _numFaces,
const int _numIndices);
362 void setIndexBufferInterleaved(
int _numTris,
int _indexSize,
const void* _indices);
371 void setFaceVerts(
int _i,
int _v0,
int _v1,
int _v2);
379 void setFaceVerts(
int _i,
int _faceSize,
int* _v);
388 void setFaceNormals(
int _i,
int _v0,
int _v1,
int _v2);
396 void setFaceNormals(
int _i,
int _faceSize,
int* _v);
405 void setFaceTexCoords(
int _i,
int _v0,
int _v1,
int _v2);
413 void setFaceTexCoords(
int _i,
int _faceSize,
int* _v);
424 void setFaceAttrib(
int _i,
int _v0,
int _v1,
int _v2,
int _attrID);
433 void setFaceAttrib(
int _i,
int _faceSize,
int* _v,
int _attrID);
451 void setFaceGroup(
int _i,
short _groupID);
457 unsigned int startIndex;
458 unsigned int numTris;
460 unsigned int numFaces;
461 unsigned int startFace;
469 int findGroupSubset(
int _groupID);
476 int getFaceGroup(
int _faceID)
const;
483 int getTriGroup(
int _triID)
const;
496 const Subset* getSubset(
int _i)
const;
514 void build(
bool _weldVertices =
false,
bool _optimizeVCache =
true,
bool _needPerFaceAttribute =
false,
bool _keepIsolatedVertices =
false);
530 void setProvokingVertex(
int _v);
547 void getVertexBuffer(
void* _dst,
const int _offset = 0,
const int _range = -1);
577 void getIndexAdjBuffer(
void* _dst,
const int _borderIndex = -1);
588 void getIndexAdjBuffer_BruteForce(
void* _dst,
const int _borderIndex = -1);
597 int getNumFaces()
const;
606 return int(faceSize_.empty() ? maxFaceSize_ : faceSize_[_i]);
615 void getVertex(
int _id,
void* _out)
const;
619 int getIndex(
int _i)
const;
639 int mapToOriginalVertexID(
const int _i,
int& _faceID,
int& _cornerID)
const;
646 int mapToOriginalFaceID(
const int _triID)
const;
652 const int* mapToOriginalFaceIDPtr()
const;
660 int mapToDrawVertexID(
const int _faceID,
const int _cornerID)
const;
669 int mapToDrawTriID(
const int _faceID,
const int _k = 0,
int* _numTrisOut = 0)
const;
682 bool isTriangleMesh()
const;
692 bool isFaceEdge(
const int _triID,
const int _edge)
const;
702 void computeAdjacency();
705 void splitVertices();
715 void getInputFaceVertex(
const int _face,
const int _corner,
int* _out)
const;
721 void getInputFaceVertex_Welded(
const int _face,
const int _corner,
int* _out)
const;
727 void getInputFaceVertexData(
const int _face,
const int _corner,
void* _out)
const;
730 inline int getInputIndex(
const int& _face,
const int& _corner,
const int& _attrId )
const
732 return faceInput_->getSingleFaceAttr(_face, _corner, _attrId);
751 ~VertexElementInput();
780 void getElementData(
int _idx,
void* _dst,
const VertexElement* _desc)
const;
800 std::vector<int> faceStart_;
801 std::vector<int> faceSize_;
802 std::vector<int> faceData_;
804 bool constantFaceSize_;
805 std::vector<short> faceGroupIDs_;
806 int curFaceInputPos_;
809 bool deleteFaceInputeData_;
811 std::vector<int> faceBufSplit_;
812 std::vector<int> faceSortMap_;
813 int provokingVertex_;
814 bool provokingVertexSetByUser_;
817 std::vector<int> triIndexBuffer_;
820 std::vector<int> isolatedVertices_;
824 std::vector<Subset> subsets_;
825 std::map<int, int> subsetIDMap_;
832 : start(0), count(0), buf(0), bufSize(0), num(0) {}
841 int getAdj(
int i,
int k)
const;
842 int getCount(
int i)
const;
847 unsigned char* count;
853 void dbgdump(std::ofstream& file)
const;
860 int getAdjVertexFaceCount(
int _vertexID)
const;
861 int getAdjVertexFace(
int _vertexID,
int _k)
const;
875 void add(
const int _face,
const int _corner);
877 std::vector< WeldListEntry > list;
891 std::vector<int> vertexWeldMapFace_;
892 std::vector<int> vertexWeldMapCorner_;
901 int numWorstCase = 0,
902 float estBufferIncrease = 0.5f);
907 int split(
int* vertex);
910 bool isIsolated(
const int vertexPosID);
935 int getNext(
const int id);
936 int* getAttribs(
const int id);
937 void setNext(
const int id,
const int next);
938 void setAttribs(
const int id,
int* attr);
960 std::vector<int> vertexMapCorner_;
964 std::vector<int> faceToTriMapOffset_;
985 int getInputIndexSplit(
const int _face,
const int _corner)
const;
987 void setInputIndexSplit(
const int _face,
const int _corner,
const int _val);
989 int mapTriToInputFace(
const int _tri)
const;
991 int getInputIndexOffset(
const int _face,
const int _corner)
const;
993 inline int getInputFaceOffset(
const int _face)
const
995 return int(faceStart_.empty() ? maxFaceSize_ * _face : faceStart_[_face]);
1002 void findIsolatedVertices();
1006 void forceUnsharedFaceVertex();
1009 void weldVertices();
1018 void resolveTriangulation();
1021 void sortFacesByGroup();
1027 void createVertexMap(
bool _keepIsolatedVerts);
1030 void createFaceMap();
1041 void getIndexAdjBuffer_MT(
void* _dst,
const int _borderIndex = -1);
1046 void dbgdump(
const char* _filename)
const;
1049 void dbgdumpObj(
const char* _filename)
const;
1052 void dbgdumpInputBin(
const char* _filename,
bool _seperateFiles =
false)
const;
1055 void dbgdumpInputObj(
const char* _filename)
const;
1058 void dbgdumpAdjList(
const char* _filename)
const;
1061 bool dbgVerify(
const char* _filename)
const;
1064 std::string vertexToString(
const void* v)
const;
1068 size_t getMemoryUsage(
bool _printConsole =
true)
const;
1071 std::string checkInputData()
const;
const int numBaseVerts
number of input vertex positions
int attrSize
size in bytes of one attribute
int getNumVertices() const
std::vector< int > faceToTriMap_
input face index -> output tri index
Namespace providing different geometric functions concerning angles.
int getNumSubsets() const
Get the number of subsets.
int stride
offset in bytes from one element to the next
int getProvokingVertex() const
int numIsolatedVerts_
isolated vertices
GLuint fmt
element data format
int getNumTriangles() const
std::vector< int > vertexMapFace_
vertex index in vbo -> input (face id, corner id) pair , also inverse of faceBufSplit_ ...
char * internalBuf
mem alloc if attribute buffer managed by this class
Description of one vertex element.
const VertexDeclaration * getVertexDeclaration() const
int numDrawVerts_
vertices in vbo
std::vector< int > splits
virtual int getVertexAdjFace(const int _vertexID, const int _k) const
int elementSize
number of ints/floats/bytes per element
std::vector< int > indices_
index buffer
virtual bool getFaceAttr(const int _faceID, const int _attrID, int *_out) const
int count
elements in buffer
virtual int * getFaceAttr(const int _faceID, const int _attrID) const
Class to define the vertex input layout.
int numVerts
number of vertex combinations currently in use
std::vector< int > triToSortFaceMap_
maps from triangle ID to sorted face ID
std::vector< int > triToFaceMap_
output tri index -> input face index
std::vector< int > triOptMap_
maps from optimized tri ID to unoptimized tri ID
int getFaceSize(const int _i) const
Get size of input face.
virtual int getVertexAdjCount(const int _vertexID) const
int getNumIndices() const
int getFaceSize(const int _faceID) const
const int * getIndexBuffer() const