Go to the documentation of this file.
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 render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
mrpt::math::TPoint3Df min
opposite corners of the cube
@ COLOR_FROM_OCCUPANCY
Color goes from black (occupied voxel) to the chosen color (free voxel)
static const uint8_t grid_line_indices[]
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
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.
The base class of 3D objects that can be directly rendered through OpenGL.
mrpt::math::TPoint3Df coords
The info of each grid block.
std::vector< mrpt::img::TColor > m_color_buffer_data
std::vector< mrpt::opengl::TTriangle > m_triangles
List of triangles.
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers,...
mrpt::vision::TStereoCalibResults out
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Virtual base class for "archives": classes abstracting I/O streams.
void onUpdateBuffers_Wireframe() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
void setLineWidth(float w)
std::vector< TVoxel > voxels
void clear()
Clears everything.
static constexpr shader_id_t WIREFRAME
void onUpdateBuffers_Points() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
static const uint8_t cube_indices[2 *6 *3]
visualization_mode_t
The different coloring schemes, which modulate the generic mrpt::opengl::CRenderizable object color.
static constexpr shader_id_t TRIANGLES
std::vector< mrpt::math::TPoint3Df > m_vertex_buffer_data
mrpt::math::TPoint3Df max
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 renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers,...
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...
COpenGLScene::Ptr & operator<<(COpenGLScene::Ptr &s, const CRenderizable::Ptr &r)
Inserts an openGL object into a scene.
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CPolyhedron::TPolyhedronEdge &o)
Reads a polyhedron edge from a binary stream.
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
bool sort_voxels_z(const COctoMapVoxels::TVoxel &a, const COctoMapVoxels::TVoxel &b)
Context for calls to render()
#define DECLARE_CUSTOM_TTYPENAME(_TYPE)
Identical to MRPT_DECLARE_TTYPENAME but intended for user code.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
mrpt::opengl::shader_id_t shader_id
A triangle (float coordinates) with RGBA colors (u8) and UV (texture coordinates) for each vertex.
A flexible renderer of voxels, typically from a 3D octo map (see mrpt::maps::COctoMap).
void onUpdateBuffers_Triangles() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
std::array< Vertex, 3 > vertices
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers,...
This base provides a set of functions for maths stuff.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
std::vector< mrpt::math::TPoint3Df > m_vertex_buffer_data
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
static const mrpt::math::TPoint3Df normals_cube[6 *2]
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers,...
std::vector< mrpt::img::TColor > m_color_buffer_data
The namespace for 3D scene representation and rendering.
static constexpr shader_id_t POINTS
The info of each of the voxels.
Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 15 23:51:15 UTC 2020 | |