40 m_last_rendered_count(0),
41 m_last_rendered_count_ongoing(0),
46 m_minmax_valid(false),
47 m_colorFromDepth_min(0,0,0),
48 m_colorFromDepth_max(0,0,1)
58 #if MRPT_HAS_OPENGL_GLUT 60 ASSERT_(m_xs.size() == m_ys.size());
61 ASSERT_(m_xs.size() == m_zs.size());
63 octree_assure_uptodate();
64 m_last_rendered_count_ongoing = 0;
70 if ( m_colorFromDepth )
74 m_minmax_valid =
true;
82 m_max_m_min = m_max - m_min;
83 if (std::abs(m_max_m_min)<1e-4)
85 else m_min = m_max - m_max_m_min * 1.01f;
86 m_max_m_min_inv = 1.0/m_max_m_min;
89 if ( m_color.A != 255 )
102 m_col_slop.R = m_colorFromDepth_max.R - m_colorFromDepth_min.R;
103 m_col_slop.G = m_colorFromDepth_max.G - m_colorFromDepth_min.G;
104 m_col_slop.B = m_colorFromDepth_max.B - m_colorFromDepth_min.B;
106 m_col_slop_inv.R = m_col_slop.R!=0 ? 1.0f/m_col_slop.R : 0;
107 m_col_slop_inv.G = m_col_slop.G!=0 ? 1.0f/m_col_slop.G : 0;
108 m_col_slop_inv.B = m_col_slop.B!=0 ? 1.0f/m_col_slop.B : 0;
120 glColor4ub(m_color.R,m_color.G,m_color.B,m_color.A);
126 if ( m_color.A != 255 )
133 m_last_rendered_count = m_last_rendered_count_ongoing;
141 #if MRPT_HAS_OPENGL_GLUT 142 if ( m_colorFromDepth!=colNone && m_max_m_min>0 )
144 const float depthCol = (m_colorFromDepth==colX ? m_xs[i] : (m_colorFromDepth==colY ? m_ys[i] : m_zs[i]));
146 float f = (depthCol - m_min) * m_max_m_min_inv;
147 f=std::max(0.0f,
min(1.0f,f));
150 m_colorFromDepth_min.R + f*m_col_slop_inv.R,
151 m_colorFromDepth_min.G + f*m_col_slop_inv.G,
152 m_colorFromDepth_min.B + f*m_col_slop_inv.B,
153 m_color.A * (1.0f/255.f) );
165 #if MRPT_HAS_OPENGL_GLUT 167 const size_t N = (all ? m_xs.size() : idxs.size());
170 m_last_rendered_count_ongoing += N/decimation;
174 for (
size_t i=0;i<N;i++)
175 internal_render_one_point(i);
179 const size_t Np = idxs.size();
180 for (
size_t i=0;i<Np;i+=decimation)
181 internal_render_one_point(idxs[i]);
200 writeToStreamRender(out);
202 out << static_cast<int32_t>(m_colorFromDepth);
203 out << m_xs << m_ys << m_zs;
209 out << m_colorFromDepth_min.R << m_colorFromDepth_min.G << m_colorFromDepth_min.B;
210 out << m_colorFromDepth_max.R << m_colorFromDepth_max.G << m_colorFromDepth_max.B;
213 out << m_pointSmooth;
231 readFromStreamRender(
in);
236 m_colorFromDepth =
Axis(axis);
244 in >> m_xs >> m_ys >> m_zs;
248 else m_pointSize = 1;
252 in >> m_colorFromDepth_min.R >> m_colorFromDepth_min.G >> m_colorFromDepth_min.B;
253 in >> m_colorFromDepth_max.R >> m_colorFromDepth_max.G >> m_colorFromDepth_max.B;
257 m_colorFromDepth_min =
TColorf(0,0,0);
258 m_colorFromDepth_max.R = m_color.R*255.f;
259 m_colorFromDepth_max.G = m_color.G*255.f;
260 m_colorFromDepth_max.B = m_color.B*255.f;
265 else m_pointSmooth =
false;
273 markAllPointsAsNew();
284 markAllPointsAsNew();
296 m_minmax_valid =
false;
299 markAllPointsAsNew();
312 m_minmax_valid =
false;
315 markAllPointsAsNew();
323 m_colorFromDepth_min = colorMin;
324 m_colorFromDepth_max = colorMax;
330 m_minmax_valid =
false;
331 octree_mark_as_outdated();
346 this->setPoint(idx,pt.
x,pt.
y,pt.
z);
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
void insertPoint(float x, float y, float z)
Adds a new point to the cloud.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glPointSize(GLfloat size)
#define ASSERT_BELOW_(__A, __B)
This file implements several operations that operate element-wise on individual or pairs of container...
void render() const MRPT_OVERRIDE
Render.
The base class of 3D objects that can be directly rendered through OpenGL.
void setGradientColors(const mrpt::utils::TColorf &colorMin, const mrpt::utils::TColorf &colorMax)
Sets the colors used as extremes when colorFromDepth is enabled.
#define GL_ONE_MINUS_SRC_ALPHA
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
void clear()
Empty the list of points.
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
This base provides a set of functions for maths stuff.
Lightweight 3D point (float version).
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
OPENGL_IMPEXP float OCTREE_RENDER_MAX_DENSITY_POINTS_PER_SQPIXEL
Default value = 0.01 points/px^2.
Information about the rendering process being issued.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
void internal_render_one_point(size_t i) const
void minimum_maximum(const std::vector< T > &V, T &curMin, T &curMax)
Return the maximum and minimum values of a std::vector.
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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 markAllPointsAsNew()
Do needed internal work if all points are new (octree rebuilt,...)
size_t PLY_export_get_vertex_count() const MRPT_OVERRIDE
In a base class, return the number of vertices.
OPENGL_IMPEXP size_t OCTREE_RENDER_MAX_POINTS_PER_NODE
Default value = 1e5.
virtual void PLY_import_set_vertex_count(const size_t N) MRPT_OVERRIDE
In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex.
void OPENGL_IMPEXP checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
virtual void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::utils::TColorf *pt_color=NULL) MRPT_OVERRIDE
In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point...
The namespace for 3D scene representation and rendering.
void OPENGL_IMPEXP getCurrentRenderingInfo(TRenderInfo &ri)
Gather useful information on the render parameters.
A RGB color - floats in the range [0,1].
GLAPI void GLAPIENTRY glEnd(void)
int round(const T value)
Returns the closer integer (int) to x.
void setPoint(size_t i, const float x, const float y, const float z)
Write an individual point (checks for "i" in the valid range only in Debug).
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
void PLY_export_get_vertex(const size_t idx, mrpt::math::TPoint3Df &pt, bool &pt_has_color, mrpt::utils::TColorf &pt_color) const MRPT_OVERRIDE
In a base class, will be called after PLY_export_get_vertex_count() once for each exported point...
A cloud of points, all with the same color or each depending on its value along a particular coordina...