Developer Documentation
Loading...
Searching...
No Matches
DrawMesh.hh
1#pragma once
2/*===========================================================================*\
3 * *
4 * OpenFlipper *
5 * Copyright (c) 2001-2015, RWTH-Aachen University *
6 * Department of Computer Graphics and Multimedia *
7 * All rights reserved. *
8 * www.openflipper.org *
9 * *
10 *---------------------------------------------------------------------------*
11 * This file is part of OpenFlipper. *
12 *---------------------------------------------------------------------------*
13 * *
14 * Redistribution and use in source and binary forms, with or without *
15 * modification, are permitted provided that the following conditions *
16 * are met: *
17 * *
18 * 1. Redistributions of source code must retain the above copyright notice, *
19 * this list of conditions and the following disclaimer. *
20 * *
21 * 2. Redistributions in binary form must reproduce the above copyright *
22 * notice, this list of conditions and the following disclaimer in the *
23 * documentation and/or other materials provided with the distribution. *
24 * *
25 * 3. Neither the name of the copyright holder nor the names of its *
26 * contributors may be used to endorse or promote products derived from *
27 * this software without specific prior written permission. *
28 * *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
31 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
32 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
33 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
34 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
35 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
36 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
37 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
38 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
40 * *
41\*===========================================================================*/
42
43//=============================================================================
44//
45// CLASS DrawMeshT
46//
47//=============================================================================
48
49//== INCLUDES =================================================================
50
51#include <vector>
52#include <list>
53#include <OpenMesh/Core/Utils/Property.hh>
54#include <OpenMesh/Core/Utils/color_cast.hh>
55
56#include <OpenMesh/Core/Mesh/DefaultTriMesh.hh>
57#include <OpenMesh/Core/Mesh/DefaultPolyMesh.hh>
58
59#include <ACG/GL/globjects.hh>
60#include <ACG/GL/GLState.hh>
61#include <ACG/GL/IRenderer.hh>
62#include <ACG/GL/MeshCompiler.hh>
63#include <ACG/ShaderUtils/GLSLShader.hh>
64
65#include <ACG/Config/ACGDefines.hh>
66
67//== FORWARDDECLARATIONS ======================================================
68
69
70//== NAMESPACES ===============================================================
71
72namespace ACG {
73
74//== CLASS DEFINITION =========================================================
75
80class ACGDLLEXPORT DrawMeshBase {
81 protected:
84
85 void deleteIbo();
86 void bindVbo();
87 void bindIbo();
88 void bindLineIbo();
89 void bindHEVbo();
90 void unbindHEVbo();
91 void bindPickVertexIbo();
92
93 void createIndexBuffer();
94 void fillLineBuffer(size_t n_edges, void *data);
95 void fillHEVBO(size_t numberOfElements_, size_t sizeOfElements_, void* data_);
96 void fillVertexBuffer();
97 void fillInvVertexMap(size_t n_vertices, void *data);
98
99 public:
100 size_t getNumTris() const { return numTris_; }
101 size_t getNumVerts() const { return numVerts_; }
102
105 MeshCompiler* getMeshCompiler() {return meshComp_;}
106 unsigned int getNumSubsets() const {return meshComp_->getNumSubsets();}
107
110 GLenum getIndexType() const {return indexType_;}
111
116 GLuint pickVertexIBO_opt() {return pickVertexIBO_;} // does not work
117
118
119
120 protected:
121 GLuint vbo_, ibo_;
122 size_t numTris_, numVerts_;
123 MeshCompiler* meshComp_;
124
126 GLuint lineIBO_;
128 GLuint heVBO_;
129 //previously bound buffer
130 GLint prevVBO_;
131
134
138 std::vector<char> vertices_;
139
142
145
148
151
154
157
158};
159
160
170template <class Mesh>
172{
173private:
174
175 struct Subset
176 {
177 int materialID;
178 unsigned long startIndex;
179 unsigned long numTris;
180 };
181
182 enum REBUILD_TYPE {REBUILD_NONE = 0, REBUILD_FULL = 1, REBUILD_GEOMETRY = 2, REBUILD_TOPOLOGY = 4, REBUILD_TEXTURES = 8};
183
184
185public:
186
187 explicit DrawMeshT(Mesh& _mesh);
188 virtual ~DrawMeshT();
189
190 void disableColors() {colorMode_ = 0;}
191 void usePerVertexColors() {colorMode_ = 1;}
192 void usePerFaceColors() {colorMode_ = 2;}
193
194 void setFlatShading() {flatMode_ = 1;}
195 void setSmoothShading() {flatMode_ = 0;}
196
197 void usePerVertexTexcoords() {textureMode_ = 0;}
198 void usePerHalfedgeTexcoords() {textureMode_ = 1;}
199 void usePerVertexNormals() {halfedgeNormalMode_ = 0;}
200 void usePerHalfedgeNormals() {halfedgeNormalMode_ = 1;}
201
204 void bindBuffers();
205
208 GLuint getVBO();
209
212 GLuint getIBO();
213
218 GLuint getHEVBO(){return heVBO_;}
219
223
228 unsigned int mapVertexToVBOIndex(unsigned int _v);
229
230
234
237 void unbindBuffers();
238
244 void draw(std::map< int, GLuint>* _textureMap, bool _nonindexed = false);
245
254 void addTriRenderObjects(IRenderer* _renderer, const RenderObject* _baseObj, std::map< int, GLuint>* _textureMap, bool _nonindexed = false);
255
258 void drawLines();
259
262 void addLineRenderObjects(IRenderer* _renderer, const RenderObject* _baseObj);
263
264
267 void drawVertices();
268
271 void addPointRenderObjects(IRenderer* _renderer, const RenderObject* _baseObj);
272
273
274
278 unsigned int getMemoryUsage(bool _printReport = false);
279
280 // The updateX functions give a hint on what to update.
281 // may perform a full rebuild internally!
282
285 void updateTopology() {rebuild_ |= REBUILD_TOPOLOGY;}
286
289 void updateGeometry() {rebuild_ |= REBUILD_GEOMETRY;}
290
293 void updateTextures() {rebuild_ |= REBUILD_TEXTURES;}
294
298 void updateFull() {rebuild_ |= REBUILD_FULL;}
299
304 unsigned int getNumTextures();
305
314 void setTextureIndexPropertyName( std::string _indexPropertyName );
315
320 const std::string& getTextureIndexPropertyName() const { return textureIndexPropertyName_; };
321
330 void setPerFaceTextureCoordinatePropertyName( std::string _perFaceTextureCoordinatePropertyName );
331
339
348
349
350 enum PropertySource
351 {
352 PROPERTY_SOURCE_VERTEX = 0,
353 PROPERTY_SOURCE_HALFEDGE,
354 PROPERTY_SOURCE_FACE,
355 };
356
362 void addVertexElement( const std::string& _propertyName, PropertySource _source = PROPERTY_SOURCE_VERTEX );
363
374 bool scanVertexShaderForInput( const std::string& _vertexShaderFile );
375
376private:
377 // processing pipeline:
378
382 void rebuild();
383
384
392 void readVertex(size_t _vertex,
393 const typename Mesh::VertexHandle& _vh,
394 const typename Mesh::HalfedgeHandle& _hh,
395 const typename Mesh::FaceHandle& _fh);
396
401 unsigned int getVertexColor(const typename Mesh::VertexHandle& _vh);
402
407 unsigned int getFaceColor(const typename Mesh::FaceHandle& _fh);
408
412 void updateGPUBuffers();
413
417 void createVBO();
418
422 void createIBO();
423
428
429public:
430 // color picking
431
439 void updatePickingVertices(ACG::GLState& _state , uint _offset = 0);
440
450 if ( !pickVertColBuf_.empty() )
451 return &(pickVertColBuf_)[0];
452 else {
453 std::cerr << "Illegal request to pickVertexColorBuffer when buffer is empty!" << std::endl;
454 return 0;
455 }
456 };
457
467 if ( !pickVertBuf_.empty() )
468 return &(pickVertBuf_)[0];
469 else {
470 std::cerr << "Illegal request to pickVertexBuffer when buffer is empty!" << std::endl;
471 return 0;
472 }
473 };
474
475
481 void drawPickingVertices_opt(const GLMatrixf& _mvp, size_t _pickOffset);
482
483
488
494
495
496 TextureBuffer* pickVertexMap_opt(){
497 if ( pickVertexMapTBO_.is_valid() )
498 return &pickVertexMapTBO_;
499 else {
500 std::cerr << "Illegal request to pickVertexMap_opt when buffer is empty!" << std::endl;
501 return 0;
502 }
503 }
504
505
506private:
507
509 std::vector< ACG::Vec3f > pickVertBuf_;
511 std::vector< ACG::Vec4uc > pickVertColBuf_;
512
513
514 // map from vbo vertex id to openmesh vertex id
515 TextureBuffer pickVertexMapTBO_;
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
526public:
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, size_t _pickOffset);
563
564
569
575
576private:
577
578 std::vector< ACG::Vec4uc > pickEdgeBuf_;
579
580 // edge picking shader
581 GLSL::Program* pickEdgeShader_;
582
583
584public:
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, size_t _pickOffset);
632
633
638
644
645
646 TextureBuffer* pickFaceTriangleMap_opt(){
647 if ( pickFaceTriToFaceMapTBO_.is_valid() )
648 return &pickFaceTriToFaceMapTBO_;
649 else {
650 std::cerr << "Illegal request to pickFaceTriangleMap_opt when buffer is empty!" << std::endl;
651 return 0;
652 }
653 }
654
655private:
656
657 // unoptimized picking buffers
658 std::vector< ACG::Vec3f > pickFaceVertexBuf_;
659 std::vector< ACG::Vec4uc > pickFaceColBuf_;
660
661 // optimized picking with shaders: maps from triangle id in draw vbo to face id in openmesh
662 TextureBuffer pickFaceTriToFaceMapTBO_;
663
666
667public:
675 void updatePickingAny(ACG::GLState& _state );
676
686 if ( !pickAnyFaceColBuf_.empty() )
687 return &(pickAnyFaceColBuf_)[0];
688 else {
689 std::cerr << "Illegal request to pickAnyFaceColorBuffer when buffer is empty!" << std::endl;
690 return 0;
691 }
692 }
693
703 if ( !pickAnyEdgeColBuf_.empty() )
704 return &(pickAnyEdgeColBuf_)[0];
705 else {
706 std::cerr << "Illegal request to pickAnyEdgeColorBuffer when buffer is empty!" << std::endl;
707 return 0;
708 }
709 }
710
720 if ( !pickAnyVertexColBuf_.empty() )
721 return &(pickAnyVertexColBuf_)[0];
722 else {
723 std::cerr << "Illegal request to pickAnyVertexColorBuffer when buffer is empty!" << std::endl;
724 return 0;
725 }
726 }
727
733 void drawPickingAny_opt(const GLMatrixf& _mvp, size_t _pickOffset);
734
739
744 void updatePickingAny_opt(ACG::GLState& _state );
745
746private:
747
748 std::vector< ACG::Vec4uc > pickAnyFaceColBuf_;
749 std::vector< ACG::Vec4uc > pickAnyEdgeColBuf_;
750 std::vector< ACG::Vec4uc > pickAnyVertexColBuf_;
751
752
753private:
754
755 // small helper functions
756
767 unsigned int countTris(unsigned int* _pOutMaxPolyVerts = 0, unsigned int* _pOutNumIndices = 0);
768
776 int getTextureIDofTri(unsigned int _tri);
777
783 int getTextureIDofFace(unsigned int _face);
784
793 const void* getMeshPropertyType(OpenMesh::BaseProperty* _prop, GLuint* _outType, unsigned int* _outSize) const;
794
804 template<class T>
805 const void* testMeshPropertyTypeT(const OpenMesh::BaseProperty* _prop, unsigned int* _outSize) const;
806
807
808public:
809
814 void dumpObj(const char* _filename) const;
815
816private:
817
820
822 unsigned int* indices_;
823
825 unsigned int rebuild_;
826
830 size_t prevNumFaces_,prevNumVerts_;
831
832
835
838
841
844
847
850
853
856
857
861 unsigned int* invVertexMap_;
862
863
864
865 //========================================================================
866 // flexible vertex layout
867 //========================================================================
868
869
871 {
872 // get property from vertex, face or halfedge array
873 PropertySource source_;
874
876 std::string name_;
877
880
883
886
888 const void* propDataPtr_;
889
892 };
893
895 const size_t offsetPos_,
896 offsetNormal_,
897 offsetTexc_,
898 offsetColor_;
899
901 std::vector<VertexProperty> additionalElements_;
902
903 //========================================================================
904 // texture handling
905 //========================================================================
906
915
922
923
924private:
925 //========================================================================
926 // write functions for flexible vertex format
927
928 void writeVertexElement(void* _dstBuf, size_t _vertex, size_t _stride, size_t _elementOffset, size_t _elementSize, const void* _elementData);
929
930 void writePosition(size_t _vertex, const ACG::Vec3d& _p);
931
932 void writeNormal(size_t _vertex, const ACG::Vec3d& _n);
933
934 void writeTexcoord(size_t _vertex, const ACG::Vec2f& _uv);
935
936 void writeColor(size_t _vertex, unsigned int _color);
937
938 void writeVertexProperty(size_t _vertex, const VertexElement* _elementDesc, const ACG::Vec4f& _propf);
939
940 void writeVertexProperty(size_t _vertex, const VertexElement* _elementDesc, const ACG::Vec4d& _propd);
941
942
948 void readVertexFromVBO(unsigned int _vertex, void* _dst);
949
950
951public:
952
953 //===========================================================================
954 // fully expanded vbo
955 //===========================================================================
956
957
962 void invalidateFullVBO();
963
969 void updateFullVBO();
970
971
972private:
973 // fully expanded mesh vbo (not indexed)
974 // this is only used for drawmodes with incompatible combinations of interpolation modes (ex. smooth gouraud lighting with flat face colors)
975 GeometryBuffer vboFull_;
976
977 // full vbo has been invalidated
978 bool updateFullVBO_;
979
980 // (colored) edges
981 GeometryBuffer vboEdges_;
982
983public:
984 //========================================================================
985 // per edge buffers
986
992 void invalidatePerEdgeBuffers() {updatePerEdgeBuffers_ = 1;}
993
1000
1004
1010
1016
1022 void invalidatePerHalfedgeBuffers() {updatePerHalfedgeBuffers_ = 1;}
1023
1028 template<typename Mesh::Normal (DrawMeshT::*NormalLookup)(typename Mesh::FaceHandle)>
1030
1036
1042
1043
1047
1048
1052
1056
1060
1061
1062private:
1063 int updatePerEdgeBuffers_;
1064 std::vector<ACG::Vec3f> perEdgeVertexBuf_;
1065 std::vector<ACG::Vec4f> perEdgeColorBuf_;
1066
1067 std::vector<float> perEdgeBuf_; // vertex vec3f + color vec4f
1068
1069 int updatePerHalfedgeBuffers_;
1070 std::vector<ACG::Vec3f> perHalfedgeVertexBuf_;
1071 std::vector<ACG::Vec4f> perHalfedgeColorBuf_;
1072
1080 template<typename Mesh::Normal (DrawMeshT::*NormalLookup)(typename Mesh::FaceHandle)>
1081 typename Mesh::Point halfedge_point(const typename Mesh::HalfedgeHandle _heh);
1082
1083 inline
1084 typename Mesh::Normal cachedNormalLookup(typename Mesh::FaceHandle fh) {
1085 return mesh_.normal(fh);
1086 }
1087
1088 inline
1089 typename Mesh::Normal computedTriMeshNormal(typename Mesh::FaceHandle fh) {
1090 typename Mesh::FVIter fv_iter = mesh_.fv_begin(fh);
1091 const typename Mesh::Point p1 = mesh_.point(*fv_iter);
1092 const typename Mesh::Point p2 = mesh_.point(*(++fv_iter));
1093 const typename Mesh::Point p3 = mesh_.point(*(++fv_iter));
1094 return ( p1 + p2 + p3 ) / 3.0;
1095 }
1096
1097 inline
1098 typename Mesh::Normal computedNormal(typename Mesh::FaceHandle fh) {
1099 unsigned int count = 0;
1100 typename Mesh::Normal normal(0, 0, 0);
1101 for (typename Mesh::FVIter fv_it = mesh_.fv_begin(fh), fv_end = mesh_.fv_end(fh); fv_it != fv_end; ++fv_it) {
1102 normal += mesh_.point(*fv_it);
1103 ++count;
1104 }
1105 normal /= count;
1106 return normal;
1107 }
1108
1109 typename Mesh::HalfedgeHandle mapToHalfedgeHandle(size_t _vertexId);
1110
1111};
1112
1113
1114// defined in DrawMeshT_impl.cc:
1115extern template class DrawMeshT<::OpenMesh::TriMesh>;
1116extern template class DrawMeshT<::OpenMesh::PolyMesh>;
1117
1118} // namespace ACG
GLenum getIndexType() const
get index type of index buffer
Definition DrawMesh.hh:110
GLuint pickVertexIBO_opt()
get an index buffer mapping from openmesh vertices to drawmesh vbo vertices
Definition DrawMesh.hh:116
GLuint pickVertexIBO_
map from openmesh vertex to vbo vertex id
Definition DrawMesh.hh:156
VertexDeclaration * vertexDeclHalfedgePos_
vertex buffer layout declaration with halfedge positions only
Definition DrawMesh.hh:153
GLenum indexType_
support for 2 and 4 byte unsigned integers
Definition DrawMesh.hh:133
VertexDeclaration vertexDeclEdgeNew_
vertex buffer layout declaration with per edge colors
Definition DrawMesh.hh:147
VertexDeclaration * vertexDeclEdgeCol_
vertex buffer layout declaration with per edge colors, legacy path
Definition DrawMesh.hh:144
VertexDeclaration * vertexDecl_
vertex buffer layout declaration with per vertex colors
Definition DrawMesh.hh:141
VertexDeclaration * vertexDeclHalfedgeCol_
vertex buffer layout declaration with per halfedge colors
Definition DrawMesh.hh:150
GLuint heVBO_
vbo for halfedge rendering, as they are offset
Definition DrawMesh.hh:128
MeshCompiler * getMeshCompiler()
get mesh compiler used to create the draw mesh
Definition DrawMesh.hh:105
std::vector< char > vertices_
Definition DrawMesh.hh:138
GLuint lineIBO_
index buffer used in Wireframe / Hiddenline mode
Definition DrawMesh.hh:126
Mesh Drawing Class.
Definition DrawMesh.hh:172
void updatePickingAny_opt(ACG::GLState &_state)
Update color picking array for the shader implementation.
ACG::Vec4f * perHalfedgeColorBuffer()
get a pointer to the per edge color buffer
void updatePickingAny(ACG::GLState &_state)
Call this function to update the color picking array.
unsigned int countTris(unsigned int *_pOutMaxPolyVerts=0, unsigned int *_pOutNumIndices=0)
Number of triangles after triangulation of the mesh.
VertexDeclaration * getVertexDeclaration()
get vertex declaration of the current vbo layout
int perFaceTextureCoordinateAvailable()
Check if per Face Texture coordinates are available.
ACG::Vec3f * perHalfedgeVertexBuffer()
get a pointer to the per edge vertex buffer
void addLineRenderObjects(IRenderer *_renderer, const RenderObject *_baseObj)
render the mesh in wireframe mode, deferred draw call
const void * testMeshPropertyTypeT(const OpenMesh::BaseProperty *_prop, unsigned int *_outSize) const
test mesh property for type T
void createVertexDeclaration()
creates all vertex declarations needed for deferred draw call renderer
void drawLines()
render the mesh in wireframe mode
ACG::Vec4uc * pickAnyFaceColorBuffer()
get a pointer to the any picking color buffer
Definition DrawMesh.hh:685
ACG::Vec3f * perEdgeVertexBuffer()
get a pointer to the per edge vertex buffer
void updatePickingFaces_opt(ACG::GLState &_state)
Update color picking array for the shader implementation.
int halfedgeNormalMode_
per vertex / halfedge normals mode toggle: 0: per vertex, 1: per halfedge
Definition DrawMesh.hh:852
void drawPickingFaces_opt(const GLMatrixf &_mvp, size_t _pickOffset)
Optimized rendering of face picking ids with a shader.
void drawPickingEdges_opt(const GLMatrixf &_mvp, size_t _pickOffset)
Optimized rendering of edge picking ids with a shader.
ACG::Vec4uc * pickAnyVertexColorBuffer()
get a pointer to the any picking color buffer
Definition DrawMesh.hh:719
void bindBuffers()
eventually rebuilds buffers used for rendering and binds index and vertex buffer
void updateTopology()
request an update for the mesh topology
Definition DrawMesh.hh:285
void drawPickingAny_opt(const GLMatrixf &_mvp, size_t _pickOffset)
Optimized rendering of any picking ids with a shader.
int colorMode_
Color Mode: 0: none, 1: per vertex, else: per face.
Definition DrawMesh.hh:834
void addVertexElement(const std::string &_propertyName, PropertySource _source=PROPERTY_SOURCE_VERTEX)
Add custom elements to the vertex layout.
void updatePickingEdges(ACG::GLState &_state, uint _offset=0)
Update color picking array for edges.
unsigned int getFaceColor(const typename Mesh::FaceHandle &_fh)
return a face color from mesh
unsigned int mapVertexToVBOIndex(unsigned int _v)
map from vertex index of the original mesh point buffer to the corresponding vertex index inside the ...
void updateGPUBuffers()
eventually update vertex and index buffers
const void * getMeshPropertyType(OpenMesh::BaseProperty *_prop, GLuint *_outType, unsigned int *_outSize) const
get the data type of a mesh property
ACG::Vec3f * pickFaceVertexBuffer()
get a pointer to the per vertex picking color buffer
Definition DrawMesh.hh:617
void updateFull()
request a full rebuild of the mesh
Definition DrawMesh.hh:298
void updatePickingEdges_opt(ACG::GLState &_state)
Update color picking array for the shader implementation.
void updatePerHalfedgeBuffers()
Update all per edge drawing buffer n The updated buffers are: per edge vertex buffer ( 2 vertices per...
int getTextureIDofFace(unsigned int _face)
get the texture index of a face
void rebuild()
draw_mesh updater
void updateTextures()
request an update for the textures
Definition DrawMesh.hh:293
void invalidatePerEdgeBuffers()
Update of the buffers.
Definition DrawMesh.hh:992
unsigned int * invVertexMap_
Definition DrawMesh.hh:861
void drawVertices()
render vertices only
int bVBOinHalfedgeTexMode_
texcoords in VBO currently in per vertex / halfedge mode toggle
Definition DrawMesh.hh:849
unsigned int getMemoryUsage(bool _printReport=false)
measures the size in bytes of allocated memory. eventually prints a report to std::cout
const VertexDeclaration * getHalfedgeColoredVertexDeclaration() const
getter for vertex declarations
Definition DrawMesh.hh:1059
void invalidateFullVBO()
the mesh has been changed
bool supportsPickingAny_opt()
Check if optimized any picking is supported.
bool supportsPickingVertices_opt()
Check if optimized vertex picking is supported.
void readVertexFromVBO(unsigned int _vertex, void *_dst)
Read one vertex from the rendering vbo.
void setPerFaceTextureCoordinatePropertyName(std::string _perFaceTextureCoordinatePropertyName)
set the name of the property used for texture coordinate
std::vector< ACG::Vec4uc > pickVertColBuf_
The color buffer used for vertex picking.
Definition DrawMesh.hh:511
void setTextureIndexPropertyName(std::string _indexPropertyName)
set the name of the property used for texture index specification
unsigned int rebuild_
hint on what to rebuild
Definition DrawMesh.hh:825
int flatMode_
flat / smooth shade mode toggle
Definition DrawMesh.hh:840
ACG::Vec4uc * pickEdgeColorBuffer()
get a pointer to the per edge picking color buffer
Definition DrawMesh.hh:547
bool supportsPickingEdges_opt()
Check if optimized face picking is supported.
ACG::Vec4f * perEdgeColorBuffer()
get a pointer to the per edge color buffer
unsigned int getVertexColor(const typename Mesh::VertexHandle &_vh)
return a vertex color from mesh
int bVBOinFlatMode_
normals in VBO currently in flat / smooth mode
Definition DrawMesh.hh:843
bool supportsPickingFaces_opt()
Check if optimized face picking is supported.
std::vector< VertexProperty > additionalElements_
additional optional elements
Definition DrawMesh.hh:901
void addTriRenderObjects(IRenderer *_renderer, const RenderObject *_baseObj, std::map< int, GLuint > *_textureMap, bool _nonindexed=false)
adds RenderObjects to a deferred draw call renderer
Mesh::Point halfedge_point(const typename Mesh::HalfedgeHandle _heh)
compute halfedge point compute visualization point for halfedge (shifted to interior of face)
void createVBO()
stores the vertex buffer on the gpu
void readVertex(size_t _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
void updateFullVBO()
update the full mesh vbo
unsigned int * indices_
final index buffer used for rendering
Definition DrawMesh.hh:822
GLSL::Program * pickFaceShader_
optimized face picking shader
Definition DrawMesh.hh:665
const VertexDeclaration * getEdgeColoredVertexDeclaration() const
getter for vertex declarations
Definition DrawMesh.hh:1051
void drawPickingVertices_opt(const GLMatrixf &_mvp, size_t _pickOffset)
Optimized rendering of vertex picking ids with a shader.
std::vector< ACG::Vec3f > pickVertBuf_
The vertex buffer used for vertex picking.
Definition DrawMesh.hh:509
ACG::Vec4uc * pickAnyEdgeColorBuffer()
get a pointer to the any picking color buffer
Definition DrawMesh.hh:702
void updatePickingVertices(ACG::GLState &_state, uint _offset=0)
GLuint getHEVBO()
getHEVBO get VBO which stores Halfedges with offset
Definition DrawMesh.hh:218
int getTextureIDofTri(unsigned int _tri)
get the texture index of a triangle
const VertexDeclaration * getHalfedgeVertexDeclaration() const
getter for vertex declarations
Definition DrawMesh.hh:1055
void invalidatePerHalfedgeBuffers()
Update of the buffers.
Definition DrawMesh.hh:1022
void updatePerEdgeBuffersNew()
Update the combined position + color buffer for edge rendering.
const std::string & getTextureIndexPropertyName() const
get the name of the texture index property
Definition DrawMesh.hh:320
void updatePickingVertices_opt(ACG::GLState &_state)
Update color picking array for the shader implementation.
size_t prevNumFaces_
Definition DrawMesh.hh:830
void draw(std::map< int, GLuint > *_textureMap, bool _nonindexed=false)
binds index and vertex buffer and executes draw calls
GLuint getVBO()
get opengl vertex buffer id
ACG::Vec3f * pickVertexBuffer()
get a pointer to the per vertex picking vertex buffer
Definition DrawMesh.hh:466
Mesh & mesh_
OpenMesh object to be rendered.
Definition DrawMesh.hh:819
int perFaceTextureIndexAvailable()
Check if texture indices are available.
void updateGeometry()
request an update for the mesh vertices
Definition DrawMesh.hh:289
bool scanVertexShaderForInput(const std::string &_vertexShaderFile)
Scan vertex layout from vertex shader.
GLuint getIBO()
get opengl index buffer id
ACG::Vec4uc * pickVertexColorBuffer()
get a pointer to the per vertex picking color buffer
Definition DrawMesh.hh:449
void createIBO()
stores the index buffer on the gpu
void updatePickingFaces(ACG::GLState &_state)
Update color picking array for faces.
void addPointRenderObjects(IRenderer *_renderer, const RenderObject *_baseObj)
render vertices only, deferred draw call
void unbindBuffers()
disables vertex, normal, texcoord and color pointers in OpenGL
unsigned int getNumTextures()
returns the number of used textured of this mesh
void bindBuffersToRenderObject(RenderObject *_obj)
eventually rebuilds buffers used for rendering and binds index and vertex buffer
std::string textureIndexPropertyName_
Property for the per face texture index.
Definition DrawMesh.hh:914
int textureMode_
per vertex / halfedge texture mode toggle: 0: per vertex, 1: per halfedge
Definition DrawMesh.hh:846
void updatePerEdgeBuffers()
Update all per edge drawing buffers.
void dumpObj(const char *_filename) const
dump current vertex/index buffer to wavefront obj
int curVBOColorMode_
Color Mode of vbo.
Definition DrawMesh.hh:837
std::string perFaceTextureCoordinatePropertyName_
Property for the per face texture coordinates.
Definition DrawMesh.hh:921
int bVBOinHalfedgeNormalMode_
normals in VBO currently in per vertex / halfedge mode toggle
Definition DrawMesh.hh:855
ACG::Vec4uc * pickFaceColorBuffer()
get a pointer to the per face picking color buffer
Definition DrawMesh.hh:600
const size_t offsetPos_
fixed vertex elements:
Definition DrawMesh.hh:895
void updateEdgeHalfedgeVertexDeclarations()
updates per edge and halfedge vertex declarations
int getNumSubsets() const
Get the number of subsets.
Class to define the vertex input layout.
GLSL program class.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition PolyMeshT.hh:136
Kernel::Normal Normal
Normal type.
Definition PolyMeshT.hh:114
Kernel::FaceHandle FaceHandle
Scalar type.
Definition PolyMeshT.hh:139
Kernel::HalfedgeHandle HalfedgeHandle
Scalar type.
Definition PolyMeshT.hh:137
Kernel::Point Point
Coordinate type.
Definition PolyMeshT.hh:112
Namespace providing different geometric functions concerning angles.
const void * propDataPtr_
memory address of property data
Definition DrawMesh.hh:888
VertexElement sourceType_
property type as stored in openmesh
Definition DrawMesh.hh:882
std::string vertexShaderInputName_
input name id in vertex shader
Definition DrawMesh.hh:879
VertexElement destType_
property type as stored in vbo
Definition DrawMesh.hh:885
std::string name_
property name in openmesh
Definition DrawMesh.hh:876
int declElementID_
element id in vertex declaration
Definition DrawMesh.hh:891
Interface class between scenegraph and renderer.
Description of one vertex element.