42 #if MRPT_HAS_OPENGL_GLUT 57 const GLubyte grid_line_indices[] = {0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,
58 6, 7, 7, 4, 0, 5, 1, 6, 2, 7, 3, 4};
60 const GLubyte cube_indices[36] = {0, 1, 2, 2, 3, 0, 0, 3, 4, 4, 5, 0,
61 0, 5, 6, 6, 1, 0, 1, 6, 7, 7, 2, 1,
62 7, 4, 3, 3, 2, 7, 4, 7, 6, 6, 5, 4};
65 const GLfloat normals_cube[3 * 6 * 4] = {
66 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0,
67 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
68 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
69 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0,
70 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1,
71 -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0};
80 #if MRPT_HAS_OPENGL_GLUT 95 if (m_grid_color.A != 255)
102 m_grid_color.R, m_grid_color.G, m_grid_color.B, m_grid_color.A);
104 const size_t nGrids = m_grid_cubes.size();
105 for (
size_t i = 0; i < nGrids; i++)
110 c.
max.
x,
c.max.y,
c.max.z,
c.max.x,
c.min.y,
c.max.z,
111 c.max.x,
c.min.y,
c.min.z,
c.max.x,
c.max.y,
c.min.z,
112 c.min.x,
c.max.y,
c.min.z,
c.min.x,
c.max.y,
c.max.z,
113 c.min.x,
c.min.y,
c.max.z,
c.min.x,
c.min.y,
c.min.z};
117 sizeof(grid_line_indices) /
sizeof(grid_line_indices[0]),
133 if (m_enable_cube_transparency)
139 if (m_showVoxelsAsPoints)
145 for (
const auto& m_voxel_set : m_voxel_sets)
147 if (!m_voxel_set.visible)
continue;
149 const std::vector<TVoxel>& voxels = m_voxel_set.voxels;
150 const size_t N = voxels.size();
151 for (
size_t j = 0; j < N; j++)
157 const double L = voxels[j].side_length * 0.5;
159 if (!m_showVoxelsAsPoints)
163 c.x + L,
c.y + L,
c.z + L,
c.x + L,
c.y - L,
c.z + L,
164 c.x + L,
c.y - L,
c.z - L,
c.x + L,
c.y + L,
c.z - L,
165 c.x - L,
c.y + L,
c.z - L,
c.x - L,
c.y + L,
c.z + L,
166 c.x - L,
c.y - L,
c.z + L,
c.x - L,
c.y - L,
c.z - L};
170 sizeof(cube_indices) /
sizeof(cube_indices[0]),
181 if (m_showVoxelsAsPoints)
207 out <<
a.visible <<
a.voxels;
212 in >>
a.visible >>
a.voxels;
218 out <<
a.min <<
a.max;
223 in >>
a.min >>
a.max;
229 out <<
a.coords <<
a.side_length <<
a.color;
234 in >>
a.coords >>
a.side_length >>
a.color;
242 writeToStreamRender(out);
244 out << m_voxel_sets << m_grid_cubes << m_bb_min << m_bb_max
245 << m_enable_lighting << m_showVoxelsAsPoints << m_showVoxelsAsPointsSize
246 << m_show_grids << m_grid_width << m_grid_color
247 << m_enable_cube_transparency
259 readFromStreamRender(
in);
261 in >> m_voxel_sets >> m_grid_cubes >> m_bb_min >> m_bb_max >>
262 m_enable_lighting >> m_showVoxelsAsPoints >>
263 m_showVoxelsAsPointsSize >> m_show_grids >> m_grid_width >>
267 in >> m_enable_cube_transparency;
269 m_enable_cube_transparency =
false;
303 return a.coords.z <
b.coords.z;
308 for (
auto& m_voxel_set : m_voxel_sets)
311 m_voxel_set.voxels.begin(), m_voxel_set.voxels.end(),
GLAPI void GLAPIENTRY glDisableClientState(GLenum array)
GLAPI void GLAPIENTRY glEnableClientState(GLenum array)
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
double x
X,Y,Z coordinates.
visualization_mode_t
The different coloring schemes, which modulate the generic mrpt::opengl::CRenderizable object color...
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glPointSize(GLfloat size)
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &out, const mrpt::opengl::CLight &o)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
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)
#define GL_ONE_MINUS_SRC_ALPHA
void clear()
Clears everything.
GLAPI void GLAPIENTRY glPopAttrib(void)
bool sort_voxels_z(const COctoMapVoxels::TVoxel &a, const COctoMapVoxels::TVoxel &b)
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
A renderizable object suitable for rendering with OpenGL's display lists.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
#define GL_COLOR_BUFFER_BIT
This base provides a set of functions for maths stuff.
void render_dl() const override
Render.
GLAPI void GLAPIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
The info of each grid block.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
GLAPI void GLAPIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
The info of each of the voxels.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Color goes from black (occupied voxel) to the chosen color (free voxel)
Virtual base class for "archives": classes abstracting I/O streams.
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...
GLAPI void GLAPIENTRY glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask)
#define DECLARE_CUSTOM_TTYPENAME(_TYPE)
Identical to MRPT_DECLARE_TTYPENAME but intended for user code.
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
The namespace for 3D scene representation and rendering.
GLAPI void GLAPIENTRY glEnd(void)
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, mrpt::opengl::CLight &o)
unsigned __int32 uint32_t
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLubyte GLubyte GLubyte a