27 : m_enable_lighting(false),
28 m_enable_cube_transparency(true),
29 m_showVoxelsAsPoints(false),
30 m_showVoxelsAsPointsSize(3.0f),
33 m_grid_color(0xE0, 0xE0, 0xE0, 0x90),
54 #if MRPT_HAS_OPENGL_GLUT
69 const GLubyte grid_line_indices[] = {0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,
70 6, 7, 7, 4, 0, 5, 1, 6, 2, 7, 3, 4};
72 const GLubyte cube_indices[36] = {0, 1, 2, 2, 3, 0, 0, 3, 4, 4, 5, 0,
73 0, 5, 6, 6, 1, 0, 1, 6, 7, 7, 2, 1,
74 7, 4, 3, 3, 2, 7, 4, 7, 6, 6, 5, 4};
77 const GLfloat normals_cube[3 * 6 * 4] = {
78 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0,
79 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
80 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
81 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0,
82 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1,
83 -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0};
92 #if MRPT_HAS_OPENGL_GLUT
107 if (m_grid_color.A != 255)
114 m_grid_color.R, m_grid_color.G, m_grid_color.B, m_grid_color.A);
116 const size_t nGrids = m_grid_cubes.size();
117 for (
size_t i = 0; i < nGrids; i++)
122 c.
max.
x,
c.max.y,
c.max.z,
c.max.x,
c.min.y,
c.max.z,
123 c.max.x,
c.min.y,
c.min.z,
c.max.x,
c.max.y,
c.min.z,
124 c.min.x,
c.max.y,
c.min.z,
c.min.x,
c.max.y,
c.max.z,
125 c.min.x,
c.min.y,
c.max.z,
c.min.x,
c.min.y,
c.min.z};
129 sizeof(grid_line_indices) /
sizeof(grid_line_indices[0]),
145 if (m_enable_cube_transparency)
151 if (m_showVoxelsAsPoints)
157 for (
size_t i = 0; i < m_voxel_sets.size(); i++)
159 if (!m_voxel_sets[i].visible)
continue;
161 const std::vector<TVoxel>& voxels = m_voxel_sets[i].voxels;
162 const size_t N = voxels.size();
163 for (
size_t j = 0; j < N; j++)
169 const double L = voxels[j].side_length * 0.5;
171 if (!m_showVoxelsAsPoints)
175 c.
x + L,
c.y + L,
c.z + L,
c.x + L,
c.y - L,
c.z + L,
176 c.x + L,
c.y - L,
c.z - L,
c.x + L,
c.y + L,
c.z - L,
177 c.x - L,
c.y + L,
c.z - L,
c.x - L,
c.y + L,
c.z + L,
178 c.x - L,
c.y - L,
c.z + L,
c.x - L,
c.y - L,
c.z - L};
182 sizeof(cube_indices) /
sizeof(cube_indices[0]),
193 if (m_showVoxelsAsPoints)
221 out <<
a.visible <<
a.voxels;
227 in >>
a.visible >>
a.voxels;
234 out <<
a.min <<
a.max;
239 in >>
a.min >>
a.max;
245 out <<
a.coords <<
a.side_length <<
a.color;
250 in >>
a.coords >>
a.side_length >>
a.color;
267 writeToStreamRender(out);
269 out << m_voxel_sets << m_grid_cubes << m_bb_min << m_bb_max
270 << m_enable_lighting << m_showVoxelsAsPoints
271 << m_showVoxelsAsPointsSize << m_show_grids << m_grid_width
272 << m_grid_color << m_enable_cube_transparency
289 readFromStreamRender(
in);
291 in >> m_voxel_sets >> m_grid_cubes >> m_bb_min >> m_bb_max >>
292 m_enable_lighting >> m_showVoxelsAsPoints >>
293 m_showVoxelsAsPointsSize >> m_show_grids >> m_grid_width >>
297 in >> m_enable_cube_transparency;
299 m_enable_cube_transparency =
false;
326 m_pose.composePoint(bb_min, bb_min);
327 m_pose.composePoint(bb_max, bb_max);
333 return a.coords.z <
b.coords.z;
338 for (
size_t i = 0; i < m_voxel_sets.size(); i++)
341 m_voxel_sets[i].voxels.begin(), m_voxel_sets[i].voxels.end(),
bool sort_voxels_z(const COctoMapVoxels::TVoxel &a, const COctoMapVoxels::TVoxel &b)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
#define DECLARE_CUSTOM_TTYPENAME(_TYPE)
Identical to MRPT_DECLARE_TTYPENAME but intended for user code.
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
void clear()
Clears everything.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
void setBoundingBox(const mrpt::math::TPoint3D &bb_min, const mrpt::math::TPoint3D &bb_max)
Manually changes the bounding box (normally the user doesn't need to call this)
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
visualization_mode_t
The different coloring schemes, which modulate the generic mrpt::opengl::CRenderizable object color.
@ COLOR_FROM_OCCUPANCY
Color goes from black (occupied voxel) to the chosen color (free voxel)
void render_dl() const override
Render.
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)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
GLAPI void GLAPIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glPointSize(GLfloat size)
GLAPI void GLAPIENTRY glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
GLAPI void GLAPIENTRY glEnableClientState(GLenum array)
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
#define GL_COLOR_BUFFER_BIT
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
#define GL_ONE_MINUS_SRC_ALPHA
GLAPI void GLAPIENTRY glEnd(void)
GLAPI void GLAPIENTRY glPopAttrib(void)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
GLAPI void GLAPIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask)
GLAPI void GLAPIENTRY glDisableClientState(GLenum array)
GLubyte GLubyte GLubyte a
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
This base provides a set of functions for maths stuff.
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
The namespace for 3D scene representation and rendering.
mrpt::utils::CStream & operator<<(mrpt::utils::CStream &out, const mrpt::opengl::CLight &o)
mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, mrpt::opengl::CLight &o)
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.
unsigned __int32 uint32_t
double x
X,Y,Z coordinates.
The info of each grid block.
The info of each of the voxels.