77 static const uint8_t
grid_line_indices[] = {0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,
78 6, 7, 7, 4, 0, 5, 1, 6, 2, 7, 3, 4};
99 {0, -1, 0}, {0, -1, 0},
100 {0, 0, -1}, {0, 0, -1},
101 {-1, 0, 0}, {-1, 0, 0}};
111 const size_t nGrids = m_grid_cubes.size();
112 for (
size_t i = 0; i < nGrids; i++)
125 for (
size_t k = 0; k <
sizeof(gli) /
sizeof(gli[0]); k += 2)
127 vbd.emplace_back(vs[gli[k]]);
128 vbd.emplace_back(vs[gli[k + 1]]);
132 cbd.assign(vbd.size(), m_grid_color);
140 for (
const auto& m_voxel_set : m_voxel_sets)
142 if (!m_voxel_set.visible)
continue;
144 const std::vector<TVoxel>& voxels = m_voxel_set.voxels;
145 const size_t N = voxels.size();
146 for (
size_t j = 0; j < N; j++)
152 const float L = voxels[j].side_length * 0.5f;
156 {c.
x + L, c.
y + L, c.
z + L}, {c.
x + L, c.
y - L, c.
z + L},
157 {c.
x + L, c.
y - L, c.
z - L}, {c.
x + L, c.
y + L, c.
z - L},
158 {c.
x - L, c.
y + L, c.
z - L}, {c.
x - L, c.
y + L, c.
z + L},
159 {c.
x - L, c.
y - L, c.
z + L}, {c.
x - L, c.
y - L, c.
z - L}};
169 for (
size_t k = 0; k <
sizeof(ci) /
sizeof(ci[0]); k += 3)
173 vs[ci[k]], vs[ci[k + 1]], vs[ci[k + 2]],
175 ns[k / 3], ns[k / 3], ns[k / 3]);
177 for (
int p = 0; p < 3; p++)
185 tris.emplace_back(std::move(tri));
196 for (
const auto& m_voxel_set : m_voxel_sets)
198 if (!m_voxel_set.visible)
continue;
200 const std::vector<TVoxel>& voxels = m_voxel_set.voxels;
201 const size_t N = voxels.size();
202 for (
size_t j = 0; j < N; j++)
208 cbd.emplace_back(vx_j_col);
257 writeToStreamRender(
out);
259 out << m_voxel_sets << m_grid_cubes << m_bb_min << m_bb_max
260 << m_enable_lighting << m_showVoxelsAsPoints << m_showVoxelsAsPointsSize
261 << m_show_grids << m_grid_width << m_grid_color
262 << m_enable_cube_transparency
263 << uint32_t(m_visual_mode);
274 readFromStreamRender(in);
276 in >> m_voxel_sets >> m_grid_cubes >> m_bb_min >> m_bb_max >>
277 m_enable_lighting >> m_showVoxelsAsPoints >>
278 m_showVoxelsAsPointsSize >> m_show_grids >> m_grid_width >>
282 in >> m_enable_cube_transparency;
284 m_enable_cube_transparency =
false;
323 for (
auto& m_voxel_set : m_voxel_sets)
326 m_voxel_set.voxels.begin(), m_voxel_set.voxels.end(),
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.
std::vector< mrpt::math::TPoint3Df > m_vertex_buffer_data
visualization_mode_t
The different coloring schemes, which modulate the generic mrpt::opengl::CRenderizable object color...
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CPolyhedron::TPolyhedronEdge &o)
Reads a polyhedron edge from a binary stream.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
void onUpdateBuffers_Wireframe() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
A triangle (float coordinates) with RGBA colors (u8) and UV (texture coordinates) for each vertex...
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
mrpt::math::TPoint3Df min
opposite corners of the cube
mrpt::opengl::shader_id_t shader_id
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)
static const uint8_t grid_line_indices[]
COpenGLScene::Ptr & operator<<(COpenGLScene::Ptr &s, const CRenderizable::Ptr &r)
Inserts an openGL object into a scene.
The base class of 3D objects that can be directly rendered through OpenGL.
std::vector< TVoxel > voxels
void clear()
Clears everything.
void setLineWidth(float w)
bool sort_voxels_z(const COctoMapVoxels::TVoxel &a, const COctoMapVoxels::TVoxel &b)
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.
Context for calls to render()
std::vector< mrpt::math::TPoint3Df > m_vertex_buffer_data
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
std::vector< mrpt::img::TColor > m_color_buffer_data
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
std::array< Vertex, 3 > vertices
This base provides a set of functions for maths stuff.
static constexpr shader_id_t WIREFRAME
mrpt::math::TPoint3Df max
void onUpdateBuffers_Triangles() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
mrpt::math::TPoint3Df coords
static const uint8_t cube_indices[2 *6 *3]
The info of each grid block.
static constexpr shader_id_t TRIANGLES
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
void onUpdateBuffers_Points() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
The info of each of the voxels.
std::vector< mrpt::img::TColor > m_color_buffer_data
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...
std::vector< mrpt::opengl::TTriangle > m_triangles
List of triangles.
#define DECLARE_CUSTOM_TTYPENAME(_TYPE)
Identical to MRPT_DECLARE_TTYPENAME but intended for user code.
mrpt::vision::TStereoCalibResults out
The namespace for 3D scene representation and rendering.
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
static const mrpt::math::TPoint3Df normals_cube[6 *2]
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
static constexpr shader_id_t POINTS
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.