50 #define VOLUMEMESHNODET_CC
54 #include "VolumeMeshNode.hh"
56 #include <ACG/GL/gl.hh>
57 #include <ACG/Utils/VSToolsT.hh>
60 #include <ACG/GL/RenderObject.hh>
61 #include <ACG/GL/VertexDeclaration.hh>
62 #include <ACG/GL/IRenderer.hh>
64 #include <OpenVolumeMesh/Mesh/HexahedralMesh.hh>
72 namespace SceneGraph {
77 template<
class VolumeMeshT>
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),
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),
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),
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),
113 lastDrawMode_ (DrawModes::NONE),
114 lastCellDrawMode_ (DrawModes::NONE),
115 lastFaceDrawMode_ (DrawModes::NONE),
116 lastEdgeDrawMode_ (DrawModes::NONE),
117 lastVertexDrawMode_(DrawModes::NONE),
119 face_normals_calculated_(false),
120 vertex_normals_calculated_(false)
131 template<
class VolumeMeshT>
138 template<
class VolumeMeshT>
141 int n_vertices(mesh_.n_vertices());
142 for (
int i = 0; i < n_vertices; ++i) {
152 template<
class VolumeMeshT>
156 if (mesh_.n_cells() > 0)
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;
172 if (mesh_.n_faces() > 0)
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;
187 if (mesh_.n_halffaces() > 0)
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;
198 if (mesh_.n_edges() > 0)
200 result |= drawModes_.edgesWireframe;
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;
209 if (dynamic_cast<const HexahedralMeshTopologyKernel*>(&mesh_) != NULL)
211 result |= drawModes_.irregularInnerEdges;
212 result |= drawModes_.irregularOuterEdges;
216 if (mesh_.n_halfedges() > 0)
218 result |= drawModes_.halfedgesWireframe;
220 if (mesh_.n_faces() > 0)
221 result |= drawModes_.halfedgesHiddenLine;
222 if (colorAttrib_.halfedge_colors_available())
223 result |= drawModes_.halfedgesColoredPerHalfedge;
226 if (mesh_.n_vertices() > 0)
228 result |= drawModes_.verticesFlatShaded;
230 if (colorAttrib_.vertex_colors_available())
231 result |= drawModes_.verticesColored;
242 template<
class VolumeMeshT>
248 cellsBufferManager_.setOptionsFromDrawMode(_drawMode);
254 GLState::normalPointer(GL_FLOAT, cellsBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(cellsBufferManager_.getNormalOffset()));
256 if (_drawMode & (drawModes_.cellsColoredPerCell | drawModes_.cellsColoredPerFace | drawModes_.cellsColoredPerHalfface | drawModes_.cellsColoredPerVertex))
260 GLState::colorPointer(4, GL_UNSIGNED_BYTE, cellsBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(cellsBufferManager_.getColorOffset()));
267 else if (_drawMode & drawModes_.cellsSmoothShaded)
273 else if (_drawMode & drawModes_.cellsFlatShaded)
279 else if (_drawMode & drawModes_.cellsTransparent)
291 glDrawArrays(GL_TRIANGLES, 0, cellsBufferManager_.getNumOfVertices());
293 if (_drawMode & drawModes_.cellsTransparent)
305 template<
class VolumeMeshT>
314 if ((_drawMode & drawModes_.faceBasedDrawModes) || boundary_only_)
326 facesBufferManager_.setOptionsFromDrawMode(_drawMode);
331 if (_drawMode & (drawModes_.hiddenLineBackgroundFaces))
339 else if (_drawMode & (drawModes_.facesColoredPerFace | drawModes_.facesColoredPerVertex
340 | drawModes_.halffacesColoredPerHalfface | drawModes_.halffacesColoredPerVertex ))
343 GLState::colorPointer(4, GL_UNSIGNED_BYTE, facesBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(facesBufferManager_.getColorOffset()));
348 else if (_drawMode & (drawModes_.facesTexturedShaded) )
350 glClientActiveTexture(GL_TEXTURE0);
351 ACG::GLState::texcoordPointer(2, GL_FLOAT, facesBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(facesBufferManager_.getTexCoordOffset()));
358 GLState::normalPointer(GL_FLOAT, facesBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(facesBufferManager_.getNormalOffset()));
360 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
363 else if (_drawMode & (drawModes_.facesTextured) )
365 glClientActiveTexture(GL_TEXTURE0);
366 ACG::GLState::texcoordPointer(2, GL_FLOAT, facesBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(facesBufferManager_.getTexCoordOffset()));
375 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
383 GLState::normalPointer(GL_FLOAT, facesBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(facesBufferManager_.getNormalOffset()));
388 glDrawArrays(GL_TRIANGLES, 0, facesBufferManager_.getNumOfVertices());
394 if (_drawMode & (drawModes_.edgesHiddenLine | drawModes_.halfedgesHiddenLine))
400 template<
class VolumeMeshT>
406 edgesBufferManager_.setOptionsFromDrawMode(_drawMode);
412 if (_drawMode & ( drawModes_.edgesColoredPerEdge | drawModes_.halfedgesColoredPerHalfedge |
413 drawModes_.irregularInnerEdges | drawModes_.irregularOuterEdges ))
416 GLState::colorPointer(4, GL_UNSIGNED_BYTE, edgesBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(edgesBufferManager_.getColorOffset()));
434 glDrawArrays(GL_LINES, 0, edgesBufferManager_.getNumOfVertices());
443 template<
class VolumeMeshT>
446 verticesBufferManager_.setOptionsFromDrawMode(_drawMode);
453 if (_drawMode & ( drawModes_.verticesColored ))
456 GLState::colorPointer(4, GL_UNSIGNED_BYTE, verticesBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(verticesBufferManager_.getColorOffset()));
471 glDrawArrays(GL_POINTS, 0, verticesBufferManager_.getNumOfVertices());
479 template<
class VolumeMeshT>
484 GLint currentProgramm;
485 glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgramm);
495 glDisable(GL_CULL_FACE);
503 if ((_drawMode & drawModes_.cellBasedDrawModes) && !(_drawMode & drawModes_.vertexBasedDrawModes))
504 vertexSelectionBufferManager_.enableVertexOnCellPrimitives();
506 vertexSelectionBufferManager_.enableVertexPrimitives();
508 if ((_drawMode & (drawModes_.cellBasedDrawModes | drawModes_.edgesOnCells)) && !(_drawMode & (drawModes_.edgeBasedDrawModes & ~drawModes_.edgesOnCells)))
509 edgeSelectionBufferManager_.enableEdgeOnCellPrimitives();
511 edgeSelectionBufferManager_.enableEdgePrimitives();
513 if ((_drawMode & drawModes_.cellBasedDrawModes) && !(_drawMode & (drawModes_.faceBasedDrawModes | drawModes_.halffaceBasedDrawModes)))
514 faceSelectionBufferManager_.enableFaceOnCellPrimitives();
516 faceSelectionBufferManager_.enableFacePrimitives();
518 cellSelectionBufferManager_.enableCellPrimitives();
526 glDrawArrays(GL_POINTS, 0, vertexSelectionBufferManager_.getNumOfVertices());
530 glDrawArrays(GL_LINES, 0, edgeSelectionBufferManager_.getNumOfVertices());
536 glDrawArrays(GL_TRIANGLES, 0, faceSelectionBufferManager_.getNumOfVertices());
540 glDrawArrays(GL_TRIANGLES, 0, cellSelectionBufferManager_.getNumOfVertices());
555 template<
class VolumeMeshT>
558 invalidateAllDrawBuffers();
559 invalidateAllPickingBuffers();
560 invalidateAllSelectionBuffers();
563 template<
class VolumeMeshT>
566 cellsBufferManager_.invalidate();
567 facesBufferManager_.invalidate();
568 edgesBufferManager_.invalidate();
569 verticesBufferManager_.invalidate();
572 template<
class VolumeMeshT>
575 cellPickBufferManager_.invalidate();
576 facePickBufferManager_.invalidate();
577 edgePickBufferManager_.invalidate();
578 vertexPickBufferManager_.invalidate();
581 template<
class VolumeMeshT>
584 cellSelectionBufferManager_.invalidate();
585 faceSelectionBufferManager_.invalidate();
586 edgeSelectionBufferManager_.invalidate();
587 vertexSelectionBufferManager_.invalidate();
590 template<
class VolumeMeshT>
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);
603 GLboolean cullFace =
false;
604 glGetBooleanv(GL_CULL_FACE, &cullFace);
606 glGetIntegerv(GL_CULL_FACE_MODE, &cullFaceMode);
608 glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &texmode);
610 glGetBooleanv(GL_TEXTURE_2D, &texturing);
627 if (!face_normals_calculated_)
629 if ( (cellDrawMode & drawModes_.cellsFlatShaded) ||
630 (faceDrawMode & (drawModes_.facesFlatShaded | drawModes_.halffacesFlatShaded | drawModes_.facesTexturedShaded)) )
631 update_face_normals();
633 if (!vertex_normals_calculated_)
635 if ( (cellDrawMode & (drawModes_.cellsSmoothShaded | drawModes_.cellsPhongShaded)) ||
636 (faceDrawMode & (drawModes_.facesSmoothShaded | drawModes_.halffacesSmoothShaded | drawModes_.facesPhongShaded | drawModes_.halffacesPhongShaded)) )
637 update_vertex_normals();
642 edgeDrawMode |= _drawMode & (drawModes_.irregularInnerEdges | drawModes_.irregularOuterEdges);
646 drawCells(_state, cellDrawMode);
648 cellsBufferManager_.free();
650 drawFaces(_state, faceDrawMode);
652 facesBufferManager_.free();
654 drawEdges(_state, edgeDrawMode);
656 edgesBufferManager_.free();
658 drawVertices(_state, vertexDrawMode);
660 verticesBufferManager_.free();
662 drawSelection(_state, cellDrawMode | faceDrawMode | edgeDrawMode | vertexDrawMode);
665 lastDrawMode_ = cellDrawMode | faceDrawMode | edgeDrawMode | vertexDrawMode;
666 lastCellDrawMode_ = cellDrawMode;
667 lastFaceDrawMode_ = faceDrawMode;
668 lastEdgeDrawMode_ = edgeDrawMode;
669 lastVertexDrawMode_ = vertexDrawMode;
698 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, texmode);
703 if (clientStateEnabledVertexArray)
708 if (clientStateEnabledColorArray)
713 if (clientStateEnabledNormalArray)
718 if (clientStateEnabledTexCoordArray)
727 template<
class VolumeMeshT>
733 ro.debugName =
"VolumeMeshNodeCells";
739 ro.depthWrite =
true;
741 ro.setMaterial(_mat);
749 if (_drawMode & (drawModes_.cellsColoredPerCell | drawModes_.cellsColoredPerFace | drawModes_.cellsColoredPerHalfface | drawModes_.cellsColoredPerVertex))
756 else if (_drawMode & drawModes_.cellsSmoothShaded)
761 else if (_drawMode & drawModes_.cellsFlatShaded)
766 else if (_drawMode & drawModes_.cellsTransparent)
770 ro.depthTest =
false;
777 ro.alpha = translucency_factor_;
780 ro.blendSrc = GL_SRC_ALPHA;
783 cellsBufferManager_.setOptionsFromDrawMode(_drawMode);
785 ro.
vertexDecl = cellsBufferManager_.getVertexDeclaration();
787 ro.glDrawArrays(GL_TRIANGLES, 0, cellsBufferManager_.getNumOfVertices());
791 template<
class VolumeMeshT>
797 ro.debugName =
"VolumeMeshNodeFaces";
803 ro.depthWrite =
true;
805 ro.setMaterial(_mat);
813 facesBufferManager_.setOptionsFromDrawMode(_drawMode);
816 if ((_drawMode & drawModes_.faceBasedDrawModes) || boundary_only_)
821 if (_drawMode & (drawModes_.hiddenLineBackgroundFaces))
833 else if (_drawMode & (drawModes_.facesColoredPerFace | drawModes_.facesColoredPerVertex
834 | drawModes_.halffacesColoredPerHalfface | drawModes_.halffacesColoredPerVertex ))
847 ro.
vertexDecl = facesBufferManager_.getVertexDeclaration();
849 ro.glDrawArrays(GL_TRIANGLES, 0, facesBufferManager_.getNumOfVertices());
853 template<
class VolumeMeshT>
859 ro.debugName =
"VolumeMeshNodeEdges";
866 ro.depthWrite =
true;
868 ro.setMaterial(_mat);
880 edgesBufferManager_.setOptionsFromDrawMode(_drawMode);
882 if (_drawMode & ( drawModes_.edgesColoredPerEdge | drawModes_.halfedgesColoredPerHalfedge |
883 drawModes_.irregularInnerEdges | drawModes_.irregularOuterEdges ))
893 ro.
vertexDecl = edgesBufferManager_.getVertexDeclaration();
895 ro.glDrawArrays(GL_LINES, 0, edgesBufferManager_.getNumOfVertices());
899 template<
class VolumeMeshT>
905 ro.debugName =
"VolumeMeshNodeVertices";
913 ro.depthWrite =
true;
915 ro.setMaterial(_mat);
927 verticesBufferManager_.setOptionsFromDrawMode(_drawMode);
930 if (_drawMode & ( drawModes_.verticesColored ))
936 ro.
vertexDecl = verticesBufferManager_.getVertexDeclaration();
938 ro.glDrawArrays(GL_POINTS, 0, verticesBufferManager_.getNumOfVertices());
944 template<
class VolumeMeshT>
950 ro.debugName =
"VolumeMeshNodeSelections";
952 ro.setMaterial(_mat);
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]);
967 if ((_drawMode & drawModes_.cellBasedDrawModes) && !(_drawMode & drawModes_.vertexBasedDrawModes))
968 vertexSelectionBufferManager_.enableVertexOnCellPrimitives();
970 vertexSelectionBufferManager_.enableVertexPrimitives();
972 if ((_drawMode & (drawModes_.cellBasedDrawModes | drawModes_.edgesOnCells)) && !(_drawMode & (drawModes_.edgeBasedDrawModes & ~drawModes_.edgesOnCells)))
973 edgeSelectionBufferManager_.enableEdgeOnCellPrimitives();
975 edgeSelectionBufferManager_.enableEdgePrimitives();
977 if ((_drawMode & drawModes_.cellBasedDrawModes) && !(_drawMode & (drawModes_.faceBasedDrawModes | drawModes_.halffaceBasedDrawModes)))
978 faceSelectionBufferManager_.enableFaceOnCellPrimitives();
980 faceSelectionBufferManager_.enableFacePrimitives();
982 cellSelectionBufferManager_.enableCellPrimitives();
986 ro.
vertexBuffer = vertexSelectionBufferManager_.getBuffer();
987 ro.
vertexDecl = vertexSelectionBufferManager_.getVertexDeclaration();
988 ro.glDrawArrays(GL_POINTS, 0, vertexSelectionBufferManager_.getNumOfVertices());
989 if (vertexSelectionBufferManager_.getNumOfVertices())
991 ro.debugName =
"VolumeMeshNode.VertexSelections";
1001 ro.
vertexBuffer = edgeSelectionBufferManager_.getBuffer();
1002 ro.
vertexDecl = edgeSelectionBufferManager_.getVertexDeclaration();
1003 ro.glDrawArrays(GL_LINES, 0, edgeSelectionBufferManager_.getNumOfVertices());
1004 if (edgeSelectionBufferManager_.getNumOfVertices())
1006 ro.debugName =
"VolumeMeshNode.EdgeSelections";
1019 ro.
vertexBuffer = faceSelectionBufferManager_.getBuffer();
1020 ro.
vertexDecl = faceSelectionBufferManager_.getVertexDeclaration();
1021 ro.glDrawArrays(GL_TRIANGLES, 0, faceSelectionBufferManager_.getNumOfVertices());
1022 if (faceSelectionBufferManager_.getNumOfVertices())
1024 ro.debugName =
"VolumeMeshNode.FaceSelections";
1029 ro.
vertexBuffer = cellSelectionBufferManager_.getBuffer();
1030 ro.
vertexDecl = cellSelectionBufferManager_.getVertexDeclaration();
1031 ro.glDrawArrays(GL_TRIANGLES, 0, cellSelectionBufferManager_.getNumOfVertices());
1032 if (cellSelectionBufferManager_.getNumOfVertices())
1034 ro.debugName =
"VolumeMeshNode.CellSelections";
1041 template<
class VolumeMeshT>
1050 if (!face_normals_calculated_)
1052 if ( (cellDrawMode & drawModes_.cellsFlatShaded) ||
1053 (faceDrawMode & (drawModes_.facesFlatShaded | drawModes_.halffacesFlatShaded | drawModes_.facesTexturedShaded)) )
1054 update_face_normals();
1056 if (!vertex_normals_calculated_)
1058 if ( (cellDrawMode & (drawModes_.cellsSmoothShaded | drawModes_.cellsPhongShaded)) ||
1059 (faceDrawMode & (drawModes_.facesSmoothShaded | drawModes_.halffacesSmoothShaded | drawModes_.facesPhongShaded | drawModes_.halffacesPhongShaded)) )
1060 update_vertex_normals();
1065 edgeDrawMode |= _drawMode & (drawModes_.irregularInnerEdges | drawModes_.irregularOuterEdges);
1068 getCellRenderObjects(_renderer, _state, cellDrawMode, _mat);
1070 cellsBufferManager_.free();
1072 getFaceRenderObjects(_renderer, _state, faceDrawMode, _mat);
1074 facesBufferManager_.free();
1076 getEdgeRenderObjects(_renderer, _state, edgeDrawMode, _mat);
1078 edgesBufferManager_.free();
1080 getVertexRenderObjects(_renderer, _state, vertexDrawMode, _mat);
1082 verticesBufferManager_.free();
1084 getSelectionRenderObjects(_renderer, _state, cellDrawMode | faceDrawMode | edgeDrawMode | vertexDrawMode, _mat);
1091 template<
class VolumeMeshT>
1101 if (lastCellDrawMode_)
1115 glDrawArrays(GL_TRIANGLES, 0, cellsBufferManager_.getNumOfVertices());
1121 if (lastFaceDrawMode_)
1135 glDrawArrays(GL_TRIANGLES, 0, facesBufferManager_.getNumOfVertices());
1141 GLenum oldDepthFunc = _state.
depthFunc();
1150 vertexPickBufferManager_.invalidateColors();
1152 pickVertices(_state);
1158 pickEdges(_state, 0);
1164 pickFaces(_state, 0);
1170 pickCells(_state, 0);
1176 vertexPickBufferManager_.invalidateColors();
1178 int nv = mesh_.n_vertices();
1179 int ne = mesh_.n_edges();
1180 int nf = mesh_.n_faces();
1181 int nc = mesh_.n_cells();
1184 pickVertices(_state);
1185 pickEdges(_state, nv);
1186 pickFaces(_state, nv + ne);
1187 pickCells(_state, nv + ne + nf);
1197 lastPickTarget_ = _target;
1200 if (clientStateEnabledVertexArray)
1205 if (clientStateEnabledColorArray)
1210 if (clientStateEnabledNormalArray)
1215 if (clientStateEnabledTexCoordArray)
1222 template<
class VolumeMeshT>
1225 cellsBufferManager_.clearCutPlanes();
1226 facesBufferManager_.clearCutPlanes();
1227 edgesBufferManager_.clearCutPlanes();
1228 verticesBufferManager_.clearCutPlanes();
1230 cellSelectionBufferManager_.clearCutPlanes();
1231 faceSelectionBufferManager_.clearCutPlanes();
1232 edgeSelectionBufferManager_.clearCutPlanes();
1233 vertexSelectionBufferManager_.clearCutPlanes();
1235 cellPickBufferManager_.clearCutPlanes();
1236 facePickBufferManager_.clearCutPlanes();
1237 edgePickBufferManager_.clearCutPlanes();
1238 vertexPickBufferManager_.clearCutPlanes();
1245 template<
class VolumeMeshT>
1248 if (lastDrawMode_ & drawModes_.vertexBasedDrawModes)
1249 vertexPickBufferManager_.enableVertexPrimitives();
1250 else if (lastDrawMode_ & drawModes_.cellBasedDrawModes)
1251 vertexPickBufferManager_.enableVertexOnCellPrimitives();
1253 vertexPickBufferManager_.enableVertexPrimitives();
1255 vertexPickBufferManager_.disableNormals();
1256 vertexPickBufferManager_.enablePickColors();
1266 GLState::colorPointer(4, GL_UNSIGNED_BYTE, vertexPickBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(vertexPickBufferManager_.getColorOffset()));
1274 glDrawArrays(GL_POINTS, 0, vertexPickBufferManager_.getNumOfVertices());
1286 template<
class VolumeMeshT>
1289 if ((lastDrawMode_ & (drawModes_.cellBasedDrawModes | drawModes_.edgesOnCells)) && !(lastDrawMode_ & (drawModes_.edgeBasedDrawModes & ~drawModes_.edgesOnCells)))
1290 edgePickBufferManager_.enableEdgeOnCellPrimitives();
1292 edgePickBufferManager_.enableEdgePrimitives();
1294 edgePickBufferManager_.enablePickColors();
1295 edgePickBufferManager_.disableNormals();
1297 GLState::bindBuffer(GL_ARRAY_BUFFER, edgePickBufferManager_.getPickBuffer(_state, _offset));
1303 GLState::colorPointer(4, GL_UNSIGNED_BYTE, edgePickBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(edgePickBufferManager_.getColorOffset()));
1311 glDrawArrays(GL_LINES, 0, edgePickBufferManager_.getNumOfVertices());
1323 template<
class VolumeMeshT>
1326 if (lastDrawMode_ & (drawModes_.faceBasedDrawModes | drawModes_.halffaceBasedDrawModes))
1327 facePickBufferManager_.enableFacePrimitives();
1328 else if (lastDrawMode_ & drawModes_.cellBasedDrawModes)
1329 facePickBufferManager_.enableFaceOnCellPrimitives();
1331 facePickBufferManager_.enableFacePrimitives();
1333 facePickBufferManager_.disableNormals();
1334 facePickBufferManager_.enablePickColors();
1336 GLState::bindBuffer(GL_ARRAY_BUFFER, facePickBufferManager_.getPickBuffer(_state, _offset));
1342 GLState::colorPointer(4, GL_UNSIGNED_BYTE, facePickBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(facePickBufferManager_.getColorOffset()));
1347 glDrawArrays(GL_TRIANGLES, 0, facePickBufferManager_.getNumOfVertices());
1356 template<
class VolumeMeshT>
1359 cellPickBufferManager_.enablePickColors();
1360 cellPickBufferManager_.disableNormals();
1361 cellPickBufferManager_.enableCellPrimitives();
1363 GLState::bindBuffer(GL_ARRAY_BUFFER, cellPickBufferManager_.getPickBuffer(_state, _offset));
1369 GLState::colorPointer(4, GL_UNSIGNED_BYTE, cellPickBufferManager_.getStride(),
reinterpret_cast<GLvoid*
>(cellPickBufferManager_.getColorOffset()));
1374 glDrawArrays(GL_TRIANGLES, 0, cellPickBufferManager_.getNumOfVertices());
1382 template<
class VolumeMeshT>
1385 normalAttrib_.update_face_normals();
1386 face_normals_calculated_ =
true;
1391 template<
class VolumeMeshT>
1394 normalAttrib_.update_vertex_normals();
1395 vertex_normals_calculated_ =
true;
1397 face_normals_calculated_ =
true;
1402 template<
class VolumeMeshT>
1404 const Vec3d& _ysize) {
1409 template<
class VolumeMeshT>
1410 void VolumeMeshNodeT<VolumeMeshT>::set_scaling(
double _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_);
1425 template<
class VolumeMeshT>
1426 void VolumeMeshNodeT<VolumeMeshT>::set_boundary_only(
bool _boundary)
1428 boundary_only_ = _boundary;
1430 cellsBufferManager_.setBoundaryOnly(_boundary);
1431 facesBufferManager_.setBoundaryOnly(_boundary);
1432 edgesBufferManager_.setBoundaryOnly(_boundary);
1433 verticesBufferManager_.setBoundaryOnly(_boundary);
1435 cellSelectionBufferManager_.setBoundaryOnly(_boundary);
1436 faceSelectionBufferManager_.setBoundaryOnly(_boundary);
1437 edgeSelectionBufferManager_.setBoundaryOnly(_boundary);
1438 vertexSelectionBufferManager_.setBoundaryOnly(_boundary);
1440 cellPickBufferManager_.setBoundaryOnly(_boundary);
1441 facePickBufferManager_.setBoundaryOnly(_boundary);
1442 edgePickBufferManager_.setBoundaryOnly(_boundary);
1443 vertexPickBufferManager_.setScale(_boundary);
1447 template<
class VolumeMeshT>
1448 void VolumeMeshNodeT<VolumeMeshT>::set_topology_changed(
bool _topology_changed)
1450 if (_topology_changed)
1451 invalidateAllBuffers();
1454 template<
class VolumeMeshT>
1455 void VolumeMeshNodeT<VolumeMeshT>::set_geometry_changed(
bool _geom_changed)
1458 invalidateAllBuffers();
1461 template<
class VolumeMeshT>
1462 void VolumeMeshNodeT<VolumeMeshT>::set_color_changed(
bool _color_changed)
1466 cellsBufferManager_.invalidateColors();
1467 facesBufferManager_.invalidateColors();
1468 edgesBufferManager_.invalidateColors();
1469 verticesBufferManager_.invalidateColors();
1474 template<
class VolumeMeshT>
1475 void VolumeMeshNodeT<VolumeMeshT>::set_texture_changed(
bool _texture_changed)
1477 if (_texture_changed)
1479 cellsBufferManager_.invalidateTexCoords();
1480 facesBufferManager_.invalidateTexCoords();
1481 edgesBufferManager_.invalidateTexCoords();
1482 verticesBufferManager_.invalidateTexCoords();
1487 template<
class VolumeMeshT>
1488 void VolumeMeshNodeT<VolumeMeshT>::set_selection_changed(
bool _selection_changed)
1490 if (_selection_changed)
1491 invalidateAllSelectionBuffers();
1497 template<
class VolumeMeshT>
1498 void VolumeMeshNodeT<VolumeMeshT>::add_cut_plane(
const Plane& _p) {
1499 cellsBufferManager_.addCutPlane(_p);
1500 facesBufferManager_.addCutPlane(_p);
1501 edgesBufferManager_.addCutPlane(_p);
1502 verticesBufferManager_.addCutPlane(_p);
1504 cellSelectionBufferManager_.addCutPlane(_p);
1505 faceSelectionBufferManager_.addCutPlane(_p);
1506 edgeSelectionBufferManager_.addCutPlane(_p);
1507 vertexSelectionBufferManager_.addCutPlane(_p);
1509 cellPickBufferManager_.addCutPlane(_p);
1510 facePickBufferManager_.addCutPlane(_p);
1511 edgePickBufferManager_.addCutPlane(_p);
1512 vertexPickBufferManager_.addCutPlane(_p);
VectorT< float, 2 > Vec2f
ShaderGenDesc shaderDesc
Drawmode and other shader params.
Vec2f depthRange
glDepthRange: (znear, zmax)
static void enable(GLenum _cap)
replaces glEnable, but supports locking
Namespace providing different geometric functions concerning angles.
static void enable(GLenum _cap)
replaces glEnable, but supports locking
void invalidateAllDrawBuffers()
invalidates all buffers used for normal rendering
static void bindBuffer(GLenum _target, GLuint _buffer)
replaces glBindBuffer, supports locking
PickTarget
What target to use for picking.
void invalidateAllPickingBuffers()
invalidates all buffers used for picking
const Vec4f & clear_color() const
get background color
static void disable(GLenum _cap)
replaces glDisable, but supports locking
bool pick_set_maximum(unsigned int _idx)
Set the maximal number of primitives/components of your object.
void pickEdges(GLState &_state, unsigned int _offset)
pick edges
picks faces (should be implemented for all nodes)
pick any of the prior targets (should be implemented for all nodes)
Interface class between scenegraph and renderer.
~VolumeMeshNodeT()
Destructor.
void update_face_normals()
updates face normals
GLenum blendDest
glBlendFunc: GL_SRC_ALPHA, GL_ZERO, GL_ONE, GL_ONE_MINUS_SRC_ALPHA ...
void setupPointRendering(float _pointSize, const Vec2f &_screenSize)
Setup rendering of circle points.
void set_depthFunc(const GLenum &_depth_func)
Call glDepthFunc() to actually change the depth comparison function, and store the new value in this ...
static void colorPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glColorPointer, supports locking
GLuint vertexBuffer
VBO, IBO ids, ignored if VAO is provided.
void drawEdges(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the edges or halfedges of the mesh
void drawSelection(GLState &_state, const DrawModes::DrawMode &_drawMode)
draw selected primitves
GLenum depthFunc
GL_LESS, GL_LEQUAL, GL_GREATER ..
void initFromState(GLState *_glState)
Initializes a RenderObject instance.
VectorT< float, 4 > Vec4f
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
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 boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
void getVertexRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
adds render objects for drawing vertices to the given renderer
This class creates buffers that can be used to render open volume meshs.
DrawModes::DrawMode availableDrawModes() const
static name of this class
picks verices (may not be implemented for all nodes)
void drawCells(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the cells of the mesh
static void enableClientState(GLenum _cap)
replaces glEnableClientState, supports locking
picks edges (may not be implemented for all nodes)
const VertexDeclaration * vertexDecl
Defines the vertex buffer layout, ignored if VAO is provided.
const Vec4f & color()
set color
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
int viewport_width() const
get viewport width
void invalidateAllBuffers()
invalidates all buffers
static void blendFunc(GLenum _sfactor, GLenum _dfactor)
replaces glBlendFunc, supports locking
const Vec4f & specular_color() const
get specular color
void set_twosided_lighting(bool _b)
set whether transparent or solid objects should be drawn
void set_color(const Vec4f &_col)
set color
Vec3f diffuse
material definitions
float line_width() const
get line width
VectorT< float, 3 > Vec3f
void lineWidth(float _sz)
set line width (default: 1.0)
static bool isClientStateEnabled(GLenum _cap)
returns true, if a client state is enabled
float point_size() const
get point size
static void normalPointer(GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glNormalPointer, supports locking
void clearTextures()
disables texture support and removes all texture types
virtual void addRenderObject(RenderObject *_renderObject)
Callback for the scenegraph nodes, which send new render objects via this function.
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 update_vertex_normals()
updates vertex normals
void setSelectionOnly(bool _selectionOnly)
Set whether only selected primitves should be added to the buffer.
static void disableClientState(GLenum _cap)
replaces glDisableClientState, supports locking
picks faces (may not be implemented for all nodes)
void set_line_width(float _f)
set line width
static void vertexPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glVertexPointer, supports locking
A data structure basing on PolyhedralMesh with specializations for hexahedra.
static void disable(GLenum _cap)
replaces glDisable, but supports locking
bool twosided_lighting()
get whether transparenet or solid objects should be drawn
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
static void cullFace(GLenum _mode)
replaces glCullFace, supports locking
static void texcoordPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glTexcoordPointer, supports locking
void getRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
Draws the object deferred.
static void enableClientState(GLenum _cap)
replaces glEnableClientState, supports locking
const GLenum & depthFunc() const
get glDepthFunc() that is supposed to be active
static void useProgram(GLuint _program)
replaces glUseProgram, supports locking
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
void set_point_size(float _f)
set point size
void drawVertices(GLState &_state, const DrawModes::DrawMode &_drawMode)
renders the vertices of the mesh
void pick(GLState &_state, PickTarget _target)
picking
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode)
draw lines and normals
const Vec4f & base_color() const
get base color (used when lighting is off)
void pickVertices(GLState &_state)
pick vertices
int viewport_height() const
get viewport height
void pickFaces(GLState &_state, unsigned int _offset)
pick faces
void pickCells(GLState &_state, unsigned int _offset)
pick cells
void getSelectionRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat)
adds render objects for drawing selected primitves to the given renderer
void invalidateAllSelectionBuffers()
invalidates all buffers used for rendering selected primitives
void setupLineRendering(float _lineWidth, const Vec2f &_screenSize)
Setup rendering of thick lines.
void pointSize(float _sz)
set point size (default: 1.0)
static void cullFace(GLenum _mode)
replaces glCullFace, 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