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.");
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
A 3D mesh composed of Triangles and/or Quads.
unsigned int m_num_verts
Number of vertices of the mesh.
CMesh3D(bool enableTransparency=false, bool antiAliasing=false, bool enableShowEdges=true, bool enableShowFaces=true, bool enableShowVertices=false)
Constructor.
virtual ~CMesh3D()
Private, virtual destructor: only can be deleted from smart pointers
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...
void setFaceColor(float r, float g, float b, float a=1.f)
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
void render_dl() const MRPT_OVERRIDE
Render.
void loadMesh(unsigned int num_verts, unsigned int num_faces, int *verts_per_face, int *face_verts, float *vert_coords)
Load a 3D mesh.
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.
void setEdgeColor(float r, float g, float b, float a=1.f)
float edge_color[4]
Color of the edges (when shown)
coord3D * m_vert_coords
Pointer storing the coordinates of the vertices. Size: 3 x num_vertices.
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...
f_verts * m_face_verts
Pointer storing the vertices that compose each face. Size: 4 x num_faces (4 for the possible max numb...
bool m_enableTransparency
float face_color[4]
Color of the faces (when shown)
float vert_color[4]
Color of the vertices (when shown)
void setVertColor(float r, float g, float b, float a=1.f)
unsigned int m_num_faces
Number of faces of the mesh.
A renderizable object suitable for rendering with OpenGL's display lists.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference. This class automatically holds the cached 3x3 rotation m...
mrpt::utils::TColor m_color
Color components in the range [0,255].
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...
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glPointSize(GLfloat size)
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
GLAPI void GLAPIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
#define GL_COLOR_MATERIAL
#define GL_ONE_MINUS_SRC_ALPHA
GLAPI void GLAPIENTRY glEnd(void)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
GLAPI void GLAPIENTRY glShadeModel(GLenum mode)
GLuint GLuint GLsizei count
GLfloat GLfloat GLfloat v2
GLdouble GLdouble GLdouble r
GLubyte GLubyte GLubyte a
GLfloat GLfloat GLfloat GLfloat v3
@ cmHOT
[New in MRPT 1.5.0]
#define THROW_EXCEPTION(msg)
This base provides a set of functions for maths stuff.
The namespace for 3D scene representation and rendering.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double z
X,Y,Z coordinates.