38 #include <geometric_shapes/shapes.h> 
   40 #include <Eigen/Eigen> 
   43 using namespace Eigen;
 
   48   if (!mesh.vertex_normals)
 
   49     throw std::runtime_error(
"Vertex normals are not computed for input mesh. Call computeVertexNormals() before " 
   50                              "passing as input to mesh_filter.");
 
   52   mesh_label_ = mesh_label;
 
   53   list_ = glGenLists(1);
 
   54   glNewList(list_, GL_COMPILE);
 
   55   glBegin(GL_TRIANGLES);
 
   56   glColor4ubv((GLubyte*)&mesh_label_);
 
   57   for (
unsigned t_idx = 0; t_idx < mesh.triangle_count; ++t_idx)
 
   59     unsigned v1 = 3 * mesh.triangles[3 * t_idx];
 
   60     unsigned v2 = 3 * mesh.triangles[3 * t_idx + 1];
 
   61     unsigned v3 = 3 * mesh.triangles[3 * t_idx + 2];
 
   63     glNormal3f(mesh.vertex_normals[v1], mesh.vertex_normals[v1 + 1], mesh.vertex_normals[v1 + 2]);
 
   64     glVertex3f(mesh.vertices[v1], mesh.vertices[v1 + 1], mesh.vertices[v1 + 2]);
 
   66     glNormal3f(mesh.vertex_normals[v2], mesh.vertex_normals[v2 + 1], mesh.vertex_normals[v2 + 2]);
 
   67     glVertex3f(mesh.vertices[v2], mesh.vertices[v2 + 1], mesh.vertices[v2 + 2]);
 
   69     glNormal3f(mesh.vertex_normals[v3], mesh.vertex_normals[v3 + 1], mesh.vertex_normals[v3 + 2]);
 
   70     glVertex3f(mesh.vertices[v3], mesh.vertices[v3 + 1], mesh.vertices[v3 + 2]);
 
   78   glDeleteLists(list_, 1);
 
   83   glMatrixMode(GL_MODELVIEW);
 
   85   if (!(transform.matrix().Flags & RowMajorBit))
 
   86     glMultMatrixd(transform.matrix().data());
 
   88     glMultTransposeMatrixd(transform.matrix().data());
 
void render(const Eigen::Isometry3d &transform) const
renders the mesh in current OpenGL frame buffer (context)
 
GLMesh(const shapes::Mesh &mesh, unsigned int mesh_label)
Constructs a GLMesh object for given mesh and label.