Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DrawMesh.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50
51
52 //=============================================================================
53 //
54 // CLASS DrawMeshT
55 //
56 //=============================================================================
57
58
59 #ifndef ACG_DRAW_MESH_HH
60 #define ACG_DRAW_MESH_HH
61
62
63 //== INCLUDES =================================================================
64
65 #include <vector>
66 #include <list>
67 #include <OpenMesh/Core/Utils/Property.hh>
68 #include <OpenMesh/Core/IO/MeshIO.hh>
69
70 #include <ACG/GL/globjects.hh>
71 #include <ACG/GL/GLState.hh>
72 #include <ACG/GL/IRenderer.hh>
73 #include <ACG/GL/MeshCompiler.hh>
74 #include <ACG/ShaderUtils/GLSLShader.hh>
75
76 #include <ACG/Config/ACGDefines.hh>
77
78 //== FORWARDDECLARATIONS ======================================================
79
80
81 //== NAMESPACES ===============================================================
82
83 namespace ACG {
84
85 //== CLASS DEFINITION =========================================================
86
91 class ACGDLLEXPORT DrawMeshBase {
92 protected:
93 DrawMeshBase();
94 ~DrawMeshBase();
95
96 void deleteIbo();
97 void bindVbo();
98 void bindIbo();
99 void bindLineIbo();
100 void bindPickVertexIbo();
101
102 void createIndexBuffer();
103 void fillLineBuffer(size_t n_edges, void *data);
104 void fillVertexBuffer();
105 void fillInvVertexMap(size_t n_vertices, void *data);
106
107 public:
108 unsigned int getNumTris() const { return numTris_; }
109 unsigned int getNumVerts() const { return numVerts_; }
110
113 MeshCompiler* getMeshCompiler() {return meshComp_;}
114 unsigned int getNumSubsets() const {return meshComp_->getNumSubsets();}
115
118 GLenum getIndexType() const {return indexType_;}
119
124 GLuint pickVertexIBO_opt() {return pickVertexIBO_;} // does not work
125
126
127
128 protected:
129 GLuint vbo_, ibo_;
130 size_t numTris_, numVerts_;
131 MeshCompiler* meshComp_;
132
134 GLuint lineIBO_;
135
137 GLenum indexType_;
138
142 std::vector<char> vertices_;
143
145 VertexDeclaration* vertexDecl_;
146
148 VertexDeclaration* vertexDeclEdgeCol_;
149
151 VertexDeclaration* vertexDeclHalfedgeCol_;
152
154 VertexDeclaration* vertexDeclHalfedgePos_;
155
157 GLuint pickVertexIBO_;
158
159 };
160
161
171 template <class Mesh>
172 class DrawMeshT : public DrawMeshBase
173 {
174 private:
175
176 struct Subset
177 {
178 int materialID;
179 unsigned long startIndex;
180 unsigned long numTris;
181 };
182
183 enum REBUILD_TYPE {REBUILD_NONE = 0, REBUILD_FULL = 1, REBUILD_GEOMETRY = 2, REBUILD_TOPOLOGY = 4, REBUILD_TEXTURES = 8};
184
185
186 public:
187
188 DrawMeshT(Mesh& _mesh);
189 virtual ~DrawMeshT();
190
191 void disableColors() {colorMode_ = 0;}
192 void usePerVertexColors() {colorMode_ = 1;}
193 void usePerFaceColors() {colorMode_ = 2;}
194
195 void setFlatShading() {flatMode_ = 1;}
196 void setSmoothShading() {flatMode_ = 0;}
197
198 void usePerVertexTexcoords() {textureMode_ = 0;}
199 void usePerHalfedgeTexcoords() {textureMode_ = 1;}
200 void usePerVertexNormals() {halfedgeNormalMode_ = 0;}
201 void usePerHalfedgeNormals() {halfedgeNormalMode_ = 1;}
202
205 void bindBuffers();
206
209 GLuint getVBO();
210
213 GLuint getIBO();
214
215
218 VertexDeclaration* getVertexDeclaration();
219
224 unsigned int mapVertexToVBOIndex(unsigned int _v);
225
226
229 void bindBuffersToRenderObject(RenderObject* _obj);
230
233 void unbindBuffers();
234
240 void draw(std::map< int, GLuint>* _textureMap, bool _nonindexed = false);
241
250 void addTriRenderObjects(IRenderer* _renderer, const RenderObject* _baseObj, std::map< int, GLuint>* _textureMap, bool _nonindexed = false);
251
254 void drawLines();
255
258 void addLineRenderObjects(IRenderer* _renderer, const RenderObject* _baseObj);
259
260
263 void drawVertices();
264
267 void addPointRenderObjects(IRenderer* _renderer, const RenderObject* _baseObj);
268
269
270
274 unsigned int getMemoryUsage(bool _printReport = false);
275
276 // The updateX functions give a hint on what to update.
277 // may perform a full rebuild internally!
278
281 void updateTopology() {rebuild_ |= REBUILD_TOPOLOGY;}
282
285 void updateGeometry() {rebuild_ |= REBUILD_GEOMETRY;}
286
289 void updateTextures() {rebuild_ |= REBUILD_TEXTURES;}
290
294 void updateFull() {rebuild_ |= REBUILD_FULL;}
295
300 unsigned int getNumTextures();
301
310 void setTextureIndexPropertyName( std::string _indexPropertyName );
311
316 const std::string& getTextureIndexPropertyName() const { return textureIndexPropertyName_; };
317
326 void setPerFaceTextureCoordinatePropertyName( std::string _perFaceTextureCoordinatePropertyName );
327
334 int perFaceTextureCoordinateAvailable();
335
343 int perFaceTextureIndexAvailable();
344
345
346 enum PropertySource
347 {
348 PROPERTY_SOURCE_VERTEX = 0,
349 PROPERTY_SOURCE_HALFEDGE,
350 PROPERTY_SOURCE_FACE,
351 };
352
358 void addVertexElement( const std::string& _propertyName, PropertySource _source = PROPERTY_SOURCE_VERTEX );
359
370 bool scanVertexShaderForInput( const std::string& _vertexShaderFile );
371
372 private:
373 // processing pipeline:
374
378 void rebuild();
379
380
388 void readVertex(unsigned int _vertex,
389 const typename Mesh::VertexHandle _vh,
390 const typename Mesh::HalfedgeHandle _hh,
391 const typename Mesh::FaceHandle _fh);
392
397 unsigned int getVertexColor(const typename Mesh::VertexHandle _vh);
398
403 unsigned int getFaceColor(const typename Mesh::FaceHandle _fh);
404
408 void updateGPUBuffers();
409
413 void createVBO();
414
418 void createIBO();
419
423 void createVertexDeclaration();
424
425 public:
426 // color picking
427
435 void updatePickingVertices(ACG::GLState& _state , uint _offset = 0);
436
445 ACG::Vec4uc * pickVertexColorBuffer(){
446 if ( !pickVertColBuf_.empty() )
447 return &(pickVertColBuf_)[0];
448 else {
449 std::cerr << "Illegal request to pickVertexColorBuffer when buffer is empty!" << std::endl;
450 return 0;
451 }
452 };
453
462 ACG::Vec3f * pickVertexBuffer(){
463 if ( !pickVertBuf_.empty() )
464 return &(pickVertBuf_)[0];
465 else {
466 std::cerr << "Illegal request to pickVertexBuffer when buffer is empty!" << std::endl;
467 return 0;
468 }
469 };
470
471
477 void drawPickingVertices_opt(const GLMatrixf& _mvp, int _pickOffset);
478
479
483 bool supportsPickingVertices_opt();
484
489 void updatePickingVertices_opt(ACG::GLState& _state);
490
491 #ifdef GL_ARB_texture_buffer_object
492
493 TextureBuffer* pickVertexMap_opt(){
494 if ( pickVertexMapTBO_.is_valid() )
495 return &pickVertexMapTBO_;
496 else {
497 std::cerr << "Illegal request to pickVertexMap_opt when buffer is empty!" << std::endl;
498 return 0;
499 }
500 }
501
502 #endif // GL_ARB_texture_buffer_object
503
504 private:
505
507 std::vector< ACG::Vec3f > pickVertBuf_;
509 std::vector< ACG::Vec4uc > pickVertColBuf_;
510
511
512 #ifdef GL_ARB_texture_buffer_object
513 // map from vbo vertex id to openmesh vertex id
514 TextureBuffer pickVertexMapTBO_;
515 #endif // GL_ARB_texture_buffer_object
516
517 // vertex picking shader
518 GLSL::Program* pickVertexShader_;
519
520
521 // selected shader picking method:
522 // 0 -> use texturebuffer which maps from vbo id to openmesh vertex id
523 // 1 -> draw with indexbuffer mapping from openmesh vertex id to vbo vertex
524 int pickVertexMethod_;
525
526 public:
527
537 void updatePickingEdges(ACG::GLState& _state , uint _offset = 0 );
538
547 ACG::Vec4uc * pickEdgeColorBuffer(){
548 if ( !pickEdgeBuf_.empty() )
549 return &(pickEdgeBuf_)[0];
550 else {
551 std::cerr << "Illegal request to pickEdgeColorBuffer when buffer is empty!" << std::endl;
552 return 0;
553 }
554 }
555
556
562 void drawPickingEdges_opt(const GLMatrixf& _mvp, int _pickOffset);
563
564
568 bool supportsPickingEdges_opt();
569
574 void updatePickingEdges_opt(ACG::GLState& _state );
575
576 private:
577
578 std::vector< ACG::Vec4uc > pickEdgeBuf_;
579
580 // edge picking shader
581 GLSL::Program* pickEdgeShader_;
582
583
584 public:
585
590 void updatePickingFaces(ACG::GLState& _state );
591
600 ACG::Vec4uc * pickFaceColorBuffer(){
601 if ( !pickFaceColBuf_.empty() )
602 return &(pickFaceColBuf_)[0];
603 else {
604 std::cerr << "Illegal request to pickFaceColorBuffer when buffer is empty!" << std::endl;
605 return 0;
606 }
607 }
608
617 ACG::Vec3f * pickFaceVertexBuffer(){
618 if ( !pickFaceVertexBuf_.empty() )
619 return &(pickFaceVertexBuf_)[0];
620 else {
621 std::cerr << "Illegal request to pickFaceVertexBuffer when buffer is empty!" << std::endl;
622 return 0;
623 }
624 }
625
631 void drawPickingFaces_opt(const GLMatrixf& _mvp, int _pickOffset);
632
633
637 bool supportsPickingFaces_opt();
638
643 void updatePickingFaces_opt(ACG::GLState& _state );
644
645 #ifdef GL_ARB_texture_buffer_object
646
647 TextureBuffer* pickFaceTriangleMap_opt(){
648 if ( pickFaceTriToFaceMapTBO_.is_valid() )
649 return &pickFaceTriToFaceMapTBO_;
650 else {
651 std::cerr << "Illegal request to pickFaceTriangleMap_opt when buffer is empty!" << std::endl;
652 return 0;
653 }
654 }
655 #endif
656
657 private:
658
659 // unoptimized picking buffers
660 std::vector< ACG::Vec3f > pickFaceVertexBuf_;
661 std::vector< ACG::Vec4uc > pickFaceColBuf_;
662
663 #ifdef GL_ARB_texture_buffer_object
664 // optimized picking with shaders: maps from triangle id in draw vbo to face id in openmesh
665 TextureBuffer pickFaceTriToFaceMapTBO_;
666 #endif // GL_ARB_texture_buffer_object
667
669 GLSL::Program* pickFaceShader_;
670
671 public:
679 void updatePickingAny(ACG::GLState& _state );
680
689 ACG::Vec4uc * pickAnyFaceColorBuffer(){
690 if ( !pickAnyFaceColBuf_.empty() )
691 return &(pickAnyFaceColBuf_)[0];
692 else {
693 std::cerr << "Illegal request to pickAnyFaceColorBuffer when buffer is empty!" << std::endl;
694 return 0;
695 }
696 }
697
706 ACG::Vec4uc * pickAnyEdgeColorBuffer(){
707 if ( !pickAnyEdgeColBuf_.empty() )
708 return &(pickAnyEdgeColBuf_)[0];
709 else {
710 std::cerr << "Illegal request to pickAnyEdgeColorBuffer when buffer is empty!" << std::endl;
711 return 0;
712 }
713 }
714
723 ACG::Vec4uc * pickAnyVertexColorBuffer(){
724 if ( !pickAnyVertexColBuf_.empty() )
725 return &(pickAnyVertexColBuf_)[0];
726 else {
727 std::cerr << "Illegal request to pickAnyVertexColorBuffer when buffer is empty!" << std::endl;
728 return 0;
729 }
730 }
731
737 void drawPickingAny_opt(const GLMatrixf& _mvp, int _pickOffset);
738
742 bool supportsPickingAny_opt();
743
748 void updatePickingAny_opt(ACG::GLState& _state );
749
750 private:
751
752 std::vector< ACG::Vec4uc > pickAnyFaceColBuf_;
753 std::vector< ACG::Vec4uc > pickAnyEdgeColBuf_;
754 std::vector< ACG::Vec4uc > pickAnyVertexColBuf_;
755
756
757 private:
758
759 // small helper functions
760
771 unsigned int countTris(unsigned int* _pOutMaxPolyVerts = 0, unsigned int* _pOutNumIndices = 0);
772
780 int getTextureIDofTri(unsigned int _tri);
781
787 int getTextureIDofFace(unsigned int _face);
788
797 const void* getMeshPropertyType(OpenMesh::BaseProperty* _prop, GLuint* _outType, unsigned int* _outSize) const;
798
808 template<class T>
809 const void* testMeshPropertyTypeT(const OpenMesh::BaseProperty* _prop, unsigned int* _outSize) const;
810
811
812 public:
813
818 void dumpObj(const char* _filename) const;
819
820 private:
821
823 Mesh& mesh_;
824
826 unsigned int* indices_;
827
829 unsigned int rebuild_;
830
834 size_t prevNumFaces_,prevNumVerts_;
835
836
838 int colorMode_;
839
841 int curVBOColorMode_;
842
844 int flatMode_;
845
847 int bVBOinFlatMode_;
848
850 int textureMode_;
851
853 int bVBOinHalfedgeTexMode_;
854
856 int halfedgeNormalMode_;
857
859 int bVBOinHalfedgeNormalMode_;
860
861
865 unsigned int* invVertexMap_;
866
867
868
869 //========================================================================
870 // flexible vertex layout
871 //========================================================================
872
873
874 struct VertexProperty
875 {
876 // get property from vertex, face or halfedge array
877 PropertySource source_;
878
880 std::string name_;
881
883 std::string vertexShaderInputName_;
884
886 VertexElement sourceType_;
887
889 VertexElement destType_;
890
892 const void* propDataPtr_;
893
895 int declElementID_;
896 };
897
899 const size_t offsetPos_,
900 offsetNormal_,
901 offsetTexc_,
902 offsetColor_;
903
905 std::vector<VertexProperty> additionalElements_;
906
907 //========================================================================
908 // texture handling
909 //========================================================================
910
918 std::string textureIndexPropertyName_;
919
925 std::string perFaceTextureCoordinatePropertyName_;
926
927
928 private:
929 //========================================================================
930 // write functions for flexible vertex format
931
932 void writeVertexElement(void* _dstBuf, unsigned int _vertex, unsigned int _stride, unsigned int _elementOffset, unsigned int _elementSize, const void* _elementData);
933
934 void writePosition(unsigned int _vertex, const ACG::Vec3d& _p);
935
936 void writeNormal(unsigned int _vertex, const ACG::Vec3d& _n);
937
938 void writeTexcoord(unsigned int _vertex, const ACG::Vec2f& _uv);
939
940 void writeColor(unsigned int _vertex, unsigned int _color);
941
942 void writeVertexProperty(unsigned int _vertex, const VertexElement* _elementDesc, const ACG::Vec4f& _propf);
943
944 void writeVertexProperty(unsigned int _vertex, const VertexElement* _elementDesc, const ACG::Vec4d& _propd);
945
946
952 void readVertexFromVBO(unsigned int _vertex, void* _dst);
953
954
955 public:
956
957 //===========================================================================
958 // fully expanded vbo
959 //===========================================================================
960
961
966 void invalidateFullVBO();
967
973 void updateFullVBO();
974
975
976 private:
977 // fully expanded mesh vbo (not indexed)
978 // this is only used for drawmodes with incompatible combinations of interpolation modes (ex. smooth gouraud lighting with flat face colors)
979 GeometryBuffer vboFull_;
980
981 // full vbo has been invalidated
982 bool updateFullVBO_;
983
984
985
986
987 public:
988 //========================================================================
989 // per edge buffers
990
996 void invalidatePerEdgeBuffers() {updatePerEdgeBuffers_ = 1;}
997
1002 void updatePerEdgeBuffers();
1003
1008 ACG::Vec3f* perEdgeVertexBuffer();
1009
1014 ACG::Vec4f* perEdgeColorBuffer();
1015
1021 void invalidatePerHalfedgeBuffers() {updatePerHalfedgeBuffers_ = 1;}
1022
1027 template<typename Mesh::Normal (DrawMeshT::*NormalLookup)(typename Mesh::FaceHandle)>
1028 void updatePerHalfedgeBuffers();
1029
1034 ACG::Vec3f* perHalfedgeVertexBuffer();
1035
1040 ACG::Vec4f* perHalfedgeColorBuffer();
1041
1042
1045 void updateEdgeHalfedgeVertexDeclarations();
1046
1047
1050 const VertexDeclaration* getEdgeColoredVertexDeclaration() const {return vertexDeclEdgeCol_;}
1051
1054 const VertexDeclaration* getHalfedgeVertexDeclaration() const {return vertexDeclHalfedgePos_;}
1055
1058 const VertexDeclaration* getHalfedgeColoredVertexDeclaration() const {return vertexDeclHalfedgeCol_;}
1059
1060
1061 private:
1062 int updatePerEdgeBuffers_;
1063 std::vector<ACG::Vec3f> perEdgeVertexBuf_;
1064 std::vector<ACG::Vec4f> perEdgeColorBuf_;
1065
1066 int updatePerHalfedgeBuffers_;
1067 std::vector<ACG::Vec3f> perHalfedgeVertexBuf_;
1068 std::vector<ACG::Vec4f> perHalfedgeColorBuf_;
1069
1077 template<typename Mesh::Normal (DrawMeshT::*NormalLookup)(typename Mesh::FaceHandle)>
1078 typename Mesh::Point halfedge_point(const typename Mesh::HalfedgeHandle _heh);
1079
1080 inline
1081 typename Mesh::Normal cachedNormalLookup(typename Mesh::FaceHandle fh) {
1082 return mesh_.normal(fh);
1083 }
1084
1085 inline
1086 typename Mesh::Normal computedTriMeshNormal(typename Mesh::FaceHandle fh) {
1087 typename Mesh::FVIter fv_iter = mesh_.fv_begin(fh);
1088 const typename Mesh::Point p1 = mesh_.point(*fv_iter);
1089 const typename Mesh::Point p2 = mesh_.point(*(++fv_iter));
1090 const typename Mesh::Point p3 = mesh_.point(*(++fv_iter));
1091 return ( p1 + p2 + p3 ) / 3.0;
1092 }
1093
1094 inline
1095 typename Mesh::Normal computedNormal(typename Mesh::FaceHandle fh) {
1096 unsigned int count = 0;
1097 typename Mesh::Normal normal(0, 0, 0);
1098 for (typename Mesh::FVIter fv_it = mesh_.fv_begin(fh), fv_end = mesh_.fv_end(fh); fv_it != fv_end; ++fv_it) {
1099 normal += mesh_.point(*fv_it);
1100 ++count;
1101 }
1102 normal /= count;
1103 return normal;
1104 }
1105
1106 typename Mesh::HalfedgeHandle mapToHalfedgeHandle(int _vertexId);
1107
1108 };
1109
1110
1111 //=============================================================================
1112 } // namespace ACG
1113 //=============================================================================
1114 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_DRAW_MESH_TCC)
1115 #define ACG_DRAW_MESH_TEMPLATES
1116 #include "DrawMeshT.cc"
1117 #endif
1118 //=============================================================================
1119 #endif // ACG_DRAW_MESH_HH defined
1120 //=============================================================================
ACG::DrawMeshT
Mesh Drawing Class.
Definition: DrawMesh.hh:172
ACG::DrawMeshT::VertexProperty::propDataPtr_
const void * propDataPtr_
memory address of property data
Definition: DrawMesh.hh:892
ACG::DrawMeshBase::pickVertexIBO_
GLuint pickVertexIBO_
map from openmesh vertex to vbo vertex id
Definition: DrawMesh.hh:157
ACG::DrawMeshT::updatePickingFaces_opt
void updatePickingFaces_opt(ACG::GLState &_state)
Update color picking array for the shader implementation.
Definition: DrawMeshT.cc:2059
ACG::DrawMeshT::getTextureIndexPropertyName
const std::string & getTextureIndexPropertyName() const
get the name of the texture index property
Definition: DrawMesh.hh:316
ACG::DrawMeshT::additionalElements_
std::vector< VertexProperty > additionalElements_
additional optional elements
Definition: DrawMesh.hh:905
ACG::DrawMeshT::getHalfedgeVertexDeclaration
const VertexDeclaration * getHalfedgeVertexDeclaration() const
getter for vertex declarations
Definition: DrawMesh.hh:1054
ACG::DrawMeshT::perFaceTextureCoordinateAvailable
int perFaceTextureCoordinateAvailable()
Check if per Face Texture coordinates are available.
Definition: DrawMeshT.cc:2338
ACG::DrawMeshT::mesh_
Mesh & mesh_
OpenMesh object to be rendered.
Definition: DrawMesh.hh:823
ACG
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
ACG::MeshCompiler::getNumSubsets
int getNumSubsets() const
Get the number of subsets.
Definition: MeshCompiler.hh:489
ACG::DrawMeshT::pickVertBuf_
std::vector< ACG::Vec3f > pickVertBuf_
The vertex buffer used for vertex picking.
Definition: DrawMesh.hh:507
ACG::DrawMeshT::addPointRenderObjects
void addPointRenderObjects(IRenderer *_renderer, const RenderObject *_baseObj)
render vertices only, deferred draw call
Definition: DrawMeshT.cc:1527
ACG::DrawMeshT::createVBO
void createVBO()
stores the vertex buffer on the gpu
Definition: DrawMeshT.cc:900
ACG::DrawMeshT::updateFullVBO
void updateFullVBO()
update the full mesh vbo
Definition: DrawMeshT.cc:2749
ACG::MeshCompiler
Definition: MeshCompiler.hh:246
ACG::DrawMeshBase::getMeshCompiler
MeshCompiler * getMeshCompiler()
get mesh compiler used to create the draw mesh
Definition: DrawMesh.hh:113
ACG::DrawMeshT::addLineRenderObjects
void addLineRenderObjects(IRenderer *_renderer, const RenderObject *_baseObj)
render the mesh in wireframe mode, deferred draw call
Definition: DrawMeshT.cc:1500
ACG::DrawMeshT::drawPickingAny_opt
void drawPickingAny_opt(const GLMatrixf &_mvp, int _pickOffset)
Optimized rendering of any picking ids with a shader.
Definition: DrawMeshT.cc:2258
ACG::DrawMeshT::countTris
unsigned int countTris(unsigned int *_pOutMaxPolyVerts=0, unsigned int *_pOutNumIndices=0)
Number of triangles after triangulation of the mesh.
Definition: DrawMeshT.cc:1543
ACG::DrawMeshT::VertexProperty::vertexShaderInputName_
std::string vertexShaderInputName_
input name id in vertex shader
Definition: DrawMesh.hh:883
ACG::DrawMeshBase::indexType_
GLenum indexType_
support for 2 and 4 byte unsigned integers
Definition: DrawMesh.hh:137
ACG::DrawMeshT::dumpObj
void dumpObj(const char *_filename) const
dump current vertex/index buffer to wavefront obj
Definition: DrawMeshT.cc:2679
ACG::DrawMeshT::updatePickingEdges
void updatePickingEdges(ACG::GLState &_state, uint _offset=0)
Update color picking array for edges.
Definition: DrawMeshT.cc:1913
ACG::DrawMeshT::rebuild
void rebuild()
draw_mesh updater
Definition: DrawMeshT.cc:407
ACG::DrawMeshT::pickAnyVertexColorBuffer
ACG::Vec4uc * pickAnyVertexColorBuffer()
get a pointer to the any picking color buffer
Definition: DrawMesh.hh:723
ACG::DrawMeshT::pickAnyFaceColorBuffer
ACG::Vec4uc * pickAnyFaceColorBuffer()
get a pointer to the any picking color buffer
Definition: DrawMesh.hh:689
ACG::DrawMeshT::updatePickingEdges_opt
void updatePickingEdges_opt(ACG::GLState &_state)
Update color picking array for the shader implementation.
Definition: DrawMeshT.cc:1938
ACG::DrawMeshT::getVertexColor
unsigned int getVertexColor(const typename Mesh::VertexHandle _vh)
return a vertex color from mesh
Definition: DrawMeshT.cc:834
ACG::DrawMeshT::bindBuffers
void bindBuffers()
eventually rebuilds buffers used for rendering and binds index and vertex buffer
Definition: DrawMeshT.cc:1301
ACG::DrawMeshBase::vertexDeclEdgeCol_
VertexDeclaration * vertexDeclEdgeCol_
vertex buffer layout declaration with per edge colors
Definition: DrawMesh.hh:148
OpenMesh::PolyMeshT::Point
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:115
ACG::DrawMeshT::invalidateFullVBO
void invalidateFullVBO()
the mesh has been changed
Definition: DrawMeshT.cc:2742
ACG::DrawMeshT::drawVertices
void drawVertices()
render vertices only
Definition: DrawMeshT.cc:1515
ACG::DrawMeshBase::vertexDeclHalfedgePos_
VertexDeclaration * vertexDeclHalfedgePos_
vertex buffer layout declaration with halfedge positions only
Definition: DrawMesh.hh:154
ACG::DrawMeshT::pickVertexBuffer
ACG::Vec3f * pickVertexBuffer()
get a pointer to the per vertex picking vertex buffer
Definition: DrawMesh.hh:462
ACG::GLState
Definition: GLState.hh:220
ACG::DrawMeshT::updatePickingVertices
void updatePickingVertices(ACG::GLState &_state, uint _offset=0)
Definition: DrawMeshT.cc:1595
OpenMesh::TriMesh_ArrayKernelT< CustomTraits >
ACG::DrawMeshT::prevNumFaces_
size_t prevNumFaces_
Definition: DrawMesh.hh:834
ACG::DrawMeshT::bVBOinFlatMode_
int bVBOinFlatMode_
normals in VBO currently in flat / smooth mode
Definition: DrawMesh.hh:847
ACG::DrawMeshT::updateTextures
void updateTextures()
request an update for the textures
Definition: DrawMesh.hh:289
ACG::DrawMeshT::updateTopology
void updateTopology()
request an update for the mesh topology
Definition: DrawMesh.hh:281
ACG::DrawMeshBase::lineIBO_
GLuint lineIBO_
index buffer used in Wireframe / Hiddenline mode
Definition: DrawMesh.hh:134
ACG::DrawMeshT::VertexProperty::name_
std::string name_
property name in openmesh
Definition: DrawMesh.hh:880
ACG::VertexElement
Description of one vertex element.
Definition: VertexDeclaration.hh:84
ACG::DrawMeshT::curVBOColorMode_
int curVBOColorMode_
Color Mode of vbo.
Definition: DrawMesh.hh:841
ACG::DrawMeshT::textureMode_
int textureMode_
per vertex / halfedge texture mode toggle: 0: per vertex, 1: per halfedge
Definition: DrawMesh.hh:850
ACG::DrawMeshT::textureIndexPropertyName_
std::string textureIndexPropertyName_
Property for the per face texture index.
Definition: DrawMesh.hh:918
ACG::DrawMeshT::testMeshPropertyTypeT
const void * testMeshPropertyTypeT(const OpenMesh::BaseProperty *_prop, unsigned int *_outSize) const
test mesh property for type T
Definition: DrawMeshT.cc:110
ACG::DrawMeshT::getHalfedgeColoredVertexDeclaration
const VertexDeclaration * getHalfedgeColoredVertexDeclaration() const
getter for vertex declarations
Definition: DrawMesh.hh:1058
ACG::DrawMeshT::draw
void draw(std::map< int, GLuint > *_textureMap, bool _nonindexed=false)
binds index and vertex buffer and executes draw calls
Definition: DrawMeshT.cc:1359
ACG::DrawMeshT::halfedge_point
Mesh::Point halfedge_point(const typename Mesh::HalfedgeHandle _heh)
compute halfedge point compute visualization point for halfedge (shifted to interior of face) ...
Definition: DrawMeshT.cc:1851
ACG::DrawMeshT::getEdgeColoredVertexDeclaration
const VertexDeclaration * getEdgeColoredVertexDeclaration() const
getter for vertex declarations
Definition: DrawMesh.hh:1050
ACG::GLMatrixT< float >
ACG::DrawMeshT::colorMode_
int colorMode_
Color Mode: 0: none, 1: per vertex, else: per face.
Definition: DrawMesh.hh:838
ACG::DrawMeshT::scanVertexShaderForInput
bool scanVertexShaderForInput(const std::string &_vertexShaderFile)
Scan vertex layout from vertex shader.
Definition: DrawMeshT.cc:2565
ACG::DrawMeshT::drawPickingFaces_opt
void drawPickingFaces_opt(const GLMatrixf &_mvp, int _pickOffset)
Optimized rendering of face picking ids with a shader.
Definition: DrawMeshT.cc:2094
ACG::DrawMeshBase::pickVertexIBO_opt
GLuint pickVertexIBO_opt()
get an index buffer mapping from openmesh vertices to drawmesh vbo vertices
Definition: DrawMesh.hh:124
ACG::DrawMeshT::updatePerEdgeBuffers
void updatePerEdgeBuffers()
Update all per edge drawing buffers.
Definition: DrawMeshT.cc:1764
ACG::DrawMeshT::bindBuffersToRenderObject
void bindBuffersToRenderObject(RenderObject *_obj)
eventually rebuilds buffers used for rendering and binds index and vertex buffer
Definition: DrawMeshT.cc:1331
ACG::DrawMeshT::createIBO
void createIBO()
stores the index buffer on the gpu
Definition: DrawMeshT.cc:1107
ACG::DrawMeshT::getIBO
GLuint getIBO()
get opengl index buffer id
Definition: DrawMeshT.cc:1280
ACG::DrawMeshT::halfedgeNormalMode_
int halfedgeNormalMode_
per vertex / halfedge normals mode toggle: 0: per vertex, 1: per halfedge
Definition: DrawMesh.hh:856
ACG::DrawMeshT::createVertexDeclaration
void createVertexDeclaration()
creates all vertex declarations needed for deferred draw call renderer
Definition: DrawMeshT.cc:2372
ACG::DrawMeshT::getVertexDeclaration
VertexDeclaration * getVertexDeclaration()
get vertex declaration of the current vbo layout
Definition: DrawMeshT.cc:2448
ACG::DrawMeshT::pickFaceVertexBuffer
ACG::Vec3f * pickFaceVertexBuffer()
get a pointer to the per vertex picking color buffer
Definition: DrawMesh.hh:617
ACG::DrawMeshT::perHalfedgeVertexBuffer
ACG::Vec3f * perHalfedgeVertexBuffer()
get a pointer to the per edge vertex buffer
Definition: DrawMeshT.cc:1880
ACG::DrawMeshT::getFaceColor
unsigned int getFaceColor(const typename Mesh::FaceHandle _fh)
return a face color from mesh
Definition: DrawMeshT.cc:856
ACG::DrawMeshT::addTriRenderObjects
void addTriRenderObjects(IRenderer *_renderer, const RenderObject *_baseObj, std::map< int, GLuint > *_textureMap, bool _nonindexed=false)
adds RenderObjects to a deferred draw call renderer
Definition: DrawMeshT.cc:1412
ACG::DrawMeshBase::vertexDecl_
VertexDeclaration * vertexDecl_
vertex buffer layout declaration with per vertex colors
Definition: DrawMesh.hh:145
ACG::DrawMeshT::updatePickingAny
void updatePickingAny(ACG::GLState &_state)
Call this function to update the color picking array.
Definition: DrawMeshT.cc:2165
ACG::DrawMeshT::invVertexMap_
unsigned int * invVertexMap_
Definition: DrawMesh.hh:865
ACG::DrawMeshT::perHalfedgeColorBuffer
ACG::Vec4f * perHalfedgeColorBuffer()
get a pointer to the per edge color buffer
Definition: DrawMeshT.cc:1895
ACG::DrawMeshT::updatePickingAny_opt
void updatePickingAny_opt(ACG::GLState &_state)
Update color picking array for the shader implementation.
Definition: DrawMeshT.cc:2241
OpenMesh::VectorT
Definition: Vector11T.hh:83
ACG::DrawMeshT::rebuild_
unsigned int rebuild_
hint on what to rebuild
Definition: DrawMesh.hh:829
ACG::DrawMeshT::VertexProperty::declElementID_
int declElementID_
element id in vertex declaration
Definition: DrawMesh.hh:895
ACG::DrawMeshT::pickVertexColorBuffer
ACG::Vec4uc * pickVertexColorBuffer()
get a pointer to the per vertex picking color buffer
Definition: DrawMesh.hh:445
ACG::DrawMeshT::pickFaceShader_
GLSL::Program * pickFaceShader_
optimized face picking shader
Definition: DrawMesh.hh:669
OpenMesh::BaseProperty
Definition: BaseProperty.hh:65
ACG::DrawMeshT::bVBOinHalfedgeTexMode_
int bVBOinHalfedgeTexMode_
texcoords in VBO currently in per vertex / halfedge mode toggle
Definition: DrawMesh.hh:853
ACG::DrawMeshT::supportsPickingEdges_opt
bool supportsPickingEdges_opt()
Check if optimized face picking is supported.
Definition: DrawMeshT.cc:1952
ACG::DrawMeshT::setTextureIndexPropertyName
void setTextureIndexPropertyName(std::string _indexPropertyName)
set the name of the property used for texture index specification
Definition: DrawMeshT.cc:2282
ACG::DrawMeshT::unbindBuffers
void unbindBuffers()
disables vertex, normal, texcoord and color pointers in OpenGL
Definition: DrawMeshT.cc:1345
ACG::DrawMeshT::readVertexFromVBO
void readVertexFromVBO(unsigned int _vertex, void *_dst)
Read one vertex from the rendering vbo.
Definition: DrawMeshT.cc:2724
ACG::DrawMeshT::invalidatePerEdgeBuffers
void invalidatePerEdgeBuffers()
Update of the buffers.
Definition: DrawMesh.hh:996
ACG::DrawMeshT::updateFull
void updateFull()
request a full rebuild of the mesh
Definition: DrawMesh.hh:294
ACG::DrawMeshT::updateEdgeHalfedgeVertexDeclarations
void updateEdgeHalfedgeVertexDeclarations()
updates per edge and halfedge vertex declarations
Definition: DrawMeshT.cc:2429
ACG::DrawMeshT::updatePickingFaces
void updatePickingFaces(ACG::GLState &_state)
Update color picking array for faces.
Definition: DrawMeshT.cc:2014
ACG::DrawMeshT::indices_
unsigned int * indices_
final index buffer used for rendering
Definition: DrawMesh.hh:826
ACG::DrawMeshT::getNumTextures
unsigned int getNumTextures()
returns the number of used textured of this mesh
Definition: DrawMeshT.cc:2326
ACG::DrawMeshT::getMemoryUsage
unsigned int getMemoryUsage(bool _printReport=false)
measures the size in bytes of allocated memory. eventually prints a report to std::cout ...
Definition: DrawMeshT.cc:1168
ACG::VertexDeclaration
Class to define the vertex input layout.
Definition: VertexDeclaration.hh:266
ACG::DrawMeshT::supportsPickingFaces_opt
bool supportsPickingFaces_opt()
Check if optimized face picking is supported.
Definition: DrawMeshT.cc:2080
ACG::DrawMeshBase::vertexDeclHalfedgeCol_
VertexDeclaration * vertexDeclHalfedgeCol_
vertex buffer layout declaration with per halfedge colors
Definition: DrawMesh.hh:151
OpenMesh::PolyMeshT::VertexHandle
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:139
ACG::DrawMeshT::readVertex
void readVertex(unsigned int _vertex, const typename Mesh::VertexHandle _vh, const typename Mesh::HalfedgeHandle _hh, const typename Mesh::FaceHandle _fh)
reads a vertex from mesh_ and write it to vertex buffer
Definition: DrawMeshT.cc:755
ACG::DrawMeshT::pickVertColBuf_
std::vector< ACG::Vec4uc > pickVertColBuf_
The color buffer used for vertex picking.
Definition: DrawMesh.hh:509
ACG::DrawMeshT::flatMode_
int flatMode_
flat / smooth shade mode toggle
Definition: DrawMesh.hh:844
ACG::DrawMeshT::invalidatePerHalfedgeBuffers
void invalidatePerHalfedgeBuffers()
Update of the buffers.
Definition: DrawMesh.hh:1021
GLSL::Program
GLSL program class.
Definition: GLSLShader.hh:217
ACG::DrawMeshT::perEdgeVertexBuffer
ACG::Vec3f * perEdgeVertexBuffer()
get a pointer to the per edge vertex buffer
Definition: DrawMeshT.cc:1576
ACG::DrawMeshT::VertexProperty::destType_
VertexElement destType_
property type as stored in vbo
Definition: DrawMesh.hh:889
ACG::DrawMeshT::getTextureIDofTri
int getTextureIDofTri(unsigned int _tri)
get the texture index of a triangle
Definition: DrawMeshT.cc:892
ACG::DrawMeshT::mapVertexToVBOIndex
unsigned int mapVertexToVBOIndex(unsigned int _v)
map from vertex index of the original mesh point buffer to the corresponding vertex index inside the ...
Definition: DrawMeshT.cc:1287
ACG::DrawMeshT::getMeshPropertyType
const void * getMeshPropertyType(OpenMesh::BaseProperty *_prop, GLuint *_outType, unsigned int *_outSize) const
get the data type of a mesh property
Definition: DrawMeshT.cc:162
ACG::DrawMeshT::getVBO
GLuint getVBO()
get opengl vertex buffer id
Definition: DrawMeshT.cc:1273
ACG::DrawMeshT::pickEdgeColorBuffer
ACG::Vec4uc * pickEdgeColorBuffer()
get a pointer to the per edge picking color buffer
Definition: DrawMesh.hh:547
ACG::DrawMeshT::perFaceTextureIndexAvailable
int perFaceTextureIndexAvailable()
Check if texture indices are available.
Definition: DrawMeshT.cc:2354
ACG::DrawMeshT::supportsPickingVertices_opt
bool supportsPickingVertices_opt()
Check if optimized vertex picking is supported.
Definition: DrawMeshT.cc:1667
ACG::DrawMeshT::setPerFaceTextureCoordinatePropertyName
void setPerFaceTextureCoordinatePropertyName(std::string _perFaceTextureCoordinatePropertyName)
set the name of the property used for texture coordinate
Definition: DrawMeshT.cc:2306
ACG::DrawMeshBase::getIndexType
GLenum getIndexType() const
get index type of index buffer
Definition: DrawMesh.hh:118
ACG::DrawMeshT::pickFaceColorBuffer
ACG::Vec4uc * pickFaceColorBuffer()
get a pointer to the per face picking color buffer
Definition: DrawMesh.hh:600
ACG::DrawMeshT::updatePerHalfedgeBuffers
void updatePerHalfedgeBuffers()
Update all per edge drawing buffer n The updated buffers are: per edge vertex buffer ( 2 vertices per...
Definition: DrawMeshT.cc:1802
ACG::DrawMeshT::addVertexElement
void addVertexElement(const std::string &_propertyName, PropertySource _source=PROPERTY_SOURCE_VERTEX)
Add custom elements to the vertex layout.
Definition: DrawMeshT.cc:2535
ACG::DrawMeshT::bVBOinHalfedgeNormalMode_
int bVBOinHalfedgeNormalMode_
normals in VBO currently in per vertex / halfedge mode toggle
Definition: DrawMesh.hh:859
ACG::DrawMeshT::updatePickingVertices_opt
void updatePickingVertices_opt(ACG::GLState &_state)
Update color picking array for the shader implementation.
Definition: DrawMeshT.cc:1615
ACG::DrawMeshT::updateGeometry
void updateGeometry()
request an update for the mesh vertices
Definition: DrawMesh.hh:285
ACG::DrawMeshBase::vertices_
std::vector< char > vertices_
Definition: DrawMesh.hh:142
ACG::DrawMeshT::perEdgeColorBuffer
ACG::Vec4f * perEdgeColorBuffer()
get a pointer to the per edge color buffer
Definition: DrawMeshT.cc:1585
ACG::DrawMeshT::perFaceTextureCoordinatePropertyName_
std::string perFaceTextureCoordinatePropertyName_
Property for the per face texture coordinates.
Definition: DrawMesh.hh:925
ACG::DrawMeshT::pickAnyEdgeColorBuffer
ACG::Vec4uc * pickAnyEdgeColorBuffer()
get a pointer to the any picking color buffer
Definition: DrawMesh.hh:706
ACG::DrawMeshT::supportsPickingAny_opt
bool supportsPickingAny_opt()
Check if optimized any picking is supported.
Definition: DrawMeshT.cc:2251
ACG::DrawMeshT::VertexProperty
Definition: DrawMesh.hh:874
ACG::DrawMeshT::Subset
Definition: DrawMesh.hh:176
ACG::DrawMeshBase
Definition: DrawMesh.hh:91
ACG::DrawMeshT::drawPickingVertices_opt
void drawPickingVertices_opt(const GLMatrixf &_mvp, int _pickOffset)
Optimized rendering of vertex picking ids with a shader.
Definition: DrawMeshT.cc:1692
ACG::DrawMeshT::drawLines
void drawLines()
render the mesh in wireframe mode
Definition: DrawMeshT.cc:1484
ACG::DrawMeshT::getTextureIDofFace
int getTextureIDofFace(unsigned int _face)
get the texture index of a face
Definition: DrawMeshT.cc:878
ACG::DrawMeshT::drawPickingEdges_opt
void drawPickingEdges_opt(const GLMatrixf &_mvp, int _pickOffset)
Optimized rendering of edge picking ids with a shader.
Definition: DrawMeshT.cc:1963
ACG::DrawMeshT::VertexProperty::sourceType_
VertexElement sourceType_
property type as stored in openmesh
Definition: DrawMesh.hh:886
OpenMesh::PolyMeshT::Normal
Kernel::Normal Normal
Normal type.
Definition: PolyMeshT.hh:117
ACG::DrawMeshT::offsetPos_
const size_t offsetPos_
fixed vertex elements:
Definition: DrawMesh.hh:899
ACG::DrawMeshT::updateGPUBuffers
void updateGPUBuffers()
eventually update vertex and index buffers
Definition: DrawMeshT.cc:1248
ACG::TextureBuffer
Definition: globjects.hh:522