Developer Documentation
VolumeMeshNodeT.cc
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 #define VOLUMEMESHNODET_CC
51 
52 //== INCLUDES =================================================================
53 
54 #include "VolumeMeshNode.hh"
55 
56 #include <ACG/GL/gl.hh>
57 #include <ACG/Utils/VSToolsT.hh>
58 #include <vector>
59 
60 #include <ACG/GL/RenderObject.hh>
61 #include <ACG/GL/VertexDeclaration.hh>
62 #include <ACG/GL/IRenderer.hh>
63 
64 #include <OpenVolumeMesh/Mesh/HexahedralMesh.hh>
65 
67 
68 
69 //== NAMESPACES ===============================================================
70 
71 namespace ACG {
72 namespace SceneGraph {
73 
74 //== IMPLEMENTATION ==========================================================
75 
76 
77 template<class VolumeMeshT>
79  OpenVolumeMesh::StatusAttrib& _statusAttrib,
83  const MaterialNode* _matNode, BaseNode* _parent,
84  std::string _name) :
85  BaseNode(_parent, _name),
86  mesh_(_mesh),
87  scale_(1.0),
88  boundary_only_(false),
89  translucency_factor_(0.1f),
90  selection_color_(ACG::Vec4f(1.0f, 0.0f, 0.0f, 1.0f)),
91  statusAttrib_(_statusAttrib),
92  colorAttrib_(_colorAttrib),
93  normalAttrib_(_normalAttrib),
94  texcoordAttrib_(_texcoordAttrib),
95  materialNode_(_matNode),
96 
97  cellsBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
98  facesBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
99  edgesBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
100  verticesBufferManager_(_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
101 
102  cellSelectionBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
103  faceSelectionBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
104  edgeSelectionBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
105  vertexSelectionBufferManager_(_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
106 
107  cellPickBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
108  facePickBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
109  edgePickBufferManager_ (_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
110  vertexPickBufferManager_(_mesh, _statusAttrib, _colorAttrib, _normalAttrib, _texcoordAttrib),
111 
112  drawModes_(),
113  lastDrawMode_ (DrawModes::NONE),
114  lastCellDrawMode_ (DrawModes::NONE),
115  lastFaceDrawMode_ (DrawModes::NONE),
116  lastEdgeDrawMode_ (DrawModes::NONE),
117  lastVertexDrawMode_(DrawModes::NONE),
118  lastPickTarget_(PICK_ANYTHING),
119  face_normals_calculated_(false),
120  vertex_normals_calculated_(false)
121 {
122  vertexSelectionBufferManager_.setSelectionOnly(true);
123  edgeSelectionBufferManager_.setSelectionOnly(true);
124  faceSelectionBufferManager_.setSelectionOnly(true);
125  cellSelectionBufferManager_.setSelectionOnly(true);
126 }
127 
128 
129 //----------------------------------------------------------------------------
130 
131 template<class VolumeMeshT>
133 
134 }
135 
136 //----------------------------------------------------------------------------
137 
138 template<class VolumeMeshT>
140 
141  int n_vertices(mesh_.n_vertices());
142  for (int i = 0; i < n_vertices; ++i) {
143  Vec3d p(mesh_.vertex(VertexHandle(i)));
144  _bbMin.minimize(p);
145  _bbMax.maximize(p);
146  }
147 }
148 
149 //----------------------------------------------------------------------------
150 
151 
152 template<class VolumeMeshT>
154  DrawModes::DrawMode result;
155 
156  if (mesh_.n_cells() > 0)
157  {
158  result |= drawModes_.cellsTransparent;
159  result |= drawModes_.cellsFlatShaded;
160  result |= drawModes_.cellsSmoothShaded;
161  result |= drawModes_.cellsPhongShaded;
162  if (colorAttrib_.vertex_colors_available())
163  result |= drawModes_.cellsColoredPerVertex;
164  if (colorAttrib_.halfface_colors_available())
165  result |= drawModes_.cellsColoredPerHalfface;
166  if (colorAttrib_.face_colors_available())
167  result |= drawModes_.cellsColoredPerFace;
168  if (colorAttrib_.cell_colors_available())
169  result |= drawModes_.cellsColoredPerCell;
170  }
171 
172  if (mesh_.n_faces() > 0)
173  {
174  result |= drawModes_.facesFlatShaded;
175  result |= drawModes_.facesSmoothShaded;
176  result |= drawModes_.facesPhongShaded;
177  if (colorAttrib_.vertex_colors_available())
178  result |= drawModes_.facesColoredPerVertex;
179  if (colorAttrib_.face_colors_available())
180  result |= drawModes_.facesColoredPerFace;
181  if (texcoordAttrib_.vertex_texcoords_available())
182  result |= drawModes_.facesTextured;
183  if (texcoordAttrib_.vertex_texcoords_available())
184  result |= drawModes_.facesTexturedShaded;
185  }
186 
187  if (mesh_.n_halffaces() > 0)
188  {
189  result |= drawModes_.halffacesFlatShaded;
190  result |= drawModes_.halffacesSmoothShaded;
191  result |= drawModes_.halffacesPhongShaded;
192  if (colorAttrib_.vertex_colors_available())
193  result |= drawModes_.halffacesColoredPerVertex;
194  if (colorAttrib_.halfface_colors_available())
195  result |= drawModes_.halffacesColoredPerHalfface;
196  }
197 
198  if (mesh_.n_edges() > 0)
199  {
200  result |= drawModes_.edgesWireframe;
201 
202  if (mesh_.n_cells () > 0)
203  result |= drawModes_.edgesOnCells;
204  if (mesh_.n_faces() > 0)
205  result |= drawModes_.edgesHiddenLine;
206  if (colorAttrib_.edge_colors_available())
207  result |= drawModes_.edgesColoredPerEdge;
208 
209  if (dynamic_cast<const HexahedralMeshTopologyKernel*>(&mesh_) != NULL)
210  {
211  result |= drawModes_.irregularInnerEdges;
212  result |= drawModes_.irregularOuterEdges;
213  }
214  }
215 
216  if (mesh_.n_halfedges() > 0)
217  {
218  result |= drawModes_.halfedgesWireframe;
219 
220  if (mesh_.n_faces() > 0)
221  result |= drawModes_.halfedgesHiddenLine;
222  if (colorAttrib_.halfedge_colors_available())
223  result |= drawModes_.halfedgesColoredPerHalfedge;
224  }
225 
226  if (mesh_.n_vertices() > 0)
227  {
228  result |= drawModes_.verticesFlatShaded;
229 
230  if (colorAttrib_.vertex_colors_available())
231  result |= drawModes_.verticesColored;
232  }
233 
234  return result;
235 
236 }
237 
238 
239 //----------------------------------------------------------------------------
240 
241 
242 template<class VolumeMeshT>
244 {
245 
246  ACG::GLState::depthRange(0.01, 1.0);
247 
248  cellsBufferManager_.setOptionsFromDrawMode(_drawMode);
249  GLState::bindBuffer(GL_ARRAY_BUFFER, cellsBufferManager_.getBuffer());
250  GLState::enableClientState(GL_VERTEX_ARRAY);
251  GLState::vertexPointer(3, GL_FLOAT, cellsBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
252 
253  GLState::enableClientState(GL_NORMAL_ARRAY);
254  GLState::normalPointer(GL_FLOAT, cellsBufferManager_.getStride(), reinterpret_cast<GLvoid*>(cellsBufferManager_.getNormalOffset()));
255 
256  if (_drawMode & (drawModes_.cellsColoredPerCell | drawModes_.cellsColoredPerFace | drawModes_.cellsColoredPerHalfface | drawModes_.cellsColoredPerVertex))
257  {
258  //for a drawmode with colors we have to activate and bind colors
259  GLState::enableClientState(GL_COLOR_ARRAY);
260  GLState::colorPointer(4, GL_UNSIGNED_BYTE, cellsBufferManager_.getStride(), reinterpret_cast<GLvoid*>(cellsBufferManager_.getColorOffset()));
261 
262  GLState::shadeModel(GL_SMOOTH);
263  GLState::disable(GL_LIGHTING);
264  GLState::enable(GL_DEPTH_TEST);
265 
266  }
267  else if (_drawMode & drawModes_.cellsSmoothShaded)
268  {
269  GLState::shadeModel(GL_SMOOTH);
270  GLState::enable(GL_LIGHTING);
271  GLState::enable(GL_DEPTH_TEST);
272  }
273  else if (_drawMode & drawModes_.cellsFlatShaded)
274  {
275  GLState::shadeModel(GL_FLAT);
276  GLState::enable(GL_LIGHTING);
277  GLState::enable(GL_DEPTH_TEST);
278  }
279  else if (_drawMode & drawModes_.cellsTransparent)
280  {
281  GLState::shadeModel(GL_FLAT);
282  GLState::disable(GL_LIGHTING);
283  GLState::disable(GL_DEPTH_TEST);
284  GLState::disableClientState(GL_COLOR_ARRAY);
285  Vec4f bc = _state.specular_color();
286  _state.set_color(Vec4f(bc[0],bc[1],bc[2],translucency_factor_));
287  GLState::enable(GL_BLEND);
288  GLState::blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
289  }
290 
291  glDrawArrays(GL_TRIANGLES, 0, cellsBufferManager_.getNumOfVertices());
292 
293  if (_drawMode & drawModes_.cellsTransparent)
294  {
295  _state.set_color(_state.base_color());
296  GLState::disable(GL_BLEND);
297  }
298 
299  GLState::disableClientState(GL_COLOR_ARRAY);
300  GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
301 
302  ACG::GLState::depthRange(0.0, 1.0);
303 }
304 
305 template<class VolumeMeshT>
307 {
308 
309  ACG::GLState::depthRange(0.01, 1.0);
310 
311  //faces are drawn from both sides, halffaces only when facing the camera
312  //however, if we only draw the boundary, we draw halffaces from both sides so we can see them
313  //when looking inside the object
314  if ((_drawMode & drawModes_.faceBasedDrawModes) || boundary_only_)
315  {
316  GLState::disable(GL_CULL_FACE);
317  }
318  else
319  {
320  GLState::enable(GL_CULL_FACE);
321  GLState::cullFace(GL_BACK);
322  }
323 
324  GLState::enable(GL_DEPTH_TEST);
325 
326  facesBufferManager_.setOptionsFromDrawMode(_drawMode);
327  GLState::bindBuffer(GL_ARRAY_BUFFER, facesBufferManager_.getBuffer());
328  GLState::enableClientState(GL_VERTEX_ARRAY);
329  GLState::vertexPointer(3, GL_FLOAT, facesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
330 
331  if (_drawMode & (drawModes_.hiddenLineBackgroundFaces))
332  {
333  GLState::disable(GL_LIGHTING);
334  GLState::shadeModel(GL_FLAT);
335  GLState::disableClientState(GL_COLOR_ARRAY);
336  GLState::disableClientState(GL_NORMAL_ARRAY);
337  _state.set_color(_state.clear_color());
338  }
339  else if (_drawMode & (drawModes_.facesColoredPerFace | drawModes_.facesColoredPerVertex
340  | drawModes_.halffacesColoredPerHalfface | drawModes_.halffacesColoredPerVertex ))
341  {
342  GLState::enableClientState(GL_COLOR_ARRAY);
343  GLState::colorPointer(4, GL_UNSIGNED_BYTE, facesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(facesBufferManager_.getColorOffset()));
344 
345  GLState::disable(GL_LIGHTING);
346  GLState::shadeModel(GL_SMOOTH);
347  }
348  else if (_drawMode & (drawModes_.facesTexturedShaded) )
349  {
350  glClientActiveTexture(GL_TEXTURE0);
351  ACG::GLState::texcoordPointer(2, GL_FLOAT, facesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(facesBufferManager_.getTexCoordOffset()));
352  ACG::GLState::enableClientState(GL_TEXTURE_COORD_ARRAY);
353 
354  GLState::enable(GL_LIGHTING);
355  GLState::disableClientState(GL_COLOR_ARRAY);
356 
357  GLState::enableClientState(GL_NORMAL_ARRAY);
358  GLState::normalPointer(GL_FLOAT, facesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(facesBufferManager_.getNormalOffset()));
359 
360  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
361  GLState::shadeModel(GL_SMOOTH);
362  }
363  else if (_drawMode & (drawModes_.facesTextured) )
364  {
365  glClientActiveTexture(GL_TEXTURE0);
366  ACG::GLState::texcoordPointer(2, GL_FLOAT, facesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(facesBufferManager_.getTexCoordOffset()));
367  ACG::GLState::enableClientState(GL_TEXTURE_COORD_ARRAY);
368 
369  GLState::disableClientState(GL_COLOR_ARRAY);
370  GLState::disableClientState(GL_NORMAL_ARRAY);
371 
372  GLState::disable(GL_LIGHTING);
373  GLState::shadeModel(GL_SMOOTH);
374 
375  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
376  }
377  else
378  {
379  GLState::enable(GL_LIGHTING);
380  GLState::disableClientState(GL_COLOR_ARRAY);
381 
382  GLState::enableClientState(GL_NORMAL_ARRAY);
383  GLState::normalPointer(GL_FLOAT, facesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(facesBufferManager_.getNormalOffset()));
384 
385  GLState::shadeModel(GL_SMOOTH);
386  }
387 
388  glDrawArrays(GL_TRIANGLES, 0, facesBufferManager_.getNumOfVertices());
389 
390  GLState::disableClientState(GL_COLOR_ARRAY);
391 
392  GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
393 
394  if (_drawMode & (drawModes_.edgesHiddenLine | drawModes_.halfedgesHiddenLine))
395  _state.set_color(_state.base_color());
396 
397  ACG::GLState::depthRange(0.0, 1.0);
398 }
399 
400 template<class VolumeMeshT>
402 {
403  ACG::GLState::depthRange(0.0, 1.0);
404 
405  edgesBufferManager_.setDefaultColor(_state.specular_color());
406  edgesBufferManager_.setOptionsFromDrawMode(_drawMode);
407 
408  GLState::bindBuffer(GL_ARRAY_BUFFER, edgesBufferManager_.getBuffer());
409  GLState::enableClientState(GL_VERTEX_ARRAY);
410  GLState::vertexPointer(3, GL_FLOAT, edgesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
411 
412  if (_drawMode & ( drawModes_.edgesColoredPerEdge | drawModes_.halfedgesColoredPerHalfedge |
413  drawModes_.irregularInnerEdges | drawModes_.irregularOuterEdges ))
414  {
415  GLState::enableClientState(GL_COLOR_ARRAY);
416  GLState::colorPointer(4, GL_UNSIGNED_BYTE, edgesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(edgesBufferManager_.getColorOffset()));
417 
418  GLState::disable(GL_LIGHTING);
419  GLState::shadeModel(GL_SMOOTH);
420 
421  glLineWidth(_state.line_width() * 2.0f);
422  }
423  else
424  {
425  _state.set_color( _state.specular_color() );
426 
427  ACG::GLState::disable(GL_LIGHTING);
428  ACG::GLState::shadeModel(GL_FLAT);
429 
430  GLState::disableClientState(GL_NORMAL_ARRAY);
431  }
432 
433 
434  glDrawArrays(GL_LINES, 0, edgesBufferManager_.getNumOfVertices());
435  glLineWidth(_state.line_width());
436 
437  GLState::disableClientState(GL_COLOR_ARRAY);
438 
439  GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
440 
441 }
442 
443 template<class VolumeMeshT>
445 {
446  verticesBufferManager_.setOptionsFromDrawMode(_drawMode);
447  GLState::bindBuffer(GL_ARRAY_BUFFER, verticesBufferManager_.getBuffer());
448  GLState::enableClientState(GL_VERTEX_ARRAY);
449  GLState::vertexPointer(3, GL_FLOAT, verticesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
450 
451  GLState::depthRange(0.0,1.0);
452 
453  if (_drawMode & ( drawModes_.verticesColored ))
454  {
455  GLState::enableClientState(GL_COLOR_ARRAY);
456  GLState::colorPointer(4, GL_UNSIGNED_BYTE, verticesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(verticesBufferManager_.getColorOffset()));
457 
458  GLState::disable(GL_LIGHTING);
459  GLState::shadeModel(GL_SMOOTH);
460  }
461  else
462  {
463  _state.set_color( _state.specular_color() );
464 
465  ACG::GLState::disable(GL_LIGHTING);
466  ACG::GLState::shadeModel(GL_FLAT);
467 
468  GLState::disableClientState(GL_NORMAL_ARRAY);
469  }
470 
471  glDrawArrays(GL_POINTS, 0, verticesBufferManager_.getNumOfVertices());
472 
473  GLState::disableClientState(GL_COLOR_ARRAY);
474 
475  GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
476 
477 }
478 
479 template<class VolumeMeshT>
481 {
482 
483  //save current shader
484  GLint currentProgramm;
485  glGetIntegerv(GL_CURRENT_PROGRAM, &currentProgramm);
486  //disable shader for drawing of the selecttion
488 
489  GLState::enable(GL_DEPTH_TEST);
490  GLState::depthFunc(GL_LEQUAL);
491  _state.set_color( selection_color_ );
492 
493  GLState::disable(GL_LIGHTING);
494  GLState::shadeModel(GL_FLAT);
495  glDisable(GL_CULL_FACE);
496  GLState::disableClientState(GL_NORMAL_ARRAY);
497  GLState::disableClientState(GL_COLOR_ARRAY);
498 
499  GLState::disable(GL_TEXTURE_2D);
500 
501  GLState::enableClientState(GL_VERTEX_ARRAY);
502 
503  if ((_drawMode & drawModes_.cellBasedDrawModes) && !(_drawMode & drawModes_.vertexBasedDrawModes))
504  vertexSelectionBufferManager_.enableVertexOnCellPrimitives();
505  else
506  vertexSelectionBufferManager_.enableVertexPrimitives();
507 
508  if ((_drawMode & (drawModes_.cellBasedDrawModes | drawModes_.edgesOnCells)) && !(_drawMode & (drawModes_.edgeBasedDrawModes & ~drawModes_.edgesOnCells)))
509  edgeSelectionBufferManager_.enableEdgeOnCellPrimitives();
510  else
511  edgeSelectionBufferManager_.enableEdgePrimitives();
512 
513  if ((_drawMode & drawModes_.cellBasedDrawModes) && !(_drawMode & (drawModes_.faceBasedDrawModes | drawModes_.halffaceBasedDrawModes)))
514  faceSelectionBufferManager_.enableFaceOnCellPrimitives();
515  else
516  faceSelectionBufferManager_.enableFacePrimitives();
517 
518  cellSelectionBufferManager_.enableCellPrimitives();
519 
520  glLineWidth(1.5*_state.line_width());
521 
522  GLState::depthRange(0.0,1.0);
523 
524  GLState::bindBuffer(GL_ARRAY_BUFFER, vertexSelectionBufferManager_.getBuffer());
525  GLState::vertexPointer(3, GL_FLOAT, 0, 0);
526  glDrawArrays(GL_POINTS, 0, vertexSelectionBufferManager_.getNumOfVertices());
527 
528  GLState::bindBuffer(GL_ARRAY_BUFFER, edgeSelectionBufferManager_.getBuffer());
529  GLState::vertexPointer(3, GL_FLOAT, 0, 0);
530  glDrawArrays(GL_LINES, 0, edgeSelectionBufferManager_.getNumOfVertices());
531 
532  GLState::depthRange(0.01,1.0);
533 
534  GLState::bindBuffer(GL_ARRAY_BUFFER, faceSelectionBufferManager_.getBuffer());
535  GLState::vertexPointer(3, GL_FLOAT, 0, 0);
536  glDrawArrays(GL_TRIANGLES, 0, faceSelectionBufferManager_.getNumOfVertices());
537 
538  GLState::bindBuffer(GL_ARRAY_BUFFER, cellSelectionBufferManager_.getBuffer());
539  GLState::vertexPointer(3, GL_FLOAT, 0, 0);
540  glDrawArrays(GL_TRIANGLES, 0, cellSelectionBufferManager_.getNumOfVertices());
541 
542  GLState::depthRange(0.0,1.0);
543 
544  _state.set_color(_state.base_color());
545 
546  GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
547 
548 
549  glLineWidth(_state.line_width());
550 
551  ACG::GLState::useProgram(currentProgramm);
552 
553 }
554 
555 template<class VolumeMeshT>
557 {
561 }
562 
563 template<class VolumeMeshT>
565 {
566  cellsBufferManager_.invalidate();
567  facesBufferManager_.invalidate();
568  edgesBufferManager_.invalidate();
569  verticesBufferManager_.invalidate();
570 }
571 
572 template<class VolumeMeshT>
574 {
575  cellPickBufferManager_.invalidate();
576  facePickBufferManager_.invalidate();
577  edgePickBufferManager_.invalidate();
578  vertexPickBufferManager_.invalidate();
579 }
580 
581 template<class VolumeMeshT>
583 {
584  cellSelectionBufferManager_.invalidate();
585  faceSelectionBufferManager_.invalidate();
586  edgeSelectionBufferManager_.invalidate();
587  vertexSelectionBufferManager_.invalidate();
588 }
589 
590 template<class VolumeMeshT>
592 
593  //save state
594  GLboolean lighting = false;
595  glGetBooleanv(GL_LIGHTING, &lighting);
596  GLboolean color_material = false;
597  glGetBooleanv(GL_COLOR_MATERIAL, &color_material);
598  GLboolean blend = false;
599  glGetBooleanv(GL_BLEND, &blend);
600  GLboolean depth = false;
601  glGetBooleanv(GL_DEPTH_TEST, &depth);
602  GLenum prev_depth = _state.depthFunc();
603  GLboolean cullFace = false;
604  glGetBooleanv(GL_CULL_FACE, &cullFace);
605  GLint cullFaceMode;
606  glGetIntegerv(GL_CULL_FACE_MODE, &cullFaceMode);
607  GLint texmode;
608  glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &texmode);
609  GLboolean texturing;
610  glGetBooleanv(GL_TEXTURE_2D, &texturing);
611  const Vec4f oldColor = _state.color();
612 
613  // ignore two sided lighting setting and turn it off
614  GLboolean lightModel = _state.twosided_lighting();
615  _state.set_twosided_lighting(false);
616 
617  bool clientStateEnabledVertexArray = GLState::isClientStateEnabled(GL_VERTEX_ARRAY);
618  bool clientStateEnabledColorArray = GLState::isClientStateEnabled(GL_COLOR_ARRAY);
619  bool clientStateEnabledNormalArray = GLState::isClientStateEnabled(GL_NORMAL_ARRAY);
620  bool clientStateEnabledTexCoordArray = GLState::isClientStateEnabled(GL_TEXTURE_COORD_ARRAY);
621 
622  DrawModes::DrawMode cellDrawMode = drawModes_.getFirstCellDrawMode(_drawMode);
623  DrawModes::DrawMode faceDrawMode = drawModes_.getFirstFaceDrawMode(_drawMode);
624  DrawModes::DrawMode edgeDrawMode = drawModes_.getFirstEdgeDrawMode(_drawMode);
625  DrawModes::DrawMode vertexDrawMode = drawModes_.getFirstVertexDrawMode(_drawMode);
626 
627  if (!face_normals_calculated_)
628  {
629  if ( (cellDrawMode & drawModes_.cellsFlatShaded) ||
630  (faceDrawMode & (drawModes_.facesFlatShaded | drawModes_.halffacesFlatShaded | drawModes_.facesTexturedShaded)) )
632  }
633  if (!vertex_normals_calculated_)
634  {
635  if ( (cellDrawMode & (drawModes_.cellsSmoothShaded | drawModes_.cellsPhongShaded)) ||
636  (faceDrawMode & (drawModes_.facesSmoothShaded | drawModes_.halffacesSmoothShaded | drawModes_.facesPhongShaded | drawModes_.halffacesPhongShaded)) )
638  }
639 
640  //the VolumeMeshBufferManager can handle non atomic drawmodes if it consists of one
641  // edge based draw mode (except edges on cells) and irregular edges
642  edgeDrawMode |= _drawMode & (drawModes_.irregularInnerEdges | drawModes_.irregularOuterEdges);
643 
644 
645  if (cellDrawMode)
646  drawCells(_state, cellDrawMode);
647  else
648  cellsBufferManager_.free();
649  if (faceDrawMode)
650  drawFaces(_state, faceDrawMode);
651  else
652  facesBufferManager_.free();
653  if (edgeDrawMode)
654  drawEdges(_state, edgeDrawMode);
655  else
656  edgesBufferManager_.free();
657  if (vertexDrawMode)
658  drawVertices(_state, vertexDrawMode);
659  else
660  verticesBufferManager_.free();
661 
662  drawSelection(_state, cellDrawMode | faceDrawMode | edgeDrawMode | vertexDrawMode);
663 
664 
665  lastDrawMode_ = cellDrawMode | faceDrawMode | edgeDrawMode | vertexDrawMode;
666  lastCellDrawMode_ = cellDrawMode;
667  lastFaceDrawMode_ = faceDrawMode;
668  lastEdgeDrawMode_ = edgeDrawMode;
669  lastVertexDrawMode_ = vertexDrawMode;
670 
671  //restore state
672  if(lighting)
673  ACG::GLState::enable(GL_LIGHTING);
674  else
675  ACG::GLState::disable(GL_LIGHTING);
676  if(color_material)
677  ACG::GLState::enable(GL_COLOR_MATERIAL);
678  else
679  ACG::GLState::disable(GL_COLOR_MATERIAL);
680  if(blend)
681  ACG::GLState::enable(GL_BLEND);
682  else
683  ACG::GLState::disable(GL_BLEND);
684  if(depth)
685  ACG::GLState::enable(GL_DEPTH_TEST);
686  else
687  ACG::GLState::disable(GL_DEPTH_TEST);
688  _state.depthFunc(prev_depth);
689  if(cullFace)
690  ACG::GLState::enable(GL_CULL_FACE);
691  else
692  ACG::GLState::disable(GL_CULL_FACE);
693  ACG::GLState::cullFace(cullFaceMode);
694  if(texturing)
695  ACG::GLState::enable(GL_TEXTURE_2D);
696  else
697  ACG::GLState::disable(GL_TEXTURE_2D);
698  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, texmode);
699  _state.set_color(oldColor);
700 
701  _state.set_twosided_lighting(lightModel);
702 
703  if (clientStateEnabledVertexArray)
704  GLState::enableClientState(GL_VERTEX_ARRAY);
705  else
706  GLState::disableClientState(GL_VERTEX_ARRAY);
707 
708  if (clientStateEnabledColorArray)
709  GLState::enableClientState(GL_COLOR_ARRAY);
710  else
711  GLState::disableClientState(GL_COLOR_ARRAY);
712 
713  if (clientStateEnabledNormalArray)
714  GLState::enableClientState(GL_NORMAL_ARRAY);
715  else
716  GLState::disableClientState(GL_NORMAL_ARRAY);
717 
718  if (clientStateEnabledTexCoordArray)
719  GLState::enableClientState(GL_TEXTURE_COORD_ARRAY);
720  else
721  GLState::disableClientState(GL_TEXTURE_COORD_ARRAY);
722 
723 }
724 
725 
726 
727 template<class VolumeMeshT>
729 {
730  RenderObject ro;
731  ro.initFromState(&_state);
732 
733  ro.debugName = "VolumeMeshNodeCells";
734 
735  //Todo: use DrawModeProperties
736 
737  // reset renderobject
738  ro.depthTest = true;
739  ro.depthWrite = true;
740  ro.depthFunc = GL_LESS;
741  ro.setMaterial(_mat);
742 
744 
745  ro.shaderDesc.shadeMode = SG_SHADE_GOURAUD;
746 
747  ro.depthRange = Vec2f(0.01f, 1.0f);
748 
749  if (_drawMode & (drawModes_.cellsColoredPerCell | drawModes_.cellsColoredPerFace | drawModes_.cellsColoredPerHalfface | drawModes_.cellsColoredPerVertex))
750  {
751  ro.shaderDesc.vertexColors = true;
752  ro.shaderDesc.numLights = -1;
753  ro.shaderDesc.shadeMode = SG_SHADE_GOURAUD;
754 
755  }
756  else if (_drawMode & drawModes_.cellsSmoothShaded)
757  {
758  ro.shaderDesc.numLights = 0;
759  ro.shaderDesc.shadeMode = SG_SHADE_GOURAUD;
760  }
761  else if (_drawMode & drawModes_.cellsFlatShaded)
762  {
763  ro.shaderDesc.numLights = 0;
764  ro.shaderDesc.shadeMode = SG_SHADE_FLAT;
765  }
766  else if (_drawMode & drawModes_.cellsTransparent)
767  {
768  ro.shaderDesc.shadeMode = SG_SHADE_GOURAUD;
769  ro.shaderDesc.numLights = -1;
770  ro.depthTest = false;
771 
772  ro.diffuse = ACG::Vec3f(_state.specular_color()[0],_state.specular_color()[1],_state.specular_color()[2]);
773  ro.ambient = ACG::Vec3f(_state.specular_color()[0],_state.specular_color()[1],_state.specular_color()[2]);
774  ro.specular = ACG::Vec3f(_state.specular_color()[0],_state.specular_color()[1],_state.specular_color()[2]);
775  ro.emissive = ACG::Vec3f(_state.specular_color()[0],_state.specular_color()[1],_state.specular_color()[2]);
776 
777  ro.alpha = translucency_factor_;
778  ro.blending = true;
779  ro.blendDest = GL_ONE_MINUS_SRC_ALPHA;
780  ro.blendSrc = GL_SRC_ALPHA;
781  }
782 
783  cellsBufferManager_.setOptionsFromDrawMode(_drawMode);
784  ro.vertexBuffer = cellsBufferManager_.getBuffer();
785  ro.vertexDecl = cellsBufferManager_.getVertexDeclaration();
786 
787  ro.glDrawArrays(GL_TRIANGLES, 0, cellsBufferManager_.getNumOfVertices());
788  _renderer->addRenderObject(&ro);
789 }
790 
791 template<class VolumeMeshT>
793 {
794  RenderObject ro;
795  ro.initFromState(&_state);
796 
797  ro.debugName = "VolumeMeshNodeFaces";
798 
799  //Todo: use DrawModeProperties
800 
801  // reset renderobject
802  ro.depthTest = true;
803  ro.depthWrite = true;
804  ro.depthFunc = GL_LESS;
805  ro.setMaterial(_mat);
806 
808 
809  ro.shaderDesc.shadeMode = SG_SHADE_GOURAUD;
810 
811  ro.depthRange = Vec2f(0.01f, 1.0f);
812 
813  facesBufferManager_.setOptionsFromDrawMode(_drawMode);
814 
815 
816  if ((_drawMode & drawModes_.faceBasedDrawModes) || boundary_only_)
817  ro.culling = false;
818  else
819  ro.culling = true;
820 
821  if (_drawMode & (drawModes_.hiddenLineBackgroundFaces))
822  {
823  ro.shaderDesc.numLights = -1;
824  ro.shaderDesc.shadeMode = SG_SHADE_FLAT;
825 
826  ro.shaderDesc.vertexColors = false;
827 
828  ro.diffuse = ACG::Vec3f(_state.clear_color()[0],_state.clear_color()[1],_state.clear_color()[2]);
829  ro.ambient = ACG::Vec3f(_state.clear_color()[0],_state.clear_color()[1],_state.clear_color()[2]);
830  ro.specular = ACG::Vec3f(_state.clear_color()[0],_state.clear_color()[1],_state.clear_color()[2]);
831  ro.emissive = ACG::Vec3f(_state.clear_color()[0],_state.clear_color()[1],_state.clear_color()[2]);
832  }
833  else if (_drawMode & (drawModes_.facesColoredPerFace | drawModes_.facesColoredPerVertex
834  | drawModes_.halffacesColoredPerHalfface | drawModes_.halffacesColoredPerVertex ))
835  {
836  ro.shaderDesc.vertexColors = true;
837  ro.shaderDesc.numLights = -1;
838  ro.shaderDesc.shadeMode = SG_SHADE_GOURAUD;
839  }
840  else
841  {
842  ro.shaderDesc.numLights = 0;
843  ro.shaderDesc.vertexColors = false;
844  }
845 
846  ro.vertexBuffer = facesBufferManager_.getBuffer();
847  ro.vertexDecl = facesBufferManager_.getVertexDeclaration();
848 
849  ro.glDrawArrays(GL_TRIANGLES, 0, facesBufferManager_.getNumOfVertices());
850  _renderer->addRenderObject(&ro);
851 }
852 
853 template<class VolumeMeshT>
855 {
856  RenderObject ro;
857  ro.initFromState(&_state);
858 
859  ro.debugName = "VolumeMeshNodeEdges";
860 
861  //Todo: use DrawModeProperties
862 
863  // reset renderobject
864  ro.depthRange = Vec2f(0.0f, 1.0f);
865  ro.depthTest = true;
866  ro.depthWrite = true;
867  ro.depthFunc = GL_LESS;
868  ro.setMaterial(_mat);
869 
871 
872  // no lighting, as there are no normals anyway
873  ro.shaderDesc.shadeMode = SG_SHADE_UNLIT;
874 
875  // thick lines
876  if (_mat && _mat->lineWidth() > 1.0f)
877  ro.setupLineRendering(_mat->lineWidth(), ACG::Vec2f(_state.viewport_width(), _state.viewport_height()));
878 
879  edgesBufferManager_.setDefaultColor(_state.specular_color());
880  edgesBufferManager_.setOptionsFromDrawMode(_drawMode);
881 
882  if (_drawMode & ( drawModes_.edgesColoredPerEdge | drawModes_.halfedgesColoredPerHalfedge |
883  drawModes_.irregularInnerEdges | drawModes_.irregularOuterEdges ))
884  {
885  ro.shaderDesc.vertexColors = true;
886  }
887  else
888  {
889  ro.emissive = ACG::Vec3f(_state.specular_color()[0],_state.specular_color()[1],_state.specular_color()[2]);
890  }
891 
892  ro.vertexBuffer = edgesBufferManager_.getBuffer();
893  ro.vertexDecl = edgesBufferManager_.getVertexDeclaration();
894 
895  ro.glDrawArrays(GL_LINES, 0, edgesBufferManager_.getNumOfVertices());
896  _renderer->addRenderObject(&ro);
897 }
898 
899 template<class VolumeMeshT>
901 {
902  RenderObject ro;
903  ro.initFromState(&_state);
904 
905  ro.debugName = "VolumeMeshNodeVertices";
906 
907 
908  //Todo: use DrawModeProperties
909 
910  // reset renderobject
911  ro.depthRange = Vec2f(0.0f, 1.0f);
912  ro.depthTest = true;
913  ro.depthWrite = true;
914  ro.depthFunc = GL_LESS;
915  ro.setMaterial(_mat);
916 
918 
919  // no lighting, as there are no normals anyway
920  ro.shaderDesc.shadeMode = SG_SHADE_UNLIT;
921 
922  // draw with point size
923  if (_mat && _mat->pointSize() > 1.0f)
924  ro.setupPointRendering(_mat->pointSize(), ACG::Vec2f(_state.viewport_width(), _state.viewport_height()));
925 
926  verticesBufferManager_.setDefaultColor(_state.specular_color());
927  verticesBufferManager_.setOptionsFromDrawMode(_drawMode);
928 
929 
930  if (_drawMode & ( drawModes_.verticesColored ))
931  ro.shaderDesc.vertexColors = true;
932  else
933  ro.emissive = ACG::Vec3f(_state.specular_color()[0],_state.specular_color()[1],_state.specular_color()[2]);
934 
935  ro.vertexBuffer = verticesBufferManager_.getBuffer();
936  ro.vertexDecl = verticesBufferManager_.getVertexDeclaration();
937 
938  ro.glDrawArrays(GL_POINTS, 0, verticesBufferManager_.getNumOfVertices());
939  _renderer->addRenderObject(&ro);
940 }
941 
942 
943 
944 template<class VolumeMeshT>
946 {
947  RenderObject ro;
948  ro.initFromState(&_state);
949 
950  ro.debugName = "VolumeMeshNodeSelections";
951 
952  ro.setMaterial(_mat);
953 
954  ro.depthTest = true;
955  ro.depthFunc = GL_LEQUAL;
956 
958  ro.shaderDesc.vertexColors = false;
959  ro.shaderDesc.numLights = -1;
960  ro.shaderDesc.shadeMode = SG_SHADE_UNLIT;
961 
962  ro.diffuse = ACG::Vec3f(selection_color_[0],selection_color_[1],selection_color_[2]);
963  ro.ambient = ACG::Vec3f(selection_color_[0],selection_color_[1],selection_color_[2]);
964  ro.specular = ACG::Vec3f(selection_color_[0],selection_color_[1],selection_color_[2]);
965  ro.emissive = ACG::Vec3f(selection_color_[0],selection_color_[1],selection_color_[2]);
966 
967  if ((_drawMode & drawModes_.cellBasedDrawModes) && !(_drawMode & drawModes_.vertexBasedDrawModes))
968  vertexSelectionBufferManager_.enableVertexOnCellPrimitives();
969  else
970  vertexSelectionBufferManager_.enableVertexPrimitives();
971 
972  if ((_drawMode & (drawModes_.cellBasedDrawModes | drawModes_.edgesOnCells)) && !(_drawMode & (drawModes_.edgeBasedDrawModes & ~drawModes_.edgesOnCells)))
973  edgeSelectionBufferManager_.enableEdgeOnCellPrimitives();
974  else
975  edgeSelectionBufferManager_.enableEdgePrimitives();
976 
977  if ((_drawMode & drawModes_.cellBasedDrawModes) && !(_drawMode & (drawModes_.faceBasedDrawModes | drawModes_.halffaceBasedDrawModes)))
978  faceSelectionBufferManager_.enableFaceOnCellPrimitives();
979  else
980  faceSelectionBufferManager_.enableFacePrimitives();
981 
982  cellSelectionBufferManager_.enableCellPrimitives();
983 
984  ro.depthRange = Vec2f(0.0f,1.0f);
985 
986  ro.vertexBuffer = vertexSelectionBufferManager_.getBuffer();
987  ro.vertexDecl = vertexSelectionBufferManager_.getVertexDeclaration();
988  ro.glDrawArrays(GL_POINTS, 0, vertexSelectionBufferManager_.getNumOfVertices());
989  if (vertexSelectionBufferManager_.getNumOfVertices())
990  {
991  ro.debugName = "VolumeMeshNode.VertexSelections";
992  ro.setupPointRendering(_state.point_size(), ACG::Vec2f(_state.viewport_width(), _state.viewport_height()));
993  _renderer->addRenderObject(&ro);
994 
995  // reset shader templates
996  ro.shaderDesc.vertexTemplateFile = "";
997  ro.shaderDesc.geometryTemplateFile = "";
998  ro.shaderDesc.fragmentTemplateFile = "";
999  }
1000 
1001  ro.vertexBuffer = edgeSelectionBufferManager_.getBuffer();
1002  ro.vertexDecl = edgeSelectionBufferManager_.getVertexDeclaration();
1003  ro.glDrawArrays(GL_LINES, 0, edgeSelectionBufferManager_.getNumOfVertices());
1004  if (edgeSelectionBufferManager_.getNumOfVertices())
1005  {
1006  ro.debugName = "VolumeMeshNode.EdgeSelections";
1007 
1008  ro.setupLineRendering(_state.line_width(), ACG::Vec2f(_state.viewport_width(), _state.viewport_height()));
1009  _renderer->addRenderObject(&ro);
1010 
1011  // reset shader templates
1012  ro.shaderDesc.vertexTemplateFile = "";
1013  ro.shaderDesc.geometryTemplateFile = "";
1014  ro.shaderDesc.fragmentTemplateFile = "";
1015  }
1016 
1017  ro.depthRange = Vec2f(0.01f, 1.0f);
1018 
1019  ro.vertexBuffer = faceSelectionBufferManager_.getBuffer();
1020  ro.vertexDecl = faceSelectionBufferManager_.getVertexDeclaration();
1021  ro.glDrawArrays(GL_TRIANGLES, 0, faceSelectionBufferManager_.getNumOfVertices());
1022  if (faceSelectionBufferManager_.getNumOfVertices())
1023  {
1024  ro.debugName = "VolumeMeshNode.FaceSelections";
1025 
1026  _renderer->addRenderObject(&ro);
1027  }
1028 
1029  ro.vertexBuffer = cellSelectionBufferManager_.getBuffer();
1030  ro.vertexDecl = cellSelectionBufferManager_.getVertexDeclaration();
1031  ro.glDrawArrays(GL_TRIANGLES, 0, cellSelectionBufferManager_.getNumOfVertices());
1032  if (cellSelectionBufferManager_.getNumOfVertices())
1033  {
1034  ro.debugName = "VolumeMeshNode.CellSelections";
1035  _renderer->addRenderObject(&ro);
1036  }
1037 
1038 
1039 }
1040 
1041 template<class VolumeMeshT>
1042 void VolumeMeshNodeT<VolumeMeshT>::getRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const Material* _mat)
1043 {
1044 
1045  DrawModes::DrawMode cellDrawMode = drawModes_.getFirstCellDrawMode(_drawMode);
1046  DrawModes::DrawMode faceDrawMode = drawModes_.getFirstFaceDrawMode(_drawMode);
1047  DrawModes::DrawMode edgeDrawMode = drawModes_.getFirstEdgeDrawMode(_drawMode);
1048  DrawModes::DrawMode vertexDrawMode = drawModes_.getFirstVertexDrawMode(_drawMode);
1049 
1050  if (!face_normals_calculated_)
1051  {
1052  if ( (cellDrawMode & drawModes_.cellsFlatShaded) ||
1053  (faceDrawMode & (drawModes_.facesFlatShaded | drawModes_.halffacesFlatShaded | drawModes_.facesTexturedShaded)) )
1055  }
1056  if (!vertex_normals_calculated_)
1057  {
1058  if ( (cellDrawMode & (drawModes_.cellsSmoothShaded | drawModes_.cellsPhongShaded)) ||
1059  (faceDrawMode & (drawModes_.facesSmoothShaded | drawModes_.halffacesSmoothShaded | drawModes_.facesPhongShaded | drawModes_.halffacesPhongShaded)) )
1061  }
1062 
1063  //the VolumeMeshBufferManager can handle non atomic drawmodes if it consists of one
1064  // edge based draw mode (except edges on cells) and irregular edges
1065  edgeDrawMode |= _drawMode & (drawModes_.irregularInnerEdges | drawModes_.irregularOuterEdges);
1066 
1067  if (cellDrawMode)
1068  getCellRenderObjects(_renderer, _state, cellDrawMode, _mat);
1069  else
1070  cellsBufferManager_.free();
1071  if (faceDrawMode)
1072  getFaceRenderObjects(_renderer, _state, faceDrawMode, _mat);
1073  else
1074  facesBufferManager_.free();
1075  if (edgeDrawMode)
1076  getEdgeRenderObjects(_renderer, _state, edgeDrawMode, _mat);
1077  else
1078  edgesBufferManager_.free();
1079  if (vertexDrawMode)
1080  getVertexRenderObjects(_renderer, _state, vertexDrawMode, _mat);
1081  else
1082  verticesBufferManager_.free();
1083 
1084  getSelectionRenderObjects(_renderer, _state, cellDrawMode | faceDrawMode | edgeDrawMode | vertexDrawMode, _mat);
1085 
1086 }
1087 
1088 //----------------------------------------------------------------------------
1089 
1090 
1091 template<class VolumeMeshT>
1093 
1094  // save state
1095  bool clientStateEnabledVertexArray = GLState::isClientStateEnabled(GL_VERTEX_ARRAY);
1096  bool clientStateEnabledColorArray = GLState::isClientStateEnabled(GL_COLOR_ARRAY);
1097  bool clientStateEnabledNormalArray = GLState::isClientStateEnabled(GL_NORMAL_ARRAY);
1098  bool clientStateEnabledTexCoordArray = GLState::isClientStateEnabled(GL_TEXTURE_COORD_ARRAY);
1099 
1100  GLState::depthRange(0.01, 1.0);
1101  if (lastCellDrawMode_)
1102  {
1103  //draw cells so the user cannot pick invisible stuff
1104 
1105  GLState::bindBuffer(GL_ARRAY_BUFFER, cellsBufferManager_.getBuffer());
1106  GLState::enableClientState(GL_VERTEX_ARRAY);
1107  GLState::vertexPointer(3, GL_FLOAT, cellsBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
1108 
1109  GLState::disableClientState(GL_NORMAL_ARRAY);
1110  GLState::disableClientState(GL_COLOR_ARRAY);
1111 
1112  Vec4f bc = _state.specular_color();
1113  _state.set_color(Vec4f(0.0,0.0,0.0,0.0));
1114 
1115  glDrawArrays(GL_TRIANGLES, 0, cellsBufferManager_.getNumOfVertices());
1116 
1117  _state.set_color(bc);
1118  GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
1119  }
1120 
1121  if (lastFaceDrawMode_)
1122  {
1123  //draw faces so the user cannot pick invisible stuff
1124 
1125  GLState::bindBuffer(GL_ARRAY_BUFFER, facesBufferManager_.getBuffer());
1126  GLState::enableClientState(GL_VERTEX_ARRAY);
1127  GLState::vertexPointer(3, GL_FLOAT, facesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
1128 
1129  GLState::disableClientState(GL_NORMAL_ARRAY);
1130  GLState::disableClientState(GL_COLOR_ARRAY);
1131 
1132  Vec4f bc = _state.specular_color();
1133  _state.set_color(Vec4f(0.0,0.0,0.0,0.0));
1134 
1135  glDrawArrays(GL_TRIANGLES, 0, facesBufferManager_.getNumOfVertices());
1136 
1137  _state.set_color(bc);
1138  GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
1139  }
1140 
1141  GLenum oldDepthFunc = _state.depthFunc();
1142 
1143  GLState::depthRange(0.0, 1.0);
1144 
1145  _state.set_depthFunc(GL_LEQUAL);
1146 
1147  switch (_target) {
1148  case PICK_VERTEX: {
1149  if (lastPickTarget_ != PICK_VERTEX)
1150  vertexPickBufferManager_.invalidateColors();
1151  _state.pick_set_maximum(mesh_.n_vertices());
1152  pickVertices(_state);
1153  break;
1154  }
1155 
1156  case PICK_EDGE: {
1157  _state.pick_set_maximum(mesh_.n_edges());
1158  pickEdges(_state, 0);
1159  break;
1160  }
1161 
1162  case PICK_FACE: {
1163  _state.pick_set_maximum(mesh_.n_faces());
1164  pickFaces(_state, 0);
1165  break;
1166  }
1167 
1168  case PICK_CELL: {
1169  _state.pick_set_maximum(mesh_.n_cells());
1170  pickCells(_state, 0);
1171  break;
1172  }
1173 
1174  case PICK_ANYTHING: {
1175  if (lastPickTarget_ != PICK_ANYTHING)
1176  vertexPickBufferManager_.invalidateColors();
1177 
1178  int nv = mesh_.n_vertices();
1179  int ne = mesh_.n_edges();
1180  int nf = mesh_.n_faces();
1181  int nc = mesh_.n_cells();
1182 
1183  _state.pick_set_maximum(nv + ne + nf + nc);
1184  pickVertices(_state);
1185  pickEdges(_state, nv);
1186  pickFaces(_state, nv + ne);
1187  pickCells(_state, nv + ne + nf);
1188  break;
1189  }
1190 
1191  default:
1192  break;
1193  }
1194 
1195  _state.set_depthFunc(oldDepthFunc);
1196 
1197  lastPickTarget_ = _target;
1198 
1199  // restore state
1200  if (clientStateEnabledVertexArray)
1201  GLState::enableClientState(GL_VERTEX_ARRAY);
1202  else
1203  GLState::disableClientState(GL_VERTEX_ARRAY);
1204 
1205  if (clientStateEnabledColorArray)
1206  GLState::enableClientState(GL_COLOR_ARRAY);
1207  else
1208  GLState::disableClientState(GL_COLOR_ARRAY);
1209 
1210  if (clientStateEnabledNormalArray)
1211  GLState::enableClientState(GL_NORMAL_ARRAY);
1212  else
1213  GLState::disableClientState(GL_NORMAL_ARRAY);
1214 
1215  if (clientStateEnabledTexCoordArray)
1216  GLState::enableClientState(GL_TEXTURE_COORD_ARRAY);
1217  else
1218  GLState::disableClientState(GL_TEXTURE_COORD_ARRAY);
1219 
1220 }
1221 
1222 template<class VolumeMeshT>
1224 {
1225  cellsBufferManager_.clearCutPlanes();
1226  facesBufferManager_.clearCutPlanes();
1227  edgesBufferManager_.clearCutPlanes();
1228  verticesBufferManager_.clearCutPlanes();
1229 
1230  cellSelectionBufferManager_.clearCutPlanes();
1231  faceSelectionBufferManager_.clearCutPlanes();
1232  edgeSelectionBufferManager_.clearCutPlanes();
1233  vertexSelectionBufferManager_.clearCutPlanes();
1234 
1235  cellPickBufferManager_.clearCutPlanes();
1236  facePickBufferManager_.clearCutPlanes();
1237  edgePickBufferManager_.clearCutPlanes();
1238  vertexPickBufferManager_.clearCutPlanes();
1239 }
1240 
1241 //----------------------------------------------------------------------------
1242 
1243 
1244 
1245 template<class VolumeMeshT>
1247 
1248  if (lastDrawMode_ & drawModes_.vertexBasedDrawModes)
1249  vertexPickBufferManager_.enableVertexPrimitives();
1250  else if (lastDrawMode_ & drawModes_.cellBasedDrawModes)
1251  vertexPickBufferManager_.enableVertexOnCellPrimitives();
1252  else
1253  vertexPickBufferManager_.enableVertexPrimitives();
1254 
1255  vertexPickBufferManager_.disableNormals();
1256  vertexPickBufferManager_.enablePickColors();
1257 
1258 
1259 
1260  GLState::bindBuffer(GL_ARRAY_BUFFER, vertexPickBufferManager_.getPickBuffer(_state, 0));
1261 
1262  GLState::enableClientState(GL_VERTEX_ARRAY);
1263  GLState::vertexPointer(3, GL_FLOAT, vertexPickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
1264 
1265  GLState::enableClientState(GL_COLOR_ARRAY);
1266  GLState::colorPointer(4, GL_UNSIGNED_BYTE, vertexPickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(vertexPickBufferManager_.getColorOffset()));
1267 
1268  GLState::shadeModel(GL_SMOOTH);
1269  GLState::disable(GL_LIGHTING);
1270 
1271  float oldPointSize = _state.point_size();
1272  _state.set_point_size(1.5*_state.point_size());
1273 
1274  glDrawArrays(GL_POINTS, 0, vertexPickBufferManager_.getNumOfVertices());
1275 
1276  _state.set_point_size(oldPointSize);
1277 
1278  GLState::disableClientState(GL_COLOR_ARRAY);
1279  GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
1280 
1281 }
1282 
1283 //----------------------------------------------------------------------------
1284 
1285 
1286 template<class VolumeMeshT>
1287 void VolumeMeshNodeT<VolumeMeshT>::pickEdges(GLState& _state, unsigned int _offset) {
1288 
1289  if ((lastDrawMode_ & (drawModes_.cellBasedDrawModes | drawModes_.edgesOnCells)) && !(lastDrawMode_ & (drawModes_.edgeBasedDrawModes & ~drawModes_.edgesOnCells)))
1290  edgePickBufferManager_.enableEdgeOnCellPrimitives();
1291  else
1292  edgePickBufferManager_.enableEdgePrimitives();
1293 
1294  edgePickBufferManager_.enablePickColors();
1295  edgePickBufferManager_.disableNormals();
1296 
1297  GLState::bindBuffer(GL_ARRAY_BUFFER, edgePickBufferManager_.getPickBuffer(_state, _offset));
1298 
1299  GLState::enableClientState(GL_VERTEX_ARRAY);
1300  GLState::vertexPointer(3, GL_FLOAT, edgePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
1301 
1302  GLState::enableClientState(GL_COLOR_ARRAY);
1303  GLState::colorPointer(4, GL_UNSIGNED_BYTE, edgePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(edgePickBufferManager_.getColorOffset()));
1304 
1305  GLState::shadeModel(GL_SMOOTH);
1306  GLState::disable(GL_LIGHTING);
1307 
1308  float oldLineWidth = _state.line_width();
1309  _state.set_line_width(4.0*_state.line_width());
1310 
1311  glDrawArrays(GL_LINES, 0, edgePickBufferManager_.getNumOfVertices());
1312 
1313  _state.set_line_width(oldLineWidth);
1314 
1315  GLState::disableClientState(GL_COLOR_ARRAY);
1316  GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
1317 
1318 }
1319 
1320 //----------------------------------------------------------------------------
1321 
1322 
1323 template<class VolumeMeshT>
1324 void VolumeMeshNodeT<VolumeMeshT>::pickFaces(GLState& _state, unsigned int _offset) {
1325 
1326  if (lastDrawMode_ & (drawModes_.faceBasedDrawModes | drawModes_.halffaceBasedDrawModes))
1327  facePickBufferManager_.enableFacePrimitives();
1328  else if (lastDrawMode_ & drawModes_.cellBasedDrawModes)
1329  facePickBufferManager_.enableFaceOnCellPrimitives();
1330  else
1331  facePickBufferManager_.enableFacePrimitives();
1332 
1333  facePickBufferManager_.disableNormals();
1334  facePickBufferManager_.enablePickColors();
1335 
1336  GLState::bindBuffer(GL_ARRAY_BUFFER, facePickBufferManager_.getPickBuffer(_state, _offset));
1337 
1338  GLState::enableClientState(GL_VERTEX_ARRAY);
1339  GLState::vertexPointer(3, GL_FLOAT, facePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
1340 
1341  GLState::enableClientState(GL_COLOR_ARRAY);
1342  GLState::colorPointer(4, GL_UNSIGNED_BYTE, facePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(facePickBufferManager_.getColorOffset()));
1343 
1344  GLState::shadeModel(GL_SMOOTH);
1345  GLState::disable(GL_LIGHTING);
1346 
1347  glDrawArrays(GL_TRIANGLES, 0, facePickBufferManager_.getNumOfVertices());
1348 
1349  GLState::disableClientState(GL_COLOR_ARRAY);
1350  GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
1351 }
1352 
1353 //----------------------------------------------------------------------------
1354 
1355 
1356 template<class VolumeMeshT>
1357 void VolumeMeshNodeT<VolumeMeshT>::pickCells(GLState& _state, unsigned int _offset) {
1358 
1359  cellPickBufferManager_.enablePickColors();
1360  cellPickBufferManager_.disableNormals();
1361  cellPickBufferManager_.enableCellPrimitives();
1362 
1363  GLState::bindBuffer(GL_ARRAY_BUFFER, cellPickBufferManager_.getPickBuffer(_state, _offset));
1364 
1365  GLState::enableClientState(GL_VERTEX_ARRAY);
1366  GLState::vertexPointer(3, GL_FLOAT, cellPickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
1367 
1368  GLState::enableClientState(GL_COLOR_ARRAY);
1369  GLState::colorPointer(4, GL_UNSIGNED_BYTE, cellPickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(cellPickBufferManager_.getColorOffset()));
1370 
1371  GLState::shadeModel(GL_SMOOTH);
1372  GLState::disable(GL_LIGHTING);
1373 
1374  glDrawArrays(GL_TRIANGLES, 0, cellPickBufferManager_.getNumOfVertices());
1375 
1376  GLState::disableClientState(GL_COLOR_ARRAY);
1377  GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
1378 }
1379 
1380 //----------------------------------------------------------------------------
1381 
1382 template<class VolumeMeshT>
1384 {
1385  normalAttrib_.update_face_normals();
1386  face_normals_calculated_ = true;
1387 }
1388 
1389 //----------------------------------------------------------------------------
1390 
1391 template<class VolumeMeshT>
1393 {
1394  normalAttrib_.update_vertex_normals();
1395  vertex_normals_calculated_ = true;
1396  //update_vertex_normals will also compute face normals
1397  face_normals_calculated_ = true;
1398 }
1399 
1400 //----------------------------------------------------------------------------
1401 
1402 template<class VolumeMeshT>
1403 void VolumeMeshNodeT<VolumeMeshT>::add_cut_plane(const Vec3d& _p, const Vec3d& _n, const Vec3d& _xsize,
1404  const Vec3d& _ysize) {
1405 
1406  add_cut_plane(VolumeMeshBufferManager<VolumeMeshT>::Plane(_p, _n, _xsize, _ysize));
1407 }
1408 
1409 template<class VolumeMeshT>
1411 {
1412  scale_ = _scale;
1413  cellsBufferManager_.setScale(scale_);
1414  edgesBufferManager_.setScale(scale_);
1415  cellSelectionBufferManager_.setScale(scale_);
1416  faceSelectionBufferManager_.setScale(scale_);
1417  edgeSelectionBufferManager_.setScale(scale_);
1418  vertexSelectionBufferManager_.setScale(scale_);
1419  cellPickBufferManager_.setScale(scale_);
1420  facePickBufferManager_.setScale(scale_);
1421  edgePickBufferManager_.setScale(scale_);
1422  vertexPickBufferManager_.setScale(scale_);
1423 }
1424 
1425 template<class VolumeMeshT>
1427 {
1428  boundary_only_ = _boundary;
1429 
1430  cellsBufferManager_.setBoundaryOnly(_boundary);
1431  facesBufferManager_.setBoundaryOnly(_boundary);
1432  edgesBufferManager_.setBoundaryOnly(_boundary);
1433  verticesBufferManager_.setBoundaryOnly(_boundary);
1434 
1435  cellSelectionBufferManager_.setBoundaryOnly(_boundary);
1436  faceSelectionBufferManager_.setBoundaryOnly(_boundary);
1437  edgeSelectionBufferManager_.setBoundaryOnly(_boundary);
1438  vertexSelectionBufferManager_.setBoundaryOnly(_boundary);
1439 
1440  cellPickBufferManager_.setBoundaryOnly(_boundary);
1441  facePickBufferManager_.setBoundaryOnly(_boundary);
1442  edgePickBufferManager_.setBoundaryOnly(_boundary);
1443  vertexPickBufferManager_.setScale(_boundary);
1444 
1445 }
1446 
1447 template<class VolumeMeshT>
1448 void VolumeMeshNodeT<VolumeMeshT>::set_topology_changed(bool _topology_changed)
1449 {
1450  if (_topology_changed)
1452 }
1453 
1454 template<class VolumeMeshT>
1456 {
1457  if (_geom_changed)
1459 }
1460 
1461 template<class VolumeMeshT>
1462 void VolumeMeshNodeT<VolumeMeshT>::set_color_changed(bool _color_changed)
1463 {
1464  if (_color_changed)
1465  {
1466  cellsBufferManager_.invalidateColors();
1467  facesBufferManager_.invalidateColors();
1468  edgesBufferManager_.invalidateColors();
1469  verticesBufferManager_.invalidateColors();
1470  }
1471 
1472 }
1473 
1474 template<class VolumeMeshT>
1475 void VolumeMeshNodeT<VolumeMeshT>::set_texture_changed(bool _texture_changed)
1476 {
1477  if (_texture_changed)
1478  {
1479  cellsBufferManager_.invalidateTexCoords();
1480  facesBufferManager_.invalidateTexCoords();
1481  edgesBufferManager_.invalidateTexCoords();
1482  verticesBufferManager_.invalidateTexCoords();
1483  }
1484 
1485 }
1486 
1487 template<class VolumeMeshT>
1488 void VolumeMeshNodeT<VolumeMeshT>::set_selection_changed(bool _selection_changed)
1489 {
1490  if (_selection_changed)
1492 }
1493 
1494 //----------------------------------------------------------------------------
1495 
1496 
1497 template<class VolumeMeshT>
1499  cellsBufferManager_.addCutPlane(_p);
1500  facesBufferManager_.addCutPlane(_p);
1501  edgesBufferManager_.addCutPlane(_p);
1502  verticesBufferManager_.addCutPlane(_p);
1503 
1504  cellSelectionBufferManager_.addCutPlane(_p);
1505  faceSelectionBufferManager_.addCutPlane(_p);
1506  edgeSelectionBufferManager_.addCutPlane(_p);
1507  vertexSelectionBufferManager_.addCutPlane(_p);
1508 
1509  cellPickBufferManager_.addCutPlane(_p);
1510  facePickBufferManager_.addCutPlane(_p);
1511  edgePickBufferManager_.addCutPlane(_p);
1512  vertexPickBufferManager_.addCutPlane(_p);
1513 }
1514 
1515 
1516 //=============================================================================
1517 } // namespace SceneGraph
1518 } // namespace ACG
1519 //=============================================================================
VectorT< float, 2 > Vec2f
Definition: VectorT.hh:108
Vec3f diffuse
material definitions
static void enable(GLenum _cap)
replaces glEnable, but supports locking
Definition: GLState.cc:1490
void update_face_normals()
Compute face normals.
ACG::SceneGraph::DrawModes::DrawMode getFirstFaceDrawMode(ACG::SceneGraph::DrawModes::DrawMode _drawMode)
Returns the first face or halfface based draw mode that is present in the given draw mode...
static void enableClientState(GLenum _cap)
replaces glEnableClientState, supports locking
void clearTextures()
disables texture support and removes all texture types
void invalidateColors()
Invalidates colors.
const Vec4f & clear_color() const
get background color
Definition: GLState.hh:924
void drawCells(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the cells of the mesh
unsigned char getStride()
Returns the vertex stride.
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
void enableVertexOnCellPrimitives()
Enables vertex primitives that are drawn on the cells.
void pickFaces(GLState &_state, unsigned int _offset)
pick faces
void getFaceRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
adds render objects for drawing faces or halffaces to the given renderer
void invalidateAllBuffers()
invalidates all buffers
void set_twosided_lighting(bool _b)
set whether transparent or solid objects should be drawn
Definition: GLState.cc:818
VectorT< float, 4 > Vec4f
Definition: VectorT.hh:144
void enableEdgeOnCellPrimitives()
Enables edge primitives which are drawn on the cells.
void invalidate()
Invalidates the buffer.
void clearCutPlanes()
Removes all cut planes.
static bool isClientStateEnabled(GLenum _cap)
returns true, if a client state is enabled
Definition: GLState.cc:1584
void pickVertices(GLState &_state)
pick vertices
GLuint getBuffer()
Returns the name of the buffer.
void getVertexRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
adds render objects for drawing vertices to the given renderer
void setOptionsFromDrawMode(ACG::SceneGraph::DrawModes::DrawMode _drawMode)
Configures the buffer manager&#39;s options from a DrawMode.
ACG::SceneGraph::DrawModes::DrawMode getFirstEdgeDrawMode(ACG::SceneGraph::DrawModes::DrawMode _drawMode)
Returns the first edge or halfedge based draw mode that is present in the given draw mode...
void drawSelection(GLState &_state, const DrawModes::DrawMode &_drawMode)
draw selected primitves
void update_face_normals()
updates face normals
static void disableClientState(GLenum _cap)
replaces glDisableClientState, supports locking
Definition: GLState.cc:1555
void enableFacePrimitives()
Enables face primitives.
bool twosided_lighting()
get whether transparenet or solid objects should be drawn
Definition: GLState.hh:1043
static void enableClientState(GLenum _cap)
replaces glEnableClientState, supports locking
Definition: GLState.cc:1541
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode)
draw lines and normals
const VertexDeclaration * vertexDecl
Defines the vertex buffer layout, ignored if VAO is provided.
void invalidateAllDrawBuffers()
invalidates all buffers used for normal rendering
void pickCells(GLState &_state, unsigned int _offset)
pick cells
void getRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
Draws the object deferred.
unsigned char getColorOffset()
Returns the color&#39;s offset within the buffer.
int viewport_width() const
get viewport width
Definition: GLState.hh:825
void drawEdges(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the edges or halfedges of the mesh
const Vec4f & specular_color() const
get specular color
Definition: GLState.hh:944
void set_depthFunc(const GLenum &_depth_func)
Call glDepthFunc() to actually change the depth comparison function, and store the new value in this ...
Definition: GLState.cc:944
static void bindBuffer(GLenum _target, GLuint _buffer)
replaces glBindBuffer, supports locking
Definition: GLState.cc:1764
This class creates buffers that can be used to render open volume meshs.
GLuint getPickBuffer(ACG::GLState &_state, unsigned int _offset)
Returns the name of the pick buffer.
void enableFaceOnCellPrimitives()
Enables face primitives which are drawn on the cells.
PickTarget
What target to use for picking.
Definition: BaseNode.hh:99
void set_point_size(float _f)
set point size
Definition: GLState.cc:774
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
Definition: Vector11T.hh:562
static void enable(GLenum _cap)
replaces glEnable, but supports locking
GLenum blendDest
glBlendFunc: GL_SRC_ALPHA, GL_ZERO, GL_ONE, GL_ONE_MINUS_SRC_ALPHA ...
const GLenum & depthFunc() const
get glDepthFunc() that is supposed to be active
Definition: GLState.cc:937
VectorT< float, 3 > Vec3f
Definition: VectorT.hh:125
const Vec4f & base_color() const
get base color (used when lighting is off)
Definition: GLState.hh:929
void lineWidth(float _sz)
set line width (default: 1.0)
float point_size() const
get point size
Definition: GLState.hh:973
void drawFaces(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the faces or halffaces of the mesh
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
Definition: GLState.cc:1728
void free()
Deletes the buffers on the GPU.
unsigned char getTexCoordOffset()
Returns the texcoord&#39;s offset within the buffer.
virtual void addRenderObject(RenderObject *_renderObject)
Callback for the scenegraph nodes, which send new render objects via this function.
Definition: IRenderer.cc:108
void disableNormals()
Disables normals.
bool pick_set_maximum(unsigned int _idx)
Set the maximal number of primitives/components of your object.
Definition: GLState.cc:1047
void setupPointRendering(float _pointSize, const Vec2f &_screenSize)
Setup rendering of circle points.
unsigned char getNormalOffset()
Returns the normal&#39;s offset within the buffer.
void invalidateAllSelectionBuffers()
invalidates all buffers used for rendering selected primitives
void pickEdges(GLState &_state, unsigned int _offset)
pick edges
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
static void disable(GLenum _cap)
replaces glDisable, but supports locking
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
void enablePickColors()
Enables picking colors.
void setScale(double _scale)
Sets the scale used to shrink cells.
picks verices (may not be implemented for all nodes)
Definition: BaseNode.hh:108
ACG::SceneGraph::DrawModes::DrawMode getFirstCellDrawMode(ACG::SceneGraph::DrawModes::DrawMode _drawMode)
Returns the first cell based draw mode that is present in the given draw mode.
void setSelectionOnly(bool _selectionOnly)
Set whether only selected primitves should be added to the buffer.
void setDefaultColor(ACG::Vec4f _defaultColor)
Sets the default color.
static void colorPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glColorPointer, supports locking
Definition: GLState.cc:1906
DrawModes::DrawMode availableDrawModes() const
static name of this class
void setupLineRendering(float _lineWidth, const Vec2f &_screenSize)
Setup rendering of thick lines.
static void vertexPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glVertexPointer, supports locking
Definition: GLState.cc:1862
static void disable(GLenum _cap)
replaces glDisable, but supports locking
Definition: GLState.cc:1504
void drawVertices(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the vertices of the mesh
VolumeMeshNodeT(const VolumeMesh &_mesh, OpenVolumeMesh::StatusAttrib &_statusAttrib, OpenVolumeMesh::ColorAttrib< Vec4f > &_colorAttrib, OpenVolumeMesh::NormalAttrib< VolumeMesh > &_normalAttrib, OpenVolumeMesh::TexCoordAttrib< Vec2f > &_texcoordAttrib, const MaterialNode *_matNode, BaseNode *_parent=0, std::string _name="<VolumeMeshNode>")
Constructor.
void enableEdgePrimitives()
Enables edge primitves.
void pick(GLState &_state, PickTarget _target)
picking
static void cullFace(GLenum _mode)
replaces glCullFace, supports locking
picks edges (may not be implemented for all nodes)
Definition: BaseNode.hh:106
static void cullFace(GLenum _mode)
replaces glCullFace, supports locking
Definition: GLState.cc:1714
GLenum depthFunc
GL_LESS, GL_LEQUAL, GL_GREATER ..
void getEdgeRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
adds render objects for drawing edges or halfedges to the given renderer
void invalidateTexCoords()
Invalidates texture coordinates.
void addCutPlane(const typename VolumeMeshBufferManager< VolumeMesh >::Plane &_p)
Adds a cut plane.
void initFromState(GLState *_glState)
Initializes a RenderObject instance.
Definition: RenderObject.cc:69
picks faces (may not be implemented for all nodes)
Definition: BaseNode.hh:102
static void texcoordPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glTexcoordPointer, supports locking
void getCellRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
adds render objects for drawing cells to the given renderer
static void useProgram(GLuint _program)
replaces glUseProgram, supports locking
A data structure basing on PolyhedralMesh with specializations for hexahedra.
pick any of the prior targets (should be implemented for all nodes)
Definition: BaseNode.hh:110
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
Definition: Vector11T.hh:534
int viewport_height() const
get viewport height
Definition: GLState.hh:827
const ACG::VertexDeclaration * getVertexDeclaration()
Returns a VertexDeclaration for the vertices stored in the buffer.
void update_vertex_normals()
updates vertex normals
float line_width() const
get line width
Definition: GLState.hh:978
void set_color(const Vec4f &_col)
set color
Definition: GLState.cc:689
void setBoundaryOnly(bool _boundaryOnly)
Sets whether only the boundary primitves should be rendered.
Interface class between scenegraph and renderer.
void set_line_width(float _f)
set line width
Definition: GLState.cc:789
void pointSize(float _sz)
set point size (default: 1.0)
void enableVertexPrimitives()
Enables vertex primitives.
void invalidateAllPickingBuffers()
invalidates all buffers used for picking
unsigned int getNumOfVertices()
Returns the number of vertices stored in the buffer.
ACG::SceneGraph::DrawModes::DrawMode getFirstVertexDrawMode(ACG::SceneGraph::DrawModes::DrawMode _drawMode)
Returns the first vertex based draw mode that is present in the given draw mode.
void enableCellPrimitives()
Enables cell primitives.
picks faces (should be implemented for all nodes)
Definition: BaseNode.hh:104
const Vec4f & color()
set color
Definition: GLState.hh:919
GLuint vertexBuffer
VBO, IBO ids, ignored if VAO is provided.
void getSelectionRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
adds render objects for drawing selected primitves to the given renderer
ShaderGenDesc shaderDesc
Drawmode and other shader params.
void update_vertex_normals()
A simple heuristic to estimate the vertex normals.
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
static void normalPointer(GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glNormalPointer, supports locking
Definition: GLState.cc:1884
Vec2f depthRange
glDepthRange: (znear, zmax)
static void blendFunc(GLenum _sfactor, GLenum _dfactor)
replaces glBlendFunc, supports locking
Definition: GLState.hh:314
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
Definition: GLState.cc:1700