25 bool is_wireframe,
float lineWidth)
26 : m_wireframe(is_wireframe),
28 m_solidborder_color(0, 0, 0)
31 setBoxCorners(corner1, corner2);
42 if (m_draw_border || m_wireframe)
59 const std::array<mrpt::math::TPoint3D, 2> corner = {m_corner_min,
62 for (
unsigned int i = 0; i < 2; i++)
64 vbd.emplace_back(corner[0].x, corner[0].y, corner[i].z);
65 vbd.emplace_back(corner[0].x, corner[1].y, corner[i].z);
67 vbd.emplace_back(corner[0].x, corner[1].y, corner[i].z);
68 vbd.emplace_back(corner[1].x, corner[1].y, corner[i].z);
70 vbd.emplace_back(corner[1].x, corner[1].y, corner[i].z);
71 vbd.emplace_back(corner[1].x, corner[0].y, corner[i].z);
73 vbd.emplace_back(corner[1].x, corner[0].y, corner[i].z);
74 vbd.emplace_back(corner[0].x, corner[0].y, corner[i].z);
76 vbd.emplace_back(corner[i].x, corner[0].y, corner[0].z);
77 vbd.emplace_back(corner[i].x, corner[0].y, corner[1].z);
79 vbd.emplace_back(corner[i].x, corner[1].y, corner[0].z);
80 vbd.emplace_back(corner[i].x, corner[1].y, corner[1].z);
83 cbd.assign(vbd.size(), m_solidborder_color);
90 const auto &c0 = m_corner_min, &c1 = m_corner_max;
95 P3(c1.x, c0.y, c0.z), P3(c0.x, c0.y, c0.z), P3(c1.x, c0.y, c1.z));
97 P3(c0.x, c0.y, c0.z), P3(c0.x, c0.y, c1.z), P3(c1.x, c0.y, c1.z));
101 P3(c1.x, c1.y, c0.z), P3(c0.x, c1.y, c0.z), P3(c1.x, c1.y, c1.z));
103 P3(c0.x, c1.y, c0.z), P3(c0.x, c1.y, c1.z), P3(c1.x, c1.y, c1.z));
107 P3(c0.x, c0.y, c0.z), P3(c0.x, c1.y, c0.z), P3(c0.x, c1.y, c1.z));
109 P3(c0.x, c0.y, c1.z), P3(c0.x, c0.y, c0.z), P3(c0.x, c1.y, c1.z));
113 P3(c1.x, c0.y, c0.z), P3(c1.x, c1.y, c0.z), P3(c1.x, c1.y, c1.z));
115 P3(c1.x, c0.y, c1.z), P3(c1.x, c0.y, c0.z), P3(c1.x, c1.y, c1.z));
119 P3(c0.x, c0.y, c0.z), P3(c1.x, c0.y, c0.z), P3(c1.x, c1.y, c0.z));
121 P3(c0.x, c1.y, c0.z), P3(c0.x, c0.y, c0.z), P3(c1.x, c1.y, c0.z));
125 P3(c0.x, c0.y, c1.z), P3(c1.x, c0.y, c1.z), P3(c1.x, c1.y, c1.z));
127 P3(c0.x, c1.y, c1.z), P3(c0.x, c0.y, c1.z), P3(c1.x, c1.y, c1.z));
130 for (
auto& t : tris) t.setColor(m_color);
136 writeToStreamRender(
out);
138 out << m_corner_min.x << m_corner_min.y << m_corner_min.z << m_corner_max.x
139 << m_corner_max.y << m_corner_max.z << m_wireframe << m_lineWidth;
141 out << m_draw_border << m_solidborder_color;
150 readFromStreamRender(in);
151 in >> m_corner_min.x >> m_corner_min.y >> m_corner_min.z >>
152 m_corner_max.x >> m_corner_max.y >> m_corner_max.z >>
153 m_wireframe >> m_lineWidth;
156 in >> m_draw_border >> m_solidborder_color;
159 m_draw_border =
false;
176 m_corner_min.x = std::min(corner1.
x, corner2.
x);
177 m_corner_min.y = std::min(corner1.
y, corner2.
y);
178 m_corner_min.z = std::min(corner1.
z, corner2.
z);
180 m_corner_max.x = std::max(corner1.
x, corner2.
x);
181 m_corner_max.y = std::max(corner1.
y, corner2.
y);
182 m_corner_max.z = std::max(corner1.
z, corner2.
z);
187 [[maybe_unused]]
double& dist)
const void setBoxCorners(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2)
Set the position and size of the box, from two corners in 3D.
A solid or wireframe box in 3D, defined by 6 rectangular faces parallel to the planes X...
#define THROW_EXCEPTION(msg)
#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...
mrpt::opengl::shader_id_t shader_id
Renderizable generic renderer for objects using the triangles shader.
void setLineWidth(float w)
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.
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray tracing.
This base provides a set of functions for maths stuff.
void onUpdateBuffers_Triangles() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
static constexpr shader_id_t WIREFRAME
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
TPoint3D_< double > TPoint3D
Lightweight 3D point.
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...
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
static constexpr shader_id_t TRIANGLES
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
std::vector< mrpt::img::TColor > m_color_buffer_data
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
std::vector< mrpt::opengl::TTriangle > m_triangles
List of triangles.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
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.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
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.