54 #define ACG_MESHNODE_C 56 #include "MeshNode2T.hh" 58 #include <ACG/Geometry/GPUCacheOptimizer.hh> 59 #include <ACG/GL/DrawMesh.hh> 60 #include <ACG/GL/GLError.hh> 61 #include <ACG/GL/GLState.hh> 78 const std::string& _name ):
85 updateVertexPicking_(true),
86 vertexPickingBaseIndex_(0),
87 updateEdgePicking_(true),
88 edgePickingBaseIndex_(0),
89 updateFacePicking_(true),
90 facePickingBaseIndex_(0),
91 updateAnyPicking_(true),
92 anyPickingBaseIndex_(0),
93 perFaceTextureIndexAvailable_(false),
95 draw_with_offset_(false)
103 MeshNodeBase::supplyDrawMesh(drawMesh_);
121 drawModes |= DrawModes::POINTS;
122 drawModes |= DrawModes::HIDDENLINE;
123 drawModes |= DrawModes::WIREFRAME;
124 drawModes |= DrawModes::HALFEDGES;
126 if (mesh_.has_vertex_normals())
128 drawModes |= DrawModes::POINTS_SHADED;
129 drawModes |= DrawModes::SOLID_SMOOTH_SHADED;
130 drawModes |= DrawModes::SOLID_PHONG_SHADED;
133 if (mesh_.has_face_normals())
134 drawModes |= DrawModes::SOLID_FLAT_SHADED;
136 if (mesh_.has_halfedge_normals())
137 drawModes |= DrawModes::SOLID_SMOOTH_SHADED_FEATURES;
139 if (mesh_.has_vertex_colors())
141 drawModes |= DrawModes::POINTS_COLORED;
142 drawModes |= DrawModes::SOLID_POINTS_COLORED;
144 if (mesh_.has_vertex_normals())
145 drawModes |= DrawModes::SOLID_POINTS_COLORED_SHADED;
148 if(mesh_.has_edge_colors())
150 drawModes |= DrawModes::EDGES_COLORED;
153 if(mesh_.has_halfedge_colors())
155 drawModes |= DrawModes::HALFEDGES_COLORED;
158 bool enableTexturedFaces = drawMesh_->perFaceTextureCoordinateAvailable() != 0;
160 if (mesh_.has_face_colors()) {
161 drawModes |= DrawModes::SOLID_FACES_COLORED;
163 if( mesh_.has_face_normals() )
164 drawModes |= DrawModes::SOLID_FACES_COLORED_FLAT_SHADED;
166 if (mesh().has_vertex_normals()) {
167 drawModes |= DrawModes::SOLID_FACES_COLORED_SMOOTH_SHADED;
169 if (enableTexturedFaces)
170 drawModes |= DrawModes::SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED;
174 if ( mesh_.has_vertex_texcoords2D() ) {
175 drawModes |= DrawModes::SOLID_TEXTURED;
177 if (mesh_.has_vertex_normals())
178 drawModes |= DrawModes::SOLID_TEXTURED_SHADED;
181 if ( enableTexturedFaces ) {
182 drawModes |= DrawModes::SOLID_2DTEXTURED_FACE;
184 if (mesh_.has_face_normals())
185 drawModes |= DrawModes::SOLID_2DTEXTURED_FACE_SHADED;
226 glPushAttrib(GL_ENABLE_BIT);
228 GLenum prev_depth_offset = _state.
depthFunc();
229 if(draw_with_offset_)
232 glPolygonOffset(-1.0f, -10.0f);
246 if ( (_drawMode & DrawModes::POINTS) || (_drawMode & DrawModes::POINTS_COLORED) || (_drawMode & DrawModes::POINTS_SHADED ) ) {
252 if ( _drawMode & DrawModes::POINTS_SHADED ) {
258 if ( enableColors_ && (_drawMode & DrawModes::POINTS_COLORED) )
260 drawMesh_->usePerVertexColors();
263 if ( enableNormals_ && (_drawMode & DrawModes::POINTS_SHADED ) )
269 drawMesh_->disableColors();
280 if (_drawMode & DrawModes::WIREFRAME)
294 drawMesh_->disableColors();
301 if (_drawMode & DrawModes::HIDDENLINE)
309 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
312 drawMesh_->disableColors();
315 clear_color[3] = 1.0;
333 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
337 if (_drawMode & DrawModes::EDGES_COLORED)
339 enable_arrays( PER_EDGE_VERTEX_ARRAY | PER_EDGE_COLOR_ARRAY );
345 if (_drawMode & DrawModes::HALFEDGES)
349 enable_arrays( PER_HALFEDGE_VERTEX_ARRAY);
355 if (_drawMode & DrawModes::HALFEDGES_COLORED)
357 enable_arrays( PER_HALFEDGE_VERTEX_ARRAY | PER_HALFEDGE_COLOR_ARRAY );
363 if ( ( _drawMode & DrawModes::SOLID_POINTS_COLORED ) && mesh_.has_vertex_colors() )
369 drawMesh_->usePerVertexColors();
375 if ( ( _drawMode & DrawModes::SOLID_POINTS_COLORED_SHADED ) && mesh_.has_vertex_colors() && mesh_.has_vertex_normals() )
380 if ( enableNormals_ ) {
386 drawMesh_->usePerVertexColors();
392 if ( ( _drawMode & DrawModes::SOLID_FLAT_SHADED ) && mesh_.has_face_normals() && mesh_.n_faces() > 0)
398 drawMesh_->setFlatShading();
399 drawMesh_->disableColors();
405 if ( ( _drawMode & DrawModes::SOLID_SMOOTH_SHADED ) && mesh_.has_vertex_normals() )
411 drawMesh_->usePerVertexNormals();
412 drawMesh_->setSmoothShading();
413 drawMesh_->disableColors();
418 if ( ( _drawMode & DrawModes::SOLID_PHONG_SHADED ) && mesh_.has_vertex_normals() )
435 drawMesh_->usePerVertexNormals();
436 drawMesh_->setSmoothShading();
437 drawMesh_->disableColors();
449 if ( ( _drawMode & DrawModes::SOLID_FACES_COLORED ) && mesh_.has_face_colors() && mesh_.n_faces() > 0)
458 drawMesh_->usePerFaceColors();
467 if ( ( _drawMode & DrawModes::SOLID_SMOOTH_SHADED_FEATURES ) && mesh_.has_halfedge_normals() && mesh_.n_faces() > 0)
473 drawMesh_->disableColors();
474 drawMesh_->setSmoothShading();
475 drawMesh_->usePerHalfedgeNormals();
482 if ( ( _drawMode & DrawModes::SOLID_FACES_COLORED_FLAT_SHADED ) && mesh_.has_face_colors() && mesh_.has_face_normals() && mesh_.n_faces() > 0 )
491 drawMesh_->setFlatShading();
492 drawMesh_->usePerFaceColors();
501 if ( ( _drawMode & DrawModes::SOLID_FACES_COLORED_SMOOTH_SHADED ) && mesh_.has_face_colors() && mesh_.has_vertex_normals() && mesh_.n_faces() > 0)
509 drawMesh_->setSmoothShading();
510 drawMesh_->usePerVertexNormals();
511 drawMesh_->usePerFaceColors();
514 drawMesh_->draw(textureMap_,
true);
524 if ((_drawMode & DrawModes::SOLID_FACES_COLORED_2DTEXTURED_FACE_SMOOTH_SHADED) && mesh_.has_face_colors() && mesh_.has_vertex_normals() && mesh_.n_faces() > 0)
536 drawMesh_->setSmoothShading();
537 drawMesh_->usePerVertexNormals();
538 drawMesh_->usePerFaceColors();
539 drawMesh_->usePerHalfedgeTexcoords();
541 drawMesh_->draw(textureMap_,
true);
549 if ( ( _drawMode & DrawModes::SOLID_TEXTURED ) && mesh_.has_vertex_texcoords2D())
556 drawMesh_->disableColors();
557 drawMesh_->usePerVertexTexcoords();
561 GLint prevTexEnvMode = 0;
562 glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &prevTexEnvMode);
563 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
569 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, prevTexEnvMode);
572 if ((_drawMode & DrawModes::SOLID_ENV_MAPPED) && mesh_.has_vertex_normals())
579 drawMesh_->disableColors();
580 drawMesh_->usePerVertexTexcoords();
584 GLint prevTexEnvMode = 0;
585 glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &prevTexEnvMode);
586 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
592 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, prevTexEnvMode);
595 if ( ( _drawMode & DrawModes::SOLID_TEXTURED_SHADED ) && mesh_.has_vertex_texcoords2D() && mesh_.has_vertex_normals())
603 drawMesh_->setSmoothShading();
604 drawMesh_->disableColors();
605 drawMesh_->usePerVertexTexcoords();
614 if ( (_drawMode & DrawModes::SOLID_2DTEXTURED_FACE) && mesh_.n_faces() > 0 )
624 drawMesh_->disableColors();
625 drawMesh_->usePerHalfedgeTexcoords();
627 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
637 if ( ( _drawMode & DrawModes::SOLID_2DTEXTURED_FACE_SHADED ) && mesh_.has_face_normals() && mesh_.n_faces() > 0)
647 drawMesh_->setFlatShading();
648 drawMesh_->disableColors();
649 drawMesh_->usePerHalfedgeTexcoords();
662 if(draw_with_offset_)
671 template <
class Mesh>
676 ro.debugName =
"MeshNode";
680 for (
unsigned int i = 0; i < _drawMode.
getNumLayers(); ++i)
689 ro.depthWrite =
true;
691 ro.setMaterial(_mat);
706 switch (props->colorSource())
708 case DrawModes::COLOR_PER_VERTEX: drawMesh_->usePerVertexColors();
break;
709 case DrawModes::COLOR_PER_FACE: drawMesh_->usePerFaceColors();
break;
712 drawMesh_->disableColors();
718 if (props->primitive() == DrawModes::PRIMITIVE_POLYGON)
720 switch (props->normalSource())
722 case DrawModes::NORMAL_PER_VERTEX: drawMesh_->usePerVertexNormals();
break;
723 case DrawModes::NORMAL_PER_HALFEDGE: drawMesh_->usePerHalfedgeNormals();
break;
728 drawMesh_->setFlatShading();
730 drawMesh_->setSmoothShading();
736 switch (props->texcoordSource())
738 case DrawModes::TEXCOORD_PER_VERTEX: drawMesh_->usePerVertexTexcoords();
break;
739 case DrawModes::TEXCOORD_PER_HALFEDGE: drawMesh_->usePerHalfedgeTexcoords();
break;
757 switch (props->lightStage())
759 case DrawModes::LIGHTSTAGE_SMOOTH:
762 case DrawModes::LIGHTSTAGE_PHONG:
765 case DrawModes::LIGHTSTAGE_UNLIT:
773 if (props->normalSource() == DrawModes::NORMAL_PER_FACE)
780 if (props->primitive() == DrawModes::PRIMITIVE_WIREFRAME)
782 ro.debugName =
"MeshNode.Wireframe";
785 drawMesh_->disableColors();
789 ro.emissive = ro.specular;
791 ro.emissive = OpenMesh::color_cast<ACG::Vec3f>(_state.
overlay_color());
799 applyRenderObjectSettings(props->primitive(), &ro);
800 drawMesh_->addLineRenderObjects(_renderer, &ro);
803 if (props->primitive() == DrawModes::PRIMITIVE_HIDDENLINE)
806 drawMesh_->disableColors();
810 ro.emissive = ro.specular;
812 ro.emissive = OpenMesh::color_cast<ACG::Vec3f>(_state.
overlay_color());
816 if ( (polyLayer >
int(i) || polyLayer < 0) && ( mesh_.n_faces() != 0 ))
820 applyRenderObjectSettings(DrawModes::PRIMITIVE_POLYGON, &ro);
823 ro.glColorMask(0,0,0,0);
825 ro.debugName =
"MeshNode.HiddenLine.faces";
826 add_face_RenderObjects(_renderer, &ro);
832 ro.glColorMask(1,1,1,1);
837 applyRenderObjectSettings(DrawModes::PRIMITIVE_HIDDENLINE, &ro);
839 ro.debugName =
"MeshNode.HiddenLine.lines";
840 drawMesh_->addLineRenderObjects(_renderer, &ro);
843 if (props->
colored() && props->primitive() == DrawModes::PRIMITIVE_EDGE)
849 ro.emissive = ro.specular;
854 applyRenderObjectSettings(props->primitive(), &ro);
855 ro.debugName =
"MeshNode.Edges";
856 drawMesh_->addLineRenderObjects(_renderer, &ro);
862 if (props->primitive() == DrawModes::PRIMITIVE_HALFEDGE)
867 drawMesh_->updateEdgeHalfedgeVertexDeclarations();
868 halfedgeDecl.clear();
873 ro.emissive = ro.specular;
876 ro.glDrawArrays(GL_LINES, 0,
int(mesh_.n_halfedges() * 2));
878 ro.debugName =
"MeshNode.HalfEdges";
888 switch (props->primitive())
890 case DrawModes::PRIMITIVE_POINT:
892 if (ro.
shaderDesc.shadeMode == SG_SHADE_UNLIT)
896 ro.emissive = ro.specular;
898 ro.emissive = OpenMesh::color_cast<ACG::Vec3f>(_state.
overlay_color());
904 applyRenderObjectSettings(props->primitive(), &ro);
905 ro.debugName =
"MeshNode.Points";
906 add_point_RenderObjects(_renderer, &ro);
908 case DrawModes::PRIMITIVE_EDGE:
911 ro.emissive = ro.specular;
916 applyRenderObjectSettings(props->primitive(), &ro);
917 ro.debugName =
"MeshNode.Edges";
918 drawMesh_->addLineRenderObjects(_renderer, &ro);
920 case DrawModes::PRIMITIVE_POLYGON:
922 applyRenderObjectSettings(props->primitive(), &ro);
924 if (!ro.
shaderDesc.vertexTemplateFile.isEmpty())
925 drawMesh_->scanVertexShaderForInput(ro.
shaderDesc.vertexTemplateFile.toStdString());
927 bool useNonIndexed = (props->colorSource() == DrawModes::COLOR_PER_FACE) && (props->lightStage() == DrawModes::LIGHTSTAGE_SMOOTH) && !props->
flatShaded();
928 if (!useNonIndexed && props->colorSource() == DrawModes::COLOR_PER_FACE)
931 ro.debugName =
"MeshNode.Faces";
932 add_face_RenderObjects(_renderer, &ro, useNonIndexed);
947 drawMesh_->addPointRenderObjects(_renderer, _baseObj);
954 drawMesh_->drawVertices();
962 if ((enabled_arrays_ & PER_EDGE_COLOR_ARRAY) && (enabled_arrays_ & PER_EDGE_VERTEX_ARRAY))
965 glDrawArrays(GL_LINES, 0,
int(mesh_.n_edges() * 2));
968 drawMesh_->drawLines();
976 if ( enabled_arrays_ & PER_HALFEDGE_VERTEX_ARRAY )
977 glDrawArrays(GL_LINES, 0,
int(mesh_.n_halfedges() * 2));
980 std::cerr <<
"Unable to Draw! halfedge array configuration is invalid!!" << std::endl;
987 drawMesh_->
draw(textureMap_);
994 drawMesh_->addTriRenderObjects(_renderer, _baseObj, textureMap_, _nonindexed);
1011 if (_arrays & PER_EDGE_VERTEX_ARRAY) {
1014 if (!(enabled_arrays_ & PER_EDGE_VERTEX_ARRAY)) {
1015 enabled_arrays_ |= PER_EDGE_VERTEX_ARRAY;
1024 }
else if (enabled_arrays_ & PER_EDGE_VERTEX_ARRAY) {
1026 enabled_arrays_ &= ~PER_EDGE_VERTEX_ARRAY;
1035 if ( mesh_.has_edge_colors() && ( _arrays & PER_EDGE_COLOR_ARRAY) ) {
1038 if (!(enabled_arrays_ & PER_EDGE_COLOR_ARRAY)) {
1039 enabled_arrays_ |= PER_EDGE_COLOR_ARRAY;
1048 }
else if (enabled_arrays_ & PER_EDGE_COLOR_ARRAY) {
1050 enabled_arrays_ &= ~PER_EDGE_COLOR_ARRAY;
1060 if (_arrays & PER_HALFEDGE_VERTEX_ARRAY) {
1063 if (!(enabled_arrays_ & PER_HALFEDGE_VERTEX_ARRAY)) {
1064 enabled_arrays_ |= PER_HALFEDGE_VERTEX_ARRAY;
1073 }
else if (enabled_arrays_ & PER_HALFEDGE_VERTEX_ARRAY) {
1075 enabled_arrays_ &= ~PER_HALFEDGE_VERTEX_ARRAY;
1084 if ( mesh_.has_halfedge_colors() && ( _arrays & PER_HALFEDGE_COLOR_ARRAY) ) {
1087 if (!(enabled_arrays_ & PER_HALFEDGE_COLOR_ARRAY)) {
1088 enabled_arrays_ |= PER_HALFEDGE_COLOR_ARRAY;
1097 }
else if (enabled_arrays_ & PER_HALFEDGE_COLOR_ARRAY) {
1099 enabled_arrays_ &= ~PER_HALFEDGE_COLOR_ARRAY;
1109 template<
class Mesh>
1118 pick_vertices(_state);
1123 pick_vertices(_state,
true);
1146 pick_edges(_state,
true);
1156 template<
class Mesh>
1163 if (!_state.
pick_set_maximum (static_cast<unsigned int>(mesh_.n_vertices()))) {
1164 omerr() <<
"MeshNode::pick_vertices: color range too small, " <<
"picking failed\n";
1168 if ( mesh_.n_vertices() == 0 ) {
1169 std::cerr <<
"pick_vertices: No vertices in Mesh!" << std::endl;
1173 if (_front && ( mesh_.n_faces() != 0 ) ) {
1177 clear_color[3] = 1.0;
1179 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1186 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
1190 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1196 int pickImplementationMethod = 0;
1200 if (drawMesh_->supportsPickingVertices_opt())
1205 if ( updateVertexPicking_ || _state.
pick_current_index () != vertexPickingBaseIndex_) {
1206 if (pickImplementationMethod == 0)
1207 drawMesh_->updatePickingVertices(_state);
1209 drawMesh_->updatePickingVertices_opt(_state);
1211 updateVertexPicking_ =
false;
1214 if (mesh_.n_vertices()) {
1216 if (pickImplementationMethod == 0) {
1227 glDrawArrays(GL_POINTS, 0,
int(mesh_.n_vertices()));
1235 else if (pickImplementationMethod == 1){
1238 drawMesh_->drawPickingVertices_opt(_state.
projection() * _state.
modelview(), vertexPickingBaseIndex_);
1244 std::cerr <<
"pick_vertices: No vertices in Mesh!" << std::endl;
1248 std::cerr <<
"No fallback pick_vertices!" << std::endl;
1255 template<
class Mesh>
1262 if (!_state.
pick_set_maximum (static_cast<unsigned int>(mesh_.n_edges()))) {
1263 omerr() <<
"MeshNode::pick_edges: color range too small, " <<
"picking failed\n";
1267 if ( mesh_.n_vertices() == 0 ) {
1268 std::cerr <<
"pick_edges: No vertices in Mesh!" << std::endl;
1272 if ( _front && ( mesh_.n_faces() != 0 ) ) {
1276 clear_color[3] = 1.0;
1278 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1285 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
1289 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1300 int pickImplementationMethod = 0;
1303 if (drawMesh_->supportsPickingEdges_opt())
1307 if (pickImplementationMethod == 0)
1308 drawMesh_->updatePickingEdges(_state);
1310 drawMesh_->updatePickingEdges_opt(_state);
1312 updateEdgePicking_ =
false;
1315 if ( mesh_.n_edges() != 0 && drawMesh_) {
1317 if (pickImplementationMethod == 0){
1327 glDrawArrays(GL_LINES, 0,
int(mesh_.n_edges() * 2));
1335 else if (pickImplementationMethod == 1){
1337 drawMesh_->drawPickingEdges_opt(_state.
projection() * _state.
modelview(), edgePickingBaseIndex_);
1344 std::cerr <<
"No fallback pick_edges!" << std::endl;
1351 template<
class Mesh>
1357 if ( mesh_.n_vertices() == 0 ) {
1358 std::cerr <<
"pick_faces: No vertices in Mesh!" << std::endl;
1362 if ( mesh_.n_faces() > 0 ) {
1363 if (!_state.
pick_set_maximum (static_cast<unsigned int>(mesh_.n_faces()))) {
1364 omerr() <<
"MeshNode::pick_faces: color range too small, " <<
"picking failed\n";
1369 omerr() <<
"Strange pickSetMAximum failed for index 1 in MeshNode\n";
1377 int pickImplementationMethod = 0;
1381 if (drawMesh_->supportsPickingFaces_opt())
1388 if (pickImplementationMethod == 0) {
1392 drawMesh_->updatePickingFaces(_state);
1394 updateFacePicking_ =
false;
1397 if ( mesh_.n_faces() != 0 ) {
1408 glDrawArrays(GL_TRIANGLES, 0,
int(3 * drawMesh_->getNumTris()));
1419 else if (pickImplementationMethod == 1) {
1424 drawMesh_->updatePickingFaces_opt(_state);
1426 updateFacePicking_ =
false;
1429 if ( mesh_.n_faces() != 0 ) {
1431 drawMesh_->drawPickingFaces_opt(_state.
projection() * _state.
modelview(), facePickingBaseIndex_);
1445 std::cerr <<
"Unknown picking method in pick_faces!" << std::endl;
1449 std::cerr <<
"No fallback pick_faces!" << std::endl;
1453 template<
class Mesh>
1459 size_t numElements = mesh_.n_faces() + mesh_.n_edges() + mesh_.n_vertices();
1461 if ( mesh_.n_vertices() == 0 ) {
1462 std::cerr <<
"pick_any: No vertices in Mesh!" << std::endl;
1467 if (numElements == 0) {
1468 std::cerr <<
"pick_any: Number of elements : 0 " << std::endl;
1474 omerr() <<
"MeshNode::pick_any: color range too small, " <<
"picking failed\n";
1483 int pickImplementationMethod = 0;
1486 if (drawMesh_->supportsPickingAny_opt())
1491 if (pickImplementationMethod == 0)
1492 drawMesh_->updatePickingAny(_state);
1494 drawMesh_->updatePickingAny_opt(_state);
1496 updateAnyPicking_ =
false;
1499 if (pickImplementationMethod == 0){
1510 if ( mesh_.n_faces() != 0 && drawMesh_) {
1515 glDrawArrays(GL_TRIANGLES, 0,
int(3 * drawMesh_->getNumTris()));
1521 if ( mesh_.n_edges() != 0 && drawMesh_) {
1526 glDrawArrays(GL_LINES, 0,
int(mesh_.n_edges() * 2));
1535 glDrawArrays(GL_POINTS, 0,
int(mesh_.n_vertices()));
1544 drawMesh_->drawPickingAny_opt(_state.
projection() * _state.
modelview(), anyPickingBaseIndex_);
1548 std::cerr <<
"No fallback pick_any!" << std::endl;
1556 template<
class Mesh>
1566 updateVertexPicking_ =
true;
1567 updateEdgePicking_ =
true;
1568 updateFacePicking_ =
true;
1569 updateAnyPicking_ =
true;
1572 drawMesh_->invalidatePerEdgeBuffers();
1575 drawMesh_->invalidatePerHalfedgeBuffers();
1577 drawMesh_->updateGeometry();
1579 drawMesh_->invalidateFullVBO();
1582 bbMin_ =
Vec3d(FLT_MAX, FLT_MAX, FLT_MAX);
1583 bbMax_ =
Vec3d(-FLT_MAX, -FLT_MAX, -FLT_MAX);
1584 typename Mesh::ConstVertexIter v_it(mesh_.vertices_begin()), v_end(mesh_.vertices_end());
1586 for (; v_it!=v_end; ++v_it)
1588 bbMin_.minimize(mesh_.point(*v_it));
1589 bbMax_.maximize(mesh_.point(*v_it));
1593 template<
class Mesh>
1598 drawMesh_->invalidatePerEdgeBuffers();
1599 drawMesh_->invalidatePerHalfedgeBuffers();
1602 drawMesh_->updateTopology();
1608 template<
class Mesh>
1612 drawMesh_->updateTextures();
1614 updateVertexPicking_ =
true;
1615 updateFacePicking_ =
true;
1616 updateAnyPicking_ =
true;
1621 template<
class Mesh>
1626 drawMesh_->invalidatePerEdgeBuffers();
1627 drawMesh_->invalidatePerHalfedgeBuffers();
1632 drawMesh_->updateFull();
1635 template<
class Mesh>
1640 drawMesh_->setTextureIndexPropertyName(_indexPropertyName);
1641 perFaceTextureIndexAvailable_ = drawMesh_->perFaceTextureIndexAvailable() != 0;
1644 template<
class Mesh>
1649 return drawMesh_->getTextureIndexPropertyName();
1652 template<
class Mesh>
1656 drawMesh_->setPerFaceTextureCoordinatePropertyName(_halfedgeTextcoordPropertyName);
1662 template<
class Mesh>
1666 unsigned int res = 0;
1675 template<
class Mesh>
static void enable(GLenum _cap, bool _warnRemoved=true)
replaces glEnable, but supports locking
bool color_picking() const
Is color picking active?
static GLuint getBoundTextureBuffer()
get bound texture
void glColor(const Vec3f &_v)
Wrapper: glColor for Vec3f.
void initFromState(GLState *_glState)
Initializes a RenderObject instance.
int getLayerIndexByPrimitive(DrawModePrimitive _type) const
search for layer with specified primitive
void pointSize(float _sz)
set point size (default: 1.0)
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
picks edges (may not be implemented for all nodes)
const Vec4f & specular_color() const
get specular color
picks faces (should be implemented for all nodes)
bool flatShaded() const
Is flat shading used (Normals per face)?
bool isAtomic() const
Check if this is an atomic draw Mode.
int viewport_width() const
get viewport width
bool lighting() const
Is lighting enabled?
Namespace providing different geometric functions concerning angles.
picks only visible front verices (may not be implemented for all nodes)
const Vec4f & overlay_color() const
Get overlay color.
void getRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat) override
Draws the object deferred.
const Vec4f & color()
set color
GLenum depthFunc
GL_LESS, GL_LEQUAL, GL_GREATER ..
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode) override
Draws the object.
static void bindTexture(GLenum _target, GLuint _buffer)
replaces glBindTexture, supports locking
const Vec4f & base_color() const
get base color (used when lighting is off)
ShaderGenDesc shaderDesc
Drawmode and other shader params.
size_t pick_current_index() const
Returns the current color picking index (can be used for caching)
void clearTextures()
disables texture support and removes all texture types
QString vertexColorsInterpolator
interpolation qualifier for input vertex colors: "flat", "smooth", "noperspective" ...
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
GLuint vertexBuffer
VBO, IBO ids, ignored if VAO is provided.
const GLenum & depthFunc() const
get glDepthFunc() that is supposed to be active
static void vertexPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glVertexPointer, supports locking
void setupLineRendering(float _lineWidth, const Vec2f &_screenSize)
Setup rendering of thick lines.
bool colored() const
Are colors used?
bool ACGDLLEXPORT openGLVersionTest(const int _major, const int _minor)
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
PickTarget
What target to use for picking.
Vec2f depthRange
glDepthRange: (znear, zmax)
unsigned int getMemoryUsage()
measures the size in bytes of allocated memory
static void disable(GLenum _cap, bool _warnRemoved=true)
replaces glDisable, but supports locking
void setupPointRendering(float _pointSize, const Vec2f &_screenSize)
Setup rendering of circle points.
pick any of the prior targets (should be implemented for all nodes)
static void disableClientState(GLenum _cap)
replaces glDisableClientState, supports locking
bool pick_set_maximum(size_t _idx)
Set the maximal number of primitives/components of your object.
QString vertexNormalInterpolator
interpolation qualifier for vertex shader normal outputs: "flat", "smooth", "noperspective" ...
picks verices (may not be implemented for all nodes)
GLuint indexBuffer
Use vertex array object.
static void enableClientState(GLenum _cap)
replaces glEnableClientState, supports locking
int viewport_height() const
get viewport height
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
picks only visible front edges (may not be implemented for all nodes)
static GLenum getBoundTextureTarget()
get bound texture target
const VertexDeclaration * vertexDecl
Defines the vertex buffer layout, ignored if VAO is provided.
DrawModeProperties stores a set of properties that defines, how to render an object.
void set_color(const Vec4f &_col)
set color
virtual void addRenderObject(RenderObject *_renderObject)
Callback for the scenegraph nodes, which send new render objects via this function.
static void colorPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glColorPointer, supports locking
void addTextureType(GLenum _type, bool _shadow, size_t _stage)
adds a texture type to the shader and enables texturing.
int priority
Priority to allow sorting of objects.
MeshNodeT(Mesh &_mesh, BaseNode *_parent=0, const std::string &_name="<MeshNode>")
Default constructor.
void set_base_color(const Vec4f &_col)
set base color (used when lighting is off)
const GLMatrixd & modelview() const
get modelview matrix
float line_width() const
get line width
const DrawModeProperties * getLayer(unsigned int _i) const
returns the property set at layer i
const GLMatrixd & projection() const
get projection matrix
Interface class between scenegraph and renderer.
size_t getNumLayers() const
returns the layer count
const Vec4f & clear_color() const
get background color
static void bindBuffer(GLenum _target, GLuint _buffer)
replaces glBindBuffer, supports locking
bool twosided_lighting()
get whether transparenet or solid objects should be drawn