53 #ifndef DOXY_IGNORE_THIS 54 #define ACG_MESHNODE_C 59 #include "MeshNodeDeprecatedT.hh" 60 #include "ShaderNode.hh" 61 #include "DrawModes.hh" 62 #include <ACG/GL/gl.hh> 63 #include <ACG/GL/GLError.hh> 64 #include <ACG/GL/ColorTranslator.hh> 67 #include <OpenMesh/Core/Utils/Property.hh> 82 MeshNodeDeprecatedT<Mesh>::
83 MeshNodeDeprecatedT(
const Mesh& _mesh,
89 face_index_buffer_(0),
92 vertexBufferInitialized_(false),
93 normalBufferInitialized_(false),
94 faceIndexBufferInitialized_(false),
97 default_halfedge_textcoord_property_(
"h:texcoords2D"),
98 indexPropertyName_(
"f:textureindex"),
99 updateFaceList_(true),
100 updateVertexList_(true),
101 updateEdgeList_(true),
102 updateAnyList_(true),
107 bbMin_(FLT_MAX, FLT_MAX, FLT_MAX),
108 bbMax_(-FLT_MAX, -FLT_MAX, -FLT_MAX)
110 faceList_ = glGenLists (1);
111 vertexList_ = glGenLists (1);
112 edgeList_ = glGenLists (1);
113 anyList_ = glGenLists (3);
121 MeshNodeDeprecatedT<Mesh>::
122 ~MeshNodeDeprecatedT()
125 glDeleteBuffers(1, (GLuint*) &vertex_buffer_);
128 glDeleteBuffers(1, (GLuint*) &normal_buffer_);
130 if (face_index_buffer_)
131 glDeleteBuffers(1, (GLuint*) &face_index_buffer_ );
134 glDeleteLists (faceList_, 1);
137 glDeleteLists (vertexList_, 1);
140 glDeleteLists (edgeList_, 1);
143 glDeleteLists (anyList_, 3);
152 MeshNodeDeprecatedT<Mesh>::
165 MeshNodeDeprecatedT<Mesh>::
166 availableDrawModes()
const 175 if (
mesh_.has_vertex_normals())
182 if (
mesh_.has_vertex_colors())
188 if (
mesh_.has_face_normals())
191 if (
mesh_.has_face_colors())
195 if(
mesh_.has_face_normals() )
199 if (
mesh_.has_vertex_texcoords1D())
203 if (
mesh_.has_vertex_normals())
207 if (
mesh_.has_vertex_texcoords2D())
211 if (
mesh_.has_vertex_normals())
215 if (
mesh_.has_vertex_texcoords3D())
219 if (
mesh_.has_vertex_normals())
223 if (
mesh_.has_halfedge_texcoords2D())
226 if (
mesh_.has_face_normals())
239 MeshNodeDeprecatedT<Mesh>::
240 enable_arrays(
unsigned int _arrays)
245 typedef typename Point::value_type PointScalar;
247 typedef typename Normal::value_type NormalScalar;
250 ((_arrays == VERTEX_ARRAY || _arrays == (VERTEX_ARRAY | NORMAL_ARRAY)) &&
251 (vertexBufferInitialized_ && normalBufferInitialized_) ) ;
257 if (!use_vbo && vertex_buffer_)
262 if (_arrays & VERTEX_ARRAY)
289 if (_arrays & NORMAL_ARRAY)
316 if (_arrays & COLOR_ARRAY)
332 if (_arrays & TEXTURE_COORD_1D_ARRAY)
348 if (_arrays & TEXTURE_COORD_2D_ARRAY)
364 if (_arrays & TEXTURE_COORD_3D_ARRAY)
389 MeshNodeDeprecatedT<Mesh>::
392 updateFaceList_ =
true;
393 updateVertexList_ =
true;
394 updateEdgeList_ =
true;
395 updateAnyList_ =
true;
399 typename Mesh::ConstVertexIter v_it(
mesh_.vertices_begin()),
400 v_end(
mesh_.vertices_end());
402 for (; v_it!=v_end; ++v_it)
409 typedef typename Point::value_type PointScalar;
411 typedef typename Normal::value_type NormalScalar;
417 if (!vertex_buffer_) glGenBuffers(1, (GLuint*) &vertex_buffer_);
420 vertexBufferInitialized_ =
false;
423 if (
sizeof(PointScalar) == 4 ) {
425 glBufferData(GL_ARRAY_BUFFER_ARB,
426 3 *
mesh_.n_vertices() *
sizeof(PointScalar),
430 vertexBufferInitialized_ =
true;
435 typename Mesh::ConstVertexIter v_it(
mesh_.vertices_begin()),
436 v_end(
mesh_.vertices_end());
438 for ( ; v_it != v_end ; ++v_it )
441 if ( !vertices_.empty() ) {
443 glBufferData(GL_ARRAY_BUFFER_ARB,
444 3 *
mesh_.n_vertices() *
sizeof(float),
447 vertexBufferInitialized_ =
true;
456 if (!normal_buffer_) glGenBuffers(1, (GLuint*) &normal_buffer_);
458 normalBufferInitialized_ =
false;
461 if (
sizeof(NormalScalar) == 4) {
463 glBufferData(GL_ARRAY_BUFFER_ARB,
464 3 *
mesh_.n_vertices() *
sizeof(NormalScalar),
465 mesh_.vertex_normals(),
468 normalBufferInitialized_ =
true;
472 typename Mesh::ConstVertexIter v_it(
mesh_.vertices_begin()),
473 v_end(
mesh_.vertices_end());
475 for ( ; v_it != v_end ; ++v_it )
478 if ( !normals_.empty() ) {
480 glBufferData(GL_ARRAY_BUFFER_ARB,
481 3 *
mesh_.n_vertices() *
sizeof(float),
484 normalBufferInitialized_ =
true;
492 }
else omlog() <<
"MeshNodeDeprecatedT: VBO not supported on this machine\n";
501 MeshNodeDeprecatedT<Mesh>::
504 updateFaceList_ =
true;
505 updateVertexList_ =
true;
509 typename Mesh::ConstFaceIter f_it(
mesh_.faces_sbegin()),
510 f_end(
mesh_.faces_end());
516 std::vector<unsigned int>().swap(indices_);
517 indices_.reserve(
mesh_.n_faces()*3);
519 for (; f_it!=f_end; ++f_it)
521 fv_it =
mesh_.cfv_iter( *f_it );
522 indices_.push_back(fv_it->idx()); ++fv_it;
523 indices_.push_back(fv_it->idx()); ++fv_it;
524 indices_.push_back(fv_it->idx());
530 std::vector<unsigned int>().swap(indices_);
531 omerr() <<
"Topology caching failed\n";
537 faceIndexBufferInitialized_ =
false;
539 if ( !indices_.empty() ) {
542 if (!face_index_buffer_) glGenBuffers(1, (GLuint*) &face_index_buffer_);
547 glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB,
548 indices_.size() *
sizeof(
unsigned int),
552 faceIndexBufferInitialized_ =
true;
569 MeshNodeDeprecatedT<Mesh>::
570 draw(GLState& _state,
const DrawModes::DrawMode& _drawMode)
572 GLenum prev_depth = _state.depthFunc();
603 glPushAttrib(GL_ENABLE_BIT);
610 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
612 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
622 Vec4f clear_color = _state.clear_color();
623 Vec4f base_color = _state.base_color();
624 clear_color[3] = 1.0;
628 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
629 _state.set_base_color(clear_color);
635 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
637 _state.set_base_color(base_color);
640 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
702 Vec4f base_color_backup = _state.base_color();
710 _state.set_base_color(base_color_backup);
716 Vec4f base_color_backup = _state.base_color();
724 _state.set_base_color(base_color_backup);
730 Vec4f base_color_backup = _state.base_color();
739 _state.set_base_color(base_color_backup);
758 enable_arrays(VERTEX_ARRAY | NORMAL_ARRAY | TEXTURE_COORD_2D_ARRAY);
773 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
786 const Vec4f ambient = _state.ambient_color();
787 const Vec4f diffuse = _state.diffuse_color();
788 const Vec4f specular = _state.specular_color();
789 _state.set_ambient_color (
Vec4f(0.1, 0.1, 0.1, 1.0));
790 _state.set_diffuse_color (
Vec4f(0.8, 0.8, 0.8, 1.0));
791 _state.set_specular_color (
Vec4f(1.0, 1.0, 1.0, 1.0));
795 glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &texmode);
796 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
798 enable_arrays(VERTEX_ARRAY | NORMAL_ARRAY | TEXTURE_COORD_1D_ARRAY);
808 _state.set_ambient_color(ambient);
809 _state.set_diffuse_color(diffuse);
810 _state.set_specular_color(specular);
813 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, texmode);
833 enable_arrays(VERTEX_ARRAY | NORMAL_ARRAY | TEXTURE_COORD_3D_ARRAY);
874 if (
mesh_.has_face_normals() )
896 MeshNodeDeprecatedT<Mesh>::
899 glDrawArrays(GL_POINTS, 0,
mesh_.n_vertices());
908 MeshNodeDeprecatedT<Mesh>::
909 draw_faces(FaceMode _mode)
911 typename Mesh::ConstFaceIter f_it(
mesh_.faces_sbegin()),
912 f_end(
mesh_.faces_end());
922 glBegin(GL_TRIANGLES);
923 for (; f_it!=f_end; ++f_it)
927 fv_it=
mesh_.cfv_iter(*f_it);
936 for (; f_it!=f_end; ++f_it)
940 for (fv_it=
mesh_.cfv_iter(*f_it); fv_it.is_valid(); ++fv_it)
953 glBegin(GL_TRIANGLES);
954 for (; f_it!=f_end; ++f_it)
958 fv_it=
mesh_.cfv_iter(*f_it);
967 for (; f_it!=f_end; ++f_it)
971 for (fv_it=
mesh_.cfv_iter(*f_it); fv_it.is_valid(); ++fv_it)
980 case FACE_NORMALS_COLORS:
984 glBegin(GL_TRIANGLES);
985 for (; f_it!=f_end; ++f_it)
990 fv_it=
mesh_.cfv_iter(*f_it);
999 for (; f_it!=f_end; ++f_it)
1001 glBegin(GL_POLYGON);
1004 for (fv_it=
mesh_.cfv_iter(*f_it); fv_it.is_valid(); ++fv_it)
1016 case FACE_HALFEDGE_TEXTURED:
1022 if ( !
mesh_.get_property_handle(texture_index_property,indexPropertyName_) ) {
1023 if( indexPropertyName_ !=
"No Texture Index")
1024 std::cerr <<
"Unable to get per face texture Index property named " << indexPropertyName_ << std::endl;
1025 if ( !
mesh_.get_property_handle(texture_index_property,
"f:textureindex") ) {
1026 std::cerr <<
"Unable to get standard per face texture Index property" << std::endl;
1027 texture_index_property.
reset();
1040 if ( !
mesh_.get_property_handle(texture_coord_property,default_halfedge_textcoord_property_) ) {
1041 std::cerr <<
"Error: Unable to get per face texture coordinate property named " 1042 << default_halfedge_textcoord_property_ << std::endl;
1043 std::cerr <<
"Unable to texture without texture coordinates" << std::endl;
1049 glBegin(GL_TRIANGLES);
1050 for (; f_it!=f_end; ++f_it) {
1052 for (fh_it =
mesh_.cfh_iter(*f_it);fh_it.is_valid();++fh_it)
1054 point =
mesh_.point(
mesh_.to_vertex_handle(*fh_it));
1055 tex2d =
mesh_.property(texture_coord_property,*fh_it);
1056 glTexCoord2f(tex2d[0], tex2d[1]);
1064 int last_texture = -1;
1069 for (; f_it!=f_end; ++f_it)
1071 int texture =
mesh_.property(texture_index_property,*f_it);
1076 if ( last_texture != texture ) {
1079 std::cerr <<
"Illegal texture index ... trying to access " << texture << std::endl;
1085 if ( !propertyMap_ || !
mesh_.get_property_handle(texture_coord_property,(*propertyMap_)[texture]) ) {
1087 std::cerr <<
"Error: Unable to get per face texture coordinate property named " 1088 << (*propertyMap_)[texture] << std::endl;
1089 if ( !
mesh_.get_property_handle(texture_coord_property,
"h:texcoords2D") ) {
1090 std::cerr <<
"Fallback: Unable to get standard Property for per halfedge texcoords" << std::endl;
1091 std::cerr <<
"Unable to texture face without texture coordinates" << std::endl;
1100 last_texture = texture;
1104 glBegin(GL_TRIANGLES);
1109 for (fh_it =
mesh_.cfh_iter(*f_it);fh_it.is_valid();++fh_it)
1111 point =
mesh_.point(
mesh_.to_vertex_handle(*fh_it));
1112 tex2d =
mesh_.property(texture_coord_property,*fh_it);
1113 glTexCoord2f(tex2d[0], tex2d[1]);
1135 if (!indices_.empty())
1139 if ( faceIndexBufferInitialized_ ) {
1145 glDrawElements(GL_TRIANGLES,
1155 glDrawElements(GL_TRIANGLES,
1167 glBegin(GL_TRIANGLES);
1168 for (; f_it!=f_end; ++f_it)
1171 fv_it=
mesh_.cfv_iter(*f_it);
1172 glArrayElement(fv_it->idx()); ++fv_it;
1173 glArrayElement(fv_it->idx()); ++fv_it;
1174 glArrayElement(fv_it->idx());
1181 for (; f_it!=f_end; ++f_it)
1183 glBegin(GL_POLYGON);
1184 for (fv_it=
mesh_.cfv_iter(*f_it); fv_it.is_valid(); ++fv_it)
1185 glArrayElement(fv_it->idx());
1198 template<
class Mesh>
1200 MeshNodeDeprecatedT<Mesh>::
1248 template<
class Mesh>
1250 MeshNodeDeprecatedT<Mesh>::
1251 pick_vertices(GLState& _state,
bool _front)
1253 GLenum prev_depth = _state.depthFunc();
1255 typename Mesh::ConstVertexIter v_it(
mesh_.vertices_begin()),
1256 v_end(
mesh_.vertices_end());
1259 if (!_state.pick_set_maximum (
mesh_.n_vertices()))
1261 omerr() <<
"MeshNode::pick_vertices: color range too small, " 1262 <<
"picking failed\n";
1270 Vec4f clear_color = _state.clear_color();
1271 Vec4f base_color = _state.base_color();
1272 clear_color[3] = 1.0;
1274 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1275 _state.set_base_color(clear_color);
1281 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
1283 _state.set_base_color(base_color);
1285 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1291 if (vertexList_ && !updateVertexList_ && _state.pick_current_index () == vertexBaseIndex_)
1293 glCallList (vertexList_);
1300 glNewList (vertexList_, GL_COMPILE);
1301 updateVertexList_ =
false;
1302 vertexBaseIndex_ = _state.pick_current_index ();
1305 if (_state.color_picking ())
1307 update_pick_buffers ();
1309 for (; v_it!=v_end; ++v_it, ++idx)
1311 pickColorBuf_[idx] = _state.pick_get_name_color (idx);
1312 pickVertexBuf_[idx] =
mesh_.point(*v_it);
1321 glDrawArrays(GL_POINTS, 0,
mesh_.n_vertices());
1328 for (; v_it!=v_end; ++v_it, ++idx)
1330 _state.pick_set_name (idx);
1340 glCallList (vertexList_);
1350 template<
class Mesh>
1352 MeshNodeDeprecatedT<Mesh>::
1353 pick_faces(GLState& _state)
1355 typename Mesh::ConstFaceIter f_it(
mesh_.faces_sbegin()),
1356 f_end(
mesh_.faces_end());
1360 if (
mesh_.n_faces() > 0 )
1362 if (!_state.pick_set_maximum (
mesh_.n_faces()))
1364 omerr() <<
"MeshNode::pick_faces: color range too small, " 1365 <<
"picking failed\n";
1371 if (!_state.pick_set_maximum (1))
1373 omerr() <<
"Strange pickSetMAximum failed for index 1 in MeshNode\n";
1378 if (faceList_ && !updateFaceList_ && _state.pick_current_index () == faceBaseIndex_)
1380 glCallList (faceList_);
1386 glNewList (faceList_, GL_COMPILE);
1387 updateFaceList_ =
false;
1388 faceBaseIndex_ = _state.pick_current_index ();
1391 if (_state.color_picking ())
1393 update_pick_buffers ();
1394 unsigned int idx = 0;
1398 for (; f_it!=f_end; ++f_it)
1400 pickColorBuf_[idx] = _state.pick_get_name_color (f_it->idx());
1401 pickColorBuf_[idx+1] = _state.pick_get_name_color (f_it->idx());
1402 pickColorBuf_[idx+2] = _state.pick_get_name_color (f_it->idx());
1404 fv_it=
mesh_.cfv_iter(*f_it);
1405 pickVertexBuf_[idx] =
mesh_.point(*fv_it); ++fv_it;
1406 pickVertexBuf_[idx+1] =
mesh_.point(*fv_it); ++fv_it;
1407 pickVertexBuf_[idx+2] =
mesh_.point(*fv_it);
1417 glDrawArrays(GL_TRIANGLES, 0,
mesh_.n_faces() * 3);
1425 unsigned int face = 0;
1426 std::vector <GLint> first;
1427 std::vector <GLsizei> count;
1429 first.resize (
mesh_.n_faces());
1430 count.resize (
mesh_.n_faces());
1432 for (; f_it!=f_end; ++f_it, ++face)
1434 unsigned int cnt = 0;
1438 for (fv_it=
mesh_.cfv_iter(*f_it); fv_it.is_valid(); ++fv_it, ++idx, ++cnt)
1440 pickVertexBuf_[idx] =
mesh_.point(*fv_it);
1441 pickColorBuf_[idx] = _state.pick_get_name_color (f_it->idx());
1451 glMultiDrawArrays(GL_POLYGON, &first[0], &count[0],
mesh_.n_faces());
1462 for (; f_it!=f_end; ++f_it)
1465 _state.pick_set_name (f_it->idx());
1467 glBegin(GL_TRIANGLES);
1469 fv_it=
mesh_.cfv_iter(*f_it);
1478 for (; f_it!=f_end; ++f_it)
1481 _state.pick_set_name (f_it->idx());
1483 glBegin(GL_POLYGON);
1485 for (fv_it=
mesh_.cfv_iter(*f_it); fv_it.is_valid(); ++fv_it)
1496 glCallList (faceList_);
1503 template<
class Mesh>
1505 MeshNodeDeprecatedT<Mesh>::
1506 pick_edges(GLState& _state,
bool _front)
1508 typename Mesh::ConstEdgeIter e_it(
mesh_.edges_sbegin()),
1509 e_end(
mesh_.edges_end());
1511 GLenum prev_depth = _state.depthFunc();
1513 if (!_state.pick_set_maximum (
mesh_.n_edges()))
1515 omerr() <<
"MeshNode::pick_edges: color range too small, " 1516 <<
"picking failed\n";
1524 Vec4f clear_color = _state.clear_color();
1525 Vec4f base_color = _state.base_color();
1526 clear_color[3] = 1.0;
1528 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1529 _state.set_base_color(clear_color);
1535 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
1537 _state.set_base_color(base_color);
1539 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1544 if (edgeList_ && !updateEdgeList_ && _state.pick_current_index () == edgeBaseIndex_)
1546 glCallList (edgeList_);
1553 glNewList (edgeList_, GL_COMPILE);
1554 updateEdgeList_ =
false;
1555 edgeBaseIndex_ = _state.pick_current_index ();
1558 if (_state.color_picking ())
1560 unsigned int idx = 0;
1561 update_pick_buffers ();
1563 for (; e_it!=e_end; ++e_it)
1565 pickColorBuf_[idx] = _state.pick_get_name_color (e_it->idx());
1566 pickColorBuf_[idx+1] = _state.pick_get_name_color (e_it->idx());
1567 pickVertexBuf_[idx] =
mesh_.point(
mesh_.to_vertex_handle(
mesh_.halfedge_handle(*e_it, 0)));
1568 pickVertexBuf_[idx+1] =
mesh_.point(
mesh_.to_vertex_handle(
mesh_.halfedge_handle(*e_it, 1)));
1578 glDrawArrays(GL_LINES, 0,
mesh_.n_edges() * 2);
1585 for (; e_it!=e_end; ++e_it)
1587 _state.pick_set_name (e_it->idx());
1598 glCallList (edgeList_);
1607 template<
class Mesh>
1609 MeshNodeDeprecatedT<Mesh>::
1610 pick_any(GLState& _state)
1612 GLenum prev_depth = _state.depthFunc();
1614 unsigned int numElements =
mesh_.n_faces() +
mesh_.n_edges() +
mesh_.n_vertices();
1617 if (numElements == 0)
1620 if (!_state.pick_set_maximum (numElements))
1622 omerr() <<
"MeshNode::pick_any: color range too small, " 1623 <<
"picking failed\n";
1627 if (anyList_ && !updateAnyList_ && _state.pick_current_index () == anyBaseIndex_)
1629 glCallList (anyList_);
1630 glCallList (anyList_+1);
1631 glCallList (anyList_+2);
1637 glNewList (anyList_, GL_COMPILE);
1638 updateAnyList_ =
false;
1639 anyBaseIndex_ = _state.pick_current_index ();
1643 typename Mesh::ConstFaceIter f_it(
mesh_.faces_sbegin()),
1644 f_end(
mesh_.faces_end());
1648 typename Mesh::ConstEdgeIter e_it(
mesh_.edges_sbegin()),
1649 e_end(
mesh_.edges_end());
1652 typename Mesh::ConstVertexIter v_it(
mesh_.vertices_begin()),
1653 v_end(
mesh_.vertices_end());
1654 GLuint vidx(
mesh_.n_faces() +
mesh_.n_edges());
1658 if (_state.color_picking ())
1660 update_pick_buffers ();
1666 unsigned int idx = 0;
1669 for (; f_it!=f_end; ++f_it)
1671 pickColorBuf_[idx] = _state.pick_get_name_color (f_it->idx());
1672 pickColorBuf_[idx+1] = _state.pick_get_name_color (f_it->idx());
1673 pickColorBuf_[idx+2] = _state.pick_get_name_color (f_it->idx());
1675 fv_it=
mesh_.cfv_iter(*f_it);
1676 pickVertexBuf_[idx] =
mesh_.point(*fv_it); ++fv_it;
1677 pickVertexBuf_[idx+1] =
mesh_.point(*fv_it); ++fv_it;
1678 pickVertexBuf_[idx+2] =
mesh_.point(*fv_it);
1685 glDrawArrays(GL_TRIANGLES, 0,
mesh_.n_faces() * 3);
1690 unsigned int face = 0;
1691 std::vector <GLint> first;
1692 std::vector <GLsizei> count;
1694 first.resize (
mesh_.n_faces());
1695 count.resize (
mesh_.n_faces());
1697 for (; f_it!=f_end; ++f_it, ++face)
1699 unsigned int cnt = 0;
1703 for (fv_it=
mesh_.cfv_iter(*f_it); fv_it.is_valid(); ++fv_it, ++idx, ++cnt)
1705 pickVertexBuf_[idx] =
mesh_.point(*fv_it);
1706 pickColorBuf_[idx] = _state.pick_get_name_color (f_it->idx());
1714 glMultiDrawArrays(GL_POLYGON, &first[0], &count[0],
mesh_.n_faces());
1721 glNewList (anyList_+1, GL_COMPILE);
1728 for (; e_it!=e_end; ++e_it)
1730 pickColorBuf_[idx] = _state.pick_get_name_color (
mesh_.n_faces() + e_it->idx());
1731 pickColorBuf_[idx+1] = _state.pick_get_name_color (
mesh_.n_faces() + e_it->idx());
1732 pickVertexBuf_[idx] =
mesh_.point(
mesh_.to_vertex_handle(
mesh_.halfedge_handle(*e_it, 0)));
1733 pickVertexBuf_[idx+1] =
mesh_.point(
mesh_.to_vertex_handle(
mesh_.halfedge_handle(*e_it, 1)));
1740 glDrawArrays(GL_LINES, 0,
mesh_.n_edges() * 2);
1746 glNewList (anyList_+2, GL_COMPILE);
1752 for (; v_it!=v_end; ++v_it, ++idx, ++vidx)
1754 pickColorBuf_[idx] = _state.pick_get_name_color (vidx);
1755 pickVertexBuf_[idx] =
mesh_.point(*v_it);
1761 glDrawArrays(GL_POINTS, 0,
mesh_.n_vertices());
1771 for (; f_it!=f_end; ++f_it)
1774 _state.pick_set_name (f_it->idx());
1776 glBegin(GL_TRIANGLES);
1778 fv_it=
mesh_.cfv_iter(*f_it);
1787 for (; f_it!=f_end; ++f_it)
1790 _state.pick_set_name (f_it->idx());
1792 glBegin(GL_POLYGON);
1794 for (fv_it=
mesh_.cfv_iter(*f_it); fv_it.is_valid(); ++fv_it)
1805 glNewList (anyList_+1, GL_COMPILE);
1811 for (; e_it!=e_end; ++e_it)
1813 _state.pick_set_name (
mesh_.n_faces() + e_it->idx());
1824 glNewList (anyList_+2, GL_COMPILE);
1829 for (; v_it!=v_end; ++v_it, ++vidx)
1831 _state.pick_set_name (vidx);
1843 glCallList (anyList_);
1844 glCallList (anyList_+1);
1845 glCallList (anyList_+2);
1851 template<
class Mesh>
1853 MeshNodeDeprecatedT<Mesh>::
1854 update_pick_buffers ()
1856 unsigned int nfv = 0;
1858 nfv =
mesh_.n_faces() * 3;
1862 typename Mesh::ConstFaceIter f_it(
mesh_.faces_sbegin()),
1863 f_end(
mesh_.faces_end());
1865 for (; f_it!=f_end; ++f_it)
1867 for (fv_it=
mesh_.cfv_iter(*f_it); fv_it.is_valid(); ++fv_it)
1872 pickVertexBuf_.resize (std::max(
mesh_.n_vertices(), std::max(
mesh_.n_edges() * 2, size_t(nfv))));
1873 pickColorBuf_.resize (std::max(
mesh_.n_vertices(), std::max(
mesh_.n_edges() * 2, size_t(nfv))));
1879 #endif // DOXY_IGNORE_THIS DrawMode SOLID_SMOOTH_SHADED
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
DrawMode SOLID_PHONG_SHADED
draw phong shaded faces
DrawMode WIREFRAME
draw wireframe
Namespace providing different geometric functions concerning angles.
void draw_vertices()
draws all vertices of the mesh
static void normalPointer(GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glNormalPointer, supports locking
DrawMode POINTS_SHADED
draw shaded points (requires point normals)
DrawMode SOLID_3DTEXTURED_SHADED
draw smooth shaded textured faces
std::map< int, GLuint > * textureMap_
Mapping of mesh face texture indices to gltexture id ( has to be provided externally ) ...
Kernel::ConstFaceVertexIter ConstFaceVertexIter
Circulator.
pick any of the prior targets (should be implemented for all nodes)
static void colorPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glColorPointer, supports locking
Kernel::Point Point
Coordinate type.
DrawMode SOLID_1DTEXTURED_SHADED
draw smooth shaded textured faces
DrawMode POINTS_COLORED
draw colored, but not lighted points (requires point colors)
DrawMode SOLID_ENV_MAPPED
draw environment mapped
static void enable(GLenum _cap, bool _warnRemoved=true)
replaces glEnable, but supports locking
DrawMode SOLID_1DTEXTURED
draw textured faces
VectorT< float, 4 > Vec4f
static void bindBufferARB(GLenum _target, GLuint _buffer)
same function as bindBuffer
Kernel::ConstFaceHalfedgeIter ConstFaceHalfedgeIter
Circulator.
static void disable(GLenum _cap, bool _warnRemoved=true)
replaces glDisable, but supports locking
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
void pick_edges(GLState &_state, bool _front=false)
Renders picking for edges _front: Only render front edges (not occluded by geometry) ...
Mesh & mesh_
The mesh this node works on.
static constexpr bool is_trimesh()
Determine whether this is a PolyMeshT or TriMeshT (This function does not check the per face vertex c...
void glNormal(const Vec3f &_n)
Wrapper: glNormal for Vec3f.
void glVertex(const Vec2i &_v)
Wrapper: glVertex for Vec2i.
Kernel::TexCoord2D TexCoord2D
TexCoord2D type.
void pick_faces(GLState &_state)
Renders picking for faces _front: Only render front faces (not occluded by geometry) ...
DrawMode SOLID_POINTS_COLORED
draw colored, but not lighted faces using interpolated vertex colors
static void vertexPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glVertexPointer, supports locking
Vec3d bbMin_
bounding box lower left corner
DrawMode HIDDENLINE
draw hidden line (2 rendering passes needed)
static void disableClientState(GLenum _cap)
replaces glDisableClientState, supports locking
void pick_any(GLState &_state)
Renders picking for all primitives.
VectorT< double, 3 > Vec3d
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
Kernel::Normal Normal
Normal type.
unsigned int enabled_arrays_
which arrays are currently enabled?
DrawMode NONE
not a valid draw mode
DrawMode SOLID_TEXTURED_SHADED
draw smooth shaded textured faces
static void enableClientState(GLenum _cap)
replaces glEnableClientState, supports locking
static void bindTexture(GLenum _target, GLuint _buffer)
replaces glBindTexture, supports locking
picks edges (may not be implemented for all nodes)
DrawMode SOLID_2DTEXTURED_FACE
draw per halfedge textured faces
void pick_vertices(GLState &_state, bool _front=false)
Renders picking for vertices _front: Only render front vertices (not occluded by geometry) ...
void enable_arrays(unsigned int _arrays)
enable/disable vertex arrays according to the bits in _arrays
Vec3d bbMax_
bounding box upper right corner
DrawMode SOLID_3DTEXTURED
draw textured faces
PickTarget
What target to use for picking.
DrawMode SOLID_FACES_COLORED
draw colored, but not lighted faces using face colors
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
picks only visible front verices (may not be implemented for all nodes)
DrawMode SOLID_2DTEXTURED_FACE_SHADED
draw per halfedge textured faces
picks faces (should be implemented for all nodes)
bool is_valid() const
The handle is valid iff the index is not negative.
const GLenum & depthFunc() const
get glDepthFunc() that is supposed to be active
static void texcoordPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glTexcoordPointer, supports locking
DrawMode SOLID_TEXTURED
draw textured faces
void glColor(const Vec3f &_v)
Wrapper: glColor for Vec3f.
picks verices (may not be implemented for all nodes)
DrawMode POINTS
draw unlighted points using the default base color
void reset()
reset handle to be invalid
DrawMode SOLID_FACES_COLORED_FLAT_SHADED
draw flat shaded and colored faces (requires face normals and colors)
void draw_faces()
draws all faces of the mesh
picks only visible front edges (may not be implemented for all nodes)