Developer Documentation
 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 
146 
149 
152 
155 
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 
335 
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 
424 
425 public:
426  // color picking
427 
435  void updatePickingVertices(ACG::GLState& _state , uint _offset = 0);
436 
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 
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 
484 
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 
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 
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 
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 
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 
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 
670 
671 public:
679  void updatePickingAny(ACG::GLState& _state );
680 
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 
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 
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 
824 
826  unsigned int* indices_;
827 
829  unsigned int rebuild_;
830 
834  size_t prevNumFaces_,prevNumVerts_;
835 
836 
839 
842 
845 
848 
851 
854 
857 
860 
861 
865  unsigned int* invVertexMap_;
866 
867 
868 
869  //========================================================================
870  // flexible vertex layout
871  //========================================================================
872 
873 
875  {
876  // get property from vertex, face or halfedge array
877  PropertySource source_;
878 
880  std::string name_;
881 
884 
887 
890 
892  const void* propDataPtr_;
893 
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 
919 
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 
1009 
1015 
1021  void invalidatePerHalfedgeBuffers() {updatePerHalfedgeBuffers_ = 1;}
1022 
1027  template<typename Mesh::Normal (DrawMeshT::*NormalLookup)(typename Mesh::FaceHandle)>
1028  void updatePerHalfedgeBuffers();
1029 
1035 
1041 
1042 
1046 
1047 
1051 
1055 
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 //=============================================================================
Mesh Drawing Class.
Definition: DrawMesh.hh:172
const void * propDataPtr_
memory address of property data
Definition: DrawMesh.hh:892
GLuint pickVertexIBO_
map from openmesh vertex to vbo vertex id
Definition: DrawMesh.hh:157
void updatePickingFaces_opt(ACG::GLState &_state)
Update color picking array for the shader implementation.
Definition: DrawMeshT.cc:2059
const std::string & getTextureIndexPropertyName() const
get the name of the texture index property
Definition: DrawMesh.hh:316
std::vector< VertexProperty > additionalElements_
additional optional elements
Definition: DrawMesh.hh:905
const VertexDeclaration * getHalfedgeVertexDeclaration() const
getter for vertex declarations
Definition: DrawMesh.hh:1054
int perFaceTextureCoordinateAvailable()
Check if per Face Texture coordinates are available.
Definition: DrawMeshT.cc:2338
Mesh & mesh_
OpenMesh object to be rendered.
Definition: DrawMesh.hh:823
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
int getNumSubsets() const
Get the number of subsets.
std::vector< ACG::Vec3f > pickVertBuf_
The vertex buffer used for vertex picking.
Definition: DrawMesh.hh:507
void addPointRenderObjects(IRenderer *_renderer, const RenderObject *_baseObj)
render vertices only, deferred draw call
Definition: DrawMeshT.cc:1527
void createVBO()
stores the vertex buffer on the gpu
Definition: DrawMeshT.cc:900
void updateFullVBO()
update the full mesh vbo
Definition: DrawMeshT.cc:2749
MeshCompiler * getMeshCompiler()
get mesh compiler used to create the draw mesh
Definition: DrawMesh.hh:113
void addLineRenderObjects(IRenderer *_renderer, const RenderObject *_baseObj)
render the mesh in wireframe mode, deferred draw call
Definition: DrawMeshT.cc:1500
void drawPickingAny_opt(const GLMatrixf &_mvp, int _pickOffset)
Optimized rendering of any picking ids with a shader.
Definition: DrawMeshT.cc:2258
unsigned int countTris(unsigned int *_pOutMaxPolyVerts=0, unsigned int *_pOutNumIndices=0)
Number of triangles after triangulation of the mesh.
Definition: DrawMeshT.cc:1543
std::string vertexShaderInputName_
input name id in vertex shader
Definition: DrawMesh.hh:883
GLenum indexType_
support for 2 and 4 byte unsigned integers
Definition: DrawMesh.hh:137
void dumpObj(const char *_filename) const
dump current vertex/index buffer to wavefront obj
Definition: DrawMeshT.cc:2679
void updatePickingEdges(ACG::GLState &_state, uint _offset=0)
Update color picking array for edges.
Definition: DrawMeshT.cc:1913
void rebuild()
draw_mesh updater
Definition: DrawMeshT.cc:407
ACG::Vec4uc * pickAnyVertexColorBuffer()
get a pointer to the any picking color buffer
Definition: DrawMesh.hh:723
ACG::Vec4uc * pickAnyFaceColorBuffer()
get a pointer to the any picking color buffer
Definition: DrawMesh.hh:689
void updatePickingEdges_opt(ACG::GLState &_state)
Update color picking array for the shader implementation.
Definition: DrawMeshT.cc:1938
unsigned int getVertexColor(const typename Mesh::VertexHandle _vh)
return a vertex color from mesh
Definition: DrawMeshT.cc:834
void bindBuffers()
eventually rebuilds buffers used for rendering and binds index and vertex buffer
Definition: DrawMeshT.cc:1301
VertexDeclaration * vertexDeclEdgeCol_
vertex buffer layout declaration with per edge colors
Definition: DrawMesh.hh:148
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:115
void invalidateFullVBO()
the mesh has been changed
Definition: DrawMeshT.cc:2742
void drawVertices()
render vertices only
Definition: DrawMeshT.cc:1515
VertexDeclaration * vertexDeclHalfedgePos_
vertex buffer layout declaration with halfedge positions only
Definition: DrawMesh.hh:154
ACG::Vec3f * pickVertexBuffer()
get a pointer to the per vertex picking vertex buffer
Definition: DrawMesh.hh:462
void updatePickingVertices(ACG::GLState &_state, uint _offset=0)
Definition: DrawMeshT.cc:1595
size_t prevNumFaces_
Definition: DrawMesh.hh:834
int bVBOinFlatMode_
normals in VBO currently in flat / smooth mode
Definition: DrawMesh.hh:847
void updateTextures()
request an update for the textures
Definition: DrawMesh.hh:289
void updateTopology()
request an update for the mesh topology
Definition: DrawMesh.hh:281
GLuint lineIBO_
index buffer used in Wireframe / Hiddenline mode
Definition: DrawMesh.hh:134
std::string name_
property name in openmesh
Definition: DrawMesh.hh:880
Description of one vertex element.
int curVBOColorMode_
Color Mode of vbo.
Definition: DrawMesh.hh:841
int textureMode_
per vertex / halfedge texture mode toggle: 0: per vertex, 1: per halfedge
Definition: DrawMesh.hh:850
std::string textureIndexPropertyName_
Property for the per face texture index.
Definition: DrawMesh.hh:918
const void * testMeshPropertyTypeT(const OpenMesh::BaseProperty *_prop, unsigned int *_outSize) const
test mesh property for type T
Definition: DrawMeshT.cc:110
const VertexDeclaration * getHalfedgeColoredVertexDeclaration() const
getter for vertex declarations
Definition: DrawMesh.hh:1058
void draw(std::map< int, GLuint > *_textureMap, bool _nonindexed=false)
binds index and vertex buffer and executes draw calls
Definition: DrawMeshT.cc:1359
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
const VertexDeclaration * getEdgeColoredVertexDeclaration() const
getter for vertex declarations
Definition: DrawMesh.hh:1050
int colorMode_
Color Mode: 0: none, 1: per vertex, else: per face.
Definition: DrawMesh.hh:838
bool scanVertexShaderForInput(const std::string &_vertexShaderFile)
Scan vertex layout from vertex shader.
Definition: DrawMeshT.cc:2565
void drawPickingFaces_opt(const GLMatrixf &_mvp, int _pickOffset)
Optimized rendering of face picking ids with a shader.
Definition: DrawMeshT.cc:2094
GLuint pickVertexIBO_opt()
get an index buffer mapping from openmesh vertices to drawmesh vbo vertices
Definition: DrawMesh.hh:124
void updatePerEdgeBuffers()
Update all per edge drawing buffers.
Definition: DrawMeshT.cc:1764
void bindBuffersToRenderObject(RenderObject *_obj)
eventually rebuilds buffers used for rendering and binds index and vertex buffer
Definition: DrawMeshT.cc:1331
void createIBO()
stores the index buffer on the gpu
Definition: DrawMeshT.cc:1107
GLuint getIBO()
get opengl index buffer id
Definition: DrawMeshT.cc:1280
int halfedgeNormalMode_
per vertex / halfedge normals mode toggle: 0: per vertex, 1: per halfedge
Definition: DrawMesh.hh:856
void createVertexDeclaration()
creates all vertex declarations needed for deferred draw call renderer
Definition: DrawMeshT.cc:2372
VertexDeclaration * getVertexDeclaration()
get vertex declaration of the current vbo layout
Definition: DrawMeshT.cc:2448
ACG::Vec3f * pickFaceVertexBuffer()
get a pointer to the per vertex picking color buffer
Definition: DrawMesh.hh:617
ACG::Vec3f * perHalfedgeVertexBuffer()
get a pointer to the per edge vertex buffer
Definition: DrawMeshT.cc:1880
unsigned int getFaceColor(const typename Mesh::FaceHandle _fh)
return a face color from mesh
Definition: DrawMeshT.cc:856
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
VertexDeclaration * vertexDecl_
vertex buffer layout declaration with per vertex colors
Definition: DrawMesh.hh:145
void updatePickingAny(ACG::GLState &_state)
Call this function to update the color picking array.
Definition: DrawMeshT.cc:2165
unsigned int * invVertexMap_
Definition: DrawMesh.hh:865
ACG::Vec4f * perHalfedgeColorBuffer()
get a pointer to the per edge color buffer
Definition: DrawMeshT.cc:1895
void updatePickingAny_opt(ACG::GLState &_state)
Update color picking array for the shader implementation.
Definition: DrawMeshT.cc:2241
unsigned int rebuild_
hint on what to rebuild
Definition: DrawMesh.hh:829
int declElementID_
element id in vertex declaration
Definition: DrawMesh.hh:895
ACG::Vec4uc * pickVertexColorBuffer()
get a pointer to the per vertex picking color buffer
Definition: DrawMesh.hh:445
GLSL::Program * pickFaceShader_
optimized face picking shader
Definition: DrawMesh.hh:669
int bVBOinHalfedgeTexMode_
texcoords in VBO currently in per vertex / halfedge mode toggle
Definition: DrawMesh.hh:853
bool supportsPickingEdges_opt()
Check if optimized face picking is supported.
Definition: DrawMeshT.cc:1952
void setTextureIndexPropertyName(std::string _indexPropertyName)
set the name of the property used for texture index specification
Definition: DrawMeshT.cc:2282
void unbindBuffers()
disables vertex, normal, texcoord and color pointers in OpenGL
Definition: DrawMeshT.cc:1345
void readVertexFromVBO(unsigned int _vertex, void *_dst)
Read one vertex from the rendering vbo.
Definition: DrawMeshT.cc:2724
void invalidatePerEdgeBuffers()
Update of the buffers.
Definition: DrawMesh.hh:996
void updateFull()
request a full rebuild of the mesh
Definition: DrawMesh.hh:294
void updateEdgeHalfedgeVertexDeclarations()
updates per edge and halfedge vertex declarations
Definition: DrawMeshT.cc:2429
void updatePickingFaces(ACG::GLState &_state)
Update color picking array for faces.
Definition: DrawMeshT.cc:2014
unsigned int * indices_
final index buffer used for rendering
Definition: DrawMesh.hh:826
unsigned int getNumTextures()
returns the number of used textured of this mesh
Definition: DrawMeshT.cc:2326
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
Class to define the vertex input layout.
bool supportsPickingFaces_opt()
Check if optimized face picking is supported.
Definition: DrawMeshT.cc:2080
VertexDeclaration * vertexDeclHalfedgeCol_
vertex buffer layout declaration with per halfedge colors
Definition: DrawMesh.hh:151
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:139
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
std::vector< ACG::Vec4uc > pickVertColBuf_
The color buffer used for vertex picking.
Definition: DrawMesh.hh:509
int flatMode_
flat / smooth shade mode toggle
Definition: DrawMesh.hh:844
void invalidatePerHalfedgeBuffers()
Update of the buffers.
Definition: DrawMesh.hh:1021
GLSL program class.
Definition: GLSLShader.hh:217
ACG::Vec3f * perEdgeVertexBuffer()
get a pointer to the per edge vertex buffer
Definition: DrawMeshT.cc:1576
VertexElement destType_
property type as stored in vbo
Definition: DrawMesh.hh:889
int getTextureIDofTri(unsigned int _tri)
get the texture index of a triangle
Definition: DrawMeshT.cc:892
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
const void * getMeshPropertyType(OpenMesh::BaseProperty *_prop, GLuint *_outType, unsigned int *_outSize) const
get the data type of a mesh property
Definition: DrawMeshT.cc:162
GLuint getVBO()
get opengl vertex buffer id
Definition: DrawMeshT.cc:1273
ACG::Vec4uc * pickEdgeColorBuffer()
get a pointer to the per edge picking color buffer
Definition: DrawMesh.hh:547
int perFaceTextureIndexAvailable()
Check if texture indices are available.
Definition: DrawMeshT.cc:2354
bool supportsPickingVertices_opt()
Check if optimized vertex picking is supported.
Definition: DrawMeshT.cc:1667
void setPerFaceTextureCoordinatePropertyName(std::string _perFaceTextureCoordinatePropertyName)
set the name of the property used for texture coordinate
Definition: DrawMeshT.cc:2306
GLenum getIndexType() const
get index type of index buffer
Definition: DrawMesh.hh:118
ACG::Vec4uc * pickFaceColorBuffer()
get a pointer to the per face picking color buffer
Definition: DrawMesh.hh:600
void updatePerHalfedgeBuffers()
Update all per edge drawing buffer n The updated buffers are: per edge vertex buffer ( 2 vertices per...
Definition: DrawMeshT.cc:1802
void addVertexElement(const std::string &_propertyName, PropertySource _source=PROPERTY_SOURCE_VERTEX)
Add custom elements to the vertex layout.
Definition: DrawMeshT.cc:2535
int bVBOinHalfedgeNormalMode_
normals in VBO currently in per vertex / halfedge mode toggle
Definition: DrawMesh.hh:859
void updatePickingVertices_opt(ACG::GLState &_state)
Update color picking array for the shader implementation.
Definition: DrawMeshT.cc:1615
void updateGeometry()
request an update for the mesh vertices
Definition: DrawMesh.hh:285
std::vector< char > vertices_
Definition: DrawMesh.hh:142
ACG::Vec4f * perEdgeColorBuffer()
get a pointer to the per edge color buffer
Definition: DrawMeshT.cc:1585
std::string perFaceTextureCoordinatePropertyName_
Property for the per face texture coordinates.
Definition: DrawMesh.hh:925
ACG::Vec4uc * pickAnyEdgeColorBuffer()
get a pointer to the any picking color buffer
Definition: DrawMesh.hh:706
bool supportsPickingAny_opt()
Check if optimized any picking is supported.
Definition: DrawMeshT.cc:2251
void drawPickingVertices_opt(const GLMatrixf &_mvp, int _pickOffset)
Optimized rendering of vertex picking ids with a shader.
Definition: DrawMeshT.cc:1692
void drawLines()
render the mesh in wireframe mode
Definition: DrawMeshT.cc:1484
int getTextureIDofFace(unsigned int _face)
get the texture index of a face
Definition: DrawMeshT.cc:878
void drawPickingEdges_opt(const GLMatrixf &_mvp, int _pickOffset)
Optimized rendering of edge picking ids with a shader.
Definition: DrawMeshT.cc:1963
VertexElement sourceType_
property type as stored in openmesh
Definition: DrawMesh.hh:886
Kernel::Normal Normal
Normal type.
Definition: PolyMeshT.hh:117
const size_t offsetPos_
fixed vertex elements:
Definition: DrawMesh.hh:899
void updateGPUBuffers()
eventually update vertex and index buffers
Definition: DrawMeshT.cc:1248