33 #if MRPT_HAS_OPENGL_GLUT
34 octree_assure_uptodate();
35 m_last_rendered_count_ongoing = 0;
68 m_last_rendered_count = m_last_rendered_count_ongoing;
76 const bool all,
const std::vector<size_t>& idxs,
77 const float render_area_sqpixels)
const
79 #if MRPT_HAS_OPENGL_GLUT
80 const size_t N = all ? m_points.size() : idxs.size();
83 1.0f,
static_cast<float>(
86 render_area_sqpixels))));
88 m_last_rendered_count_ongoing += N / decimation;
90 m_last_rendered_count_ongoing +=
91 (all ? m_points.size() : idxs.size()) / decimation;
95 for (
size_t i = 0; i < N; i += decimation)
104 for (
size_t i = 0; i < N; i += decimation)
121 writeToStreamRender(out);
124 out << m_pointSmooth;
135 readFromStreamRender(
in);
136 in >> m_points >> m_pointSize;
141 m_pointSmooth =
false;
146 readFromStreamRender(
in);
152 for (
uint32_t i = 0; i < n; i++) in >> m_points[i];
160 markAllPointsAsNew();
166 in >> o.
x >> o.
y >> o.
z >> o.
R >> o.
G >> o.
B;
173 out << o.
x << o.
y << o.
z << o.
R << o.
G << o.
B;
188 markAllPointsAsNew();
193 float x,
float y,
float z,
float R,
float G,
float B)
199 markAllPointsAsNew();
225 pt.
x, pt.
y, pt.
z, pt_color->
R, pt_color->
G, pt_color->
B));
254 const float coord_min,
const float coord_max,
const int coord_index,
260 const float coord_range = coord_max - coord_min;
261 const float coord_range_1 = coord_range != 0.0f ? 1.0f / coord_range : 1.0f;
262 for (
size_t i = 0; i < m_points.size(); i++)
268 coord = m_points[i].x;
271 coord = m_points[i].y;
274 coord = m_points[i].z;
277 const float col_idx =
278 std::max(0.0f,
std::min(1.0f, (
coord - coord_min) * coord_range_1));
281 this->setPointColor_fast(i,
r,
g,
b);
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
A cloud of points, each one with an individual colour (R,G,B).
void markAllPointsAsNew()
Do needed internal work if all points are new (octree rebuilt,...)
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
void recolorizeByCoordinate(const float coord_min, const float coord_max, const int coord_index=2, const mrpt::img::TColormap color_map=mrpt::img::cmJET)
Regenerates the color of each point according the one coordinate (coord_index:0,1,...
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
size_t PLY_export_get_vertex_count() const override
In a base class, return the number of vertices.
void render_subset(const bool all, const std::vector< size_t > &idxs, const float render_area_sqpixels) const
Render a subset of points (required by octree renderer)
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
void push_back(float x, float y, float z, float R, float G, float B)
Inserts a new point into the point cloud.
virtual void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::img::TColorf *pt_color=nullptr) override
In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point.
void PLY_export_get_vertex(const size_t idx, mrpt::math::TPoint3Df &pt, bool &pt_has_color, mrpt::img::TColorf &pt_color) const override
In a base class, will be called after PLY_export_get_vertex_count() once for each exported point.
virtual void PLY_import_set_vertex_count(const size_t N) override
In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex.
void setPoint(size_t i, const TPointColour &p)
Write an individual point (checks for "i" in the valid range only in Debug).
The base class of 3D objects that can be directly rendered through OpenGL.
Virtual base class for "archives": classes abstracting I/O streams.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
#define ASSERT_BELOW_(__A, __B)
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
#define ASSERT_ABOVEEQ_(__A, __B)
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glPointSize(GLfloat size)
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
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 glDisable(GLenum cap)
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
GLdouble GLdouble GLdouble r
void colormap(const TColormap &color_map, const float color_index, float &r, float &g, float &b)
Transform a float number in the range [0,1] into RGB components.
TColormap
Different colormaps for use in mrpt::img::colormap()
void OCTREE_RENDER_MAX_DENSITY_POINTS_PER_SQPIXEL(float value)
Default value = 0.01 points/px^2.
int round(const T value)
Returns the closer integer (int) to x.
Global variables to change the run-time behaviour of some MRPT classes within mrpt-base.
This base provides a set of functions for maths stuff.
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
void getCurrentRenderingInfo(TRenderInfo &ri)
Gather useful information on the render parameters.
The namespace for 3D scene representation and rendering.
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &out, const mrpt::opengl::CLight &o)
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, mrpt::opengl::CLight &o)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
This file implements several operations that operate element-wise on individual or pairs of container...
unsigned __int32 uint32_t
A RGB color - floats in the range [0,1].
Lightweight 3D point (float version).
Information about the rendering process being issued.