47 #include "VertexDeclaration.hh" 55 #include <ACG/GL/gl.hh> 137 virtual int getNumFaces()
const = 0;
143 virtual int getNumIndices()
const = 0;
148 virtual int getFaceSize(
const int _faceID)
const = 0;
157 virtual int getSingleFaceAttr(
const int _faceID,
const int _faceCorner,
const int _attrID)
const;
165 virtual bool getFaceAttr(
const int _faceID,
const int _attrID,
int* _out)
const {
return false;}
172 virtual int*
getFaceAttr(
const int _faceID,
const int _attrID)
const {
return 0;}
199 int getNumFaces()
const override {
return numFaces_;}
202 int getFaceSize(
const int _faceID)
const override {
return faceSize_[_faceID];}
204 int getSingleFaceAttr(
const int _faceID,
const int _faceCorner,
const int _attrID)
const override;
206 bool getFaceAttr(
const int _faceID,
const int _attrID,
int* _out)
const override;
208 void dbgWriteToObjFile(FILE* _file,
int _posAttrID = 0,
int _normalAttrID = -1,
int _texcAttrID = -1);
211 void setFaceData(
int _faceID,
int _size,
int* _data,
int _attrID = 0);
220 std::vector<int> faceOffset_;
221 std::vector<int> faceSize_;
224 std::vector<int> faceData_[16];
234 virtual bool equalVertex(
const void* v0,
const void* v1,
const VertexDeclaration* _decl);
262 void setVertices(
size_t _num,
const void* _data,
size_t _stride = 0,
bool _internalCopy =
false, GLuint _fmt = 0,
int _elementSize = -1);
273 void setNormals(
size_t _num,
const void* _data,
size_t _stride = 0,
bool _internalCopy =
false, GLuint _fmt = 0,
int _elementSize = -1);
284 void setTexCoords(
size_t _num,
const void* _data,
size_t _stride = 0,
bool _internalCopy =
false, GLuint _fmt = 0,
int _elementSize = -1);
297 void setAttribVec(
int _attrIdx,
size_t _num,
const void* _data,
size_t _stride = 0,
bool _internalCopy =
false, GLuint _fmt = 0,
int _elementSize = -1);
306 void setAttrib(
int _attrIdx,
int _v,
const void* _data);
313 int getNumInputAttributes(
int _attrIdx)
const;
346 void setNumFaces(
const int _numFaces,
const int _numIndices);
356 void setIndexBufferInterleaved(
int _numTris,
int _indexSize,
const void* _indices);
365 void setFaceVerts(
int _i,
int _v0,
int _v1,
int _v2);
373 void setFaceVerts(
int _i,
int _faceSize,
int* _v);
382 void setFaceNormals(
int _i,
int _v0,
int _v1,
int _v2);
390 void setFaceNormals(
int _i,
int _faceSize,
int* _v);
399 void setFaceTexCoords(
int _i,
int _v0,
int _v1,
int _v2);
407 void setFaceTexCoords(
int _i,
int _faceSize,
int* _v);
418 void setFaceAttrib(
int _i,
int _v0,
int _v1,
int _v2,
int _attrID);
427 void setFaceAttrib(
int _i,
int _faceSize,
int* _v,
int _attrID);
445 void setFaceGroup(
int _i,
short _groupID);
451 unsigned int startIndex;
452 unsigned int numTris;
454 unsigned int numFaces;
455 unsigned int startFace;
463 int findGroupSubset(
int _groupID);
470 int getFaceGroup(
int _faceID)
const;
477 int getTriGroup(
int _triID)
const;
490 const Subset* getSubset(
int _i)
const;
508 void build(
bool _weldVertices =
false,
bool _optimizeVCache =
true,
bool _needPerFaceAttribute =
false,
bool _keepIsolatedVertices =
false);
524 void setProvokingVertex(
int _v);
541 void getVertexBuffer(
void* _dst,
const int _offset = 0,
const int _range = -1);
571 void getIndexAdjBuffer(
void* _dst,
const int _borderIndex = -1);
582 void getIndexAdjBuffer_BruteForce(
void* _dst,
const int _borderIndex = -1);
591 int getNumFaces()
const;
600 return int(faceSize_.empty() ? maxFaceSize_ : faceSize_[_i]);
609 void getVertex(
int _id,
void* _out)
const;
613 int getIndex(
int _i)
const;
633 int mapToOriginalVertexID(
const size_t _i,
int& _faceID,
int& _cornerID)
const;
640 int mapToOriginalFaceID(
const int _triID)
const;
646 const int* mapToOriginalFaceIDPtr()
const;
654 int mapToDrawVertexID(
const int _faceID,
const int _cornerID)
const;
663 int mapToDrawTriID(
const int _faceID,
const int _k = 0,
int* _numTrisOut = 0)
const;
676 bool isTriangleMesh()
const;
686 bool isFaceEdge(
const int _triID,
const int _edge)
const;
696 void computeAdjacency(
bool _forceRecompute =
false);
699 void splitVertices();
709 void getInputFaceVertex(
const int _face,
const int _corner,
int* _out)
const;
715 void getInputFaceVertex_Welded(
const int _face,
const int _corner,
int* _out)
const;
721 void getInputFaceVertexData(
const int _face,
const int _corner,
void* _out)
const;
724 inline int getInputIndex(
const int& _face,
const int& _corner,
const int& _attrId )
const 726 return faceInput_->getSingleFaceAttr(_face, _corner, _attrId);
745 ~VertexElementInput();
774 void getElementData(
int _idx,
void* _dst,
const VertexElement* _desc)
const;
794 std::vector<int> faceStart_;
795 std::vector<int> faceSize_;
796 std::vector<int> faceData_;
798 bool constantFaceSize_;
799 std::vector<short> faceGroupIDs_;
800 int curFaceInputPos_;
803 bool deleteFaceInputeData_;
805 std::vector<int> faceBufSplit_;
806 std::vector<int> faceSortMap_;
807 int provokingVertex_;
808 bool provokingVertexSetByUser_;
811 std::vector<int> triIndexBuffer_;
814 std::vector<int> isolatedVertices_;
818 std::vector<Subset> subsets_;
819 std::map<int, int> subsetIDMap_;
826 : start(0), count(0), buf(0), bufSize(0), num(0) {}
835 int getAdj(
int i,
int k)
const;
836 int getCount(
int i)
const;
841 unsigned char* count;
847 void dbgdump(std::ofstream& file)
const;
854 int getAdjVertexFaceCount(
int _vertexID)
const;
855 int getAdjVertexFace(
int _vertexID,
int _k)
const;
869 void add(
const int _face,
const int _corner);
871 std::vector< WeldListEntry > list;
885 std::vector<int> vertexWeldMapFace_;
886 std::vector<int> vertexWeldMapCorner_;
895 int numWorstCase = 0,
896 float estBufferIncrease = 0.5f);
901 int split(
int* vertex);
904 bool isIsolated(
const int vertexPosID);
929 int getNext(
const int id);
930 int* getAttribs(
const int id);
931 void setNext(
const int id,
const int next);
932 void setAttribs(
const int id,
int* attr);
954 std::vector<int> vertexMapCorner_;
958 std::vector<int> faceToTriMapOffset_;
979 int getInputIndexSplit(
const int _face,
const int _corner)
const;
981 void setInputIndexSplit(
const int _face,
const int _corner,
const int _val);
983 int mapTriToInputFace(
const int _tri)
const;
985 int getInputIndexOffset(
const int _face,
const int _corner)
const;
987 inline int getInputFaceOffset(
const int _face)
const 989 return int(faceStart_.empty() ? maxFaceSize_ * _face : faceStart_[_face]);
996 void findIsolatedVertices();
1000 void forceUnsharedFaceVertex();
1003 void weldVertices();
1012 void resolveTriangulation();
1015 void sortFacesByGroup();
1021 void createVertexMap(
bool _keepIsolatedVerts);
1024 void createFaceMap();
1035 void getIndexAdjBuffer_MT(
void* _dst,
const int _borderIndex = -1);
1040 void dbgdump(
const char* _filename)
const;
1043 void dbgdumpObj(
const char* _filename)
const;
1046 void dbgdumpInputBin(
const char* _filename,
bool _seperateFiles =
false)
const;
1049 void dbgdumpInputObj(
const char* _filename)
const;
1052 void dbgdumpAdjList(
const char* _filename)
const;
1055 bool dbgVerify(
const char* _filename)
const;
1058 std::string vertexToString(
const void* v)
const;
1062 size_t getMemoryUsage(
bool _printConsole =
true)
const;
1065 std::string checkInputData()
const;
size_t numDrawVerts_
vertices in vbo
const int numBaseVerts
number of input vertex positions
const int * getIndexBuffer() const
std::vector< int > indices_
index buffer
Namespace providing different geometric functions concerning angles.
Class to define the vertex input layout.
int getNumVertices() const
size_t numIsolatedVerts_
isolated vertices
Description of one vertex element.
std::vector< int > triToFaceMap_
output tri index -> input face index
std::vector< int > triToSortFaceMap_
maps from triangle ID to sorted face ID
std::vector< int > splits
int getFaceSize(const int _i) const
Get size of input face.
int getProvokingVertex() const
int getNumSubsets() const
Get the number of subsets.
std::vector< int > vertexMapFace_
vertex index in vbo -> input (face id, corner id) pair , also inverse of faceBufSplit_ ...
int numVerts
number of vertex combinations currently in use
int getNumTriangles() const
const VertexDeclaration * getVertexDeclaration() const
std::vector< int > faceToTriMap_
input face index -> output tri index
std::vector< int > triOptMap_
maps from optimized tri ID to unoptimized tri ID