27 CMesh3DPtr
CMesh3D::Create(
bool enableTransparency,
bool enableShowEdges,
bool enableShowFaces,
bool enableShowVertices)
29 return CMesh3DPtr(
new CMesh3D(enableTransparency, enableShowEdges, enableShowFaces, enableShowVertices));
32 CMesh3D::CMesh3D(
bool enableTransparency,
bool antiAliasing ,
bool enableShowEdges ,
bool enableShowFaces,
bool enableShowVertices ) :
33 m_enableTransparency(enableTransparency),
34 m_antiAliasing(antiAliasing),
35 m_showEdges(enableShowEdges),
36 m_showFaces(enableShowFaces),
37 m_showVertices(enableShowVertices),
38 m_computeNormals(true),
55 void CMesh3D::loadMesh(
unsigned int num_verts,
unsigned int num_faces,
int *verts_per_face,
int *face_verts,
float *vert_coords)
62 for (
unsigned int i = 0; i < num_faces; i++)
64 if (verts_per_face[i] == 3)
66 else if (verts_per_face[i] == 4)
70 printf(
"\n Incorrect mesh format. It can only be composed of triangles and/or quads.");
77 unsigned int count = 0;
78 for (
unsigned int f = 0; f < num_faces; f++)
91 for (
unsigned int i = 0; i < num_verts; i++)
103 for (
unsigned int f = 0; f < num_faces; f++)
114 m_normals[f][0] = vec1[1] * vec2[2] - vec1[2] * vec2[1];
115 m_normals[f][1] = vec1[2] * vec2[0] - vec1[0] * vec2[2];
116 m_normals[f][2] = vec1[0] * vec2[1] - vec1[1] * vec2[0];
122 m_normals[f][0] = vec1[1] * vec2[2] - vec1[2] * vec2[1];
123 m_normals[f][1] = vec1[2] * vec2[0] - vec1[0] * vec2[2];
124 m_normals[f][2] = vec1[0] * vec2[1] - vec1[1] * vec2[0];
132 void CMesh3D::loadMesh(
unsigned int num_verts,
unsigned int num_faces,
const Array<bool, 1, Dynamic> &is_quad,
const Array<int, 4, Dynamic> &face_verts,
const Array<float, 3, Dynamic> &vert_coords)
139 for (
unsigned int i = 0; i < num_faces; i++)
144 for (
unsigned int f = 0; f < num_faces; f++)
157 for (
unsigned int i = 0; i < num_verts; i++)
167 for (
unsigned int f = 0; f < num_faces; f++)
178 m_normals[f][0] = vec1[1] * vec2[2] - vec1[2] * vec2[1];
179 m_normals[f][1] = vec1[2] * vec2[0] - vec1[0] * vec2[2];
180 m_normals[f][2] = vec1[0] * vec2[1] - vec1[1] * vec2[0];
186 m_normals[f][0] = vec1[1] * vec2[2] - vec1[2] * vec2[1];
187 m_normals[f][1] = vec1[2] * vec2[0] - vec1[0] * vec2[2];
188 m_normals[f][2] = vec1[0] * vec2[1] - vec1[1] * vec2[0];
201 #if MRPT_HAS_OPENGL_GLUT 240 for (
int i = 0; i < 4; i++)
251 for (
int i = 0; i < 3; i++)
271 const unsigned char num_vert = 3 +
m_is_quad[f];
272 for (
int i = 0; i < num_vert - 1; i++)
386 bb_min.
x = 10000.f; bb_min.
y = 10000.f; bb_min.
z = 10000.f;
387 bb_max.
x = -10000.f; bb_max.
y = -10000.f; bb_max.
z = -10000.f;
390 printf(
"\n The mesh is empty and has no size. The returned information has no meaning.");
GLuint GLuint GLsizei count
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glPointSize(GLfloat size)
unsigned int m_num_verts
Number of vertices of the mesh.
float face_color[4]
Color of the faces (when shown)
#define THROW_EXCEPTION(msg)
GLAPI void GLAPIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
#define GL_ONE_MINUS_SRC_ALPHA
double z
X,Y,Z coordinates.
#define GL_COLOR_MATERIAL
A 3D mesh composed of Triangles and/or Quads.
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
GLAPI void GLAPIENTRY glShadeModel(GLenum mode)
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference. This class automatically holds the cached 3x3 rotation m...
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
A renderizable object suitable for rendering with OpenGL's display lists.
bool m_enableTransparency
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=NULL, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
void setVertColor(float r, float g, float b, float a=1.f)
This base provides a set of functions for maths stuff.
CMesh3D(bool enableTransparency=false, bool antiAliasing=false, bool enableShowEdges=true, bool enableShowFaces=true, bool enableShowVertices=false)
Constructor.
GLfloat GLfloat GLfloat GLfloat v3
mrpt::utils::TColor m_color
Color components in the range [0,255].
GLAPI void GLAPIENTRY glBegin(GLenum mode)
void loadMesh(unsigned int num_verts, unsigned int num_faces, int *verts_per_face, int *face_verts, float *vert_coords)
Load a 3D mesh.
unsigned int m_num_faces
Number of faces of the mesh.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
void setFaceColor(float r, float g, float b, float a=1.f)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void render_dl() const MRPT_OVERRIDE
Render.
GLdouble GLdouble GLdouble r
virtual ~CMesh3D()
Private, virtual destructor: only can be deleted from smart pointers.
The namespace for 3D scene representation and rendering.
GLAPI void GLAPIENTRY glEnd(void)
bool * m_is_quad
Pointer storing whether a face is a quad (1) or a triangle (0)
coord3D * m_normals
Pointer storing the face normals. Size: 3 x num_faces.
GLfloat GLfloat GLfloat v2
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
float vert_color[4]
Color of the vertices (when shown)
void setEdgeColor(float r, float g, float b, float a=1.f)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLubyte GLubyte GLubyte a
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
coord3D * m_vert_coords
Pointer storing the coordinates of the vertices. Size: 3 x num_vertices.
f_verts * m_face_verts
Pointer storing the vertices that compose each face. Size: 4 x num_faces (4 for the possible max numb...
float edge_color[4]
Color of the edges (when shown)