33 const size_t cols = Z.getColCount();
34 const size_t rows = Z.getRowCount();
36 if ((m_colorFromZ) || (m_isImage)) updateColorsMatrix();
38 ASSERT_((cols > 0) && (rows > 0))
39 ASSERT_((xMax > xMin) && (yMax > yMin))
41 X.setSize(rows, cols);
42 Y.setSize(rows, cols);
43 const float sCellX = (xMax - xMin) / (rows - 1);
44 const float sCellY = (yMax - yMin) / (cols - 1);
46 for (
size_t iX = 0; iX < rows; iX++)
47 for (
size_t iY = 0; iY < cols; iY++)
49 X(iX, iY) = xMin + iX * sCellX;
50 Y(iX, iY) = yMin + iY * sCellY;
53 pointsUpToDate =
true;
61 #if MRPT_HAS_OPENGL_GLUT
63 if (!pointsUpToDate) updatePoints();
85 for (
unsigned int i = 0; i < X.getRowCount(); i++)
86 for (
unsigned int j = 0; j < X.getColCount(); j++)
88 if (m_isImage && m_textureImage.isColor())
89 glColor4f(C_r(i, j), C_g(i, j), C_b(i, j), m_color.A / 255.f);
92 glColor4f(C(i, j), C(i, j), C(i, j), m_color.A / 255.f);
94 else if (m_colorFromZ)
103 m_color.R / 255.f, m_color.G / 255.f, m_color.B / 255.f,
130 m_textureImage =
img;
133 Z.setSize(
img.getHeight(),
img.getWidth());
137 m_modified_Image =
true;
138 m_enableTransparency =
false;
139 m_colorFromZ =
false;
141 pointsUpToDate =
false;
157 (
img.getWidth() ==
static_cast<size_t>(in_Z.cols())) &&
158 (
img.getHeight() ==
static_cast<size_t>(in_Z.rows())))
163 m_textureImage =
img;
166 m_modified_Image =
true;
167 m_enableTransparency =
false;
168 m_colorFromZ =
false;
170 pointsUpToDate =
false;
187 writeToStreamRender(out);
189 out << m_textureImage;
191 out << xMin << xMax << yMin << yMax;
193 out << m_enableTransparency;
197 out << m_pointSmooth;
211 readFromStreamRender(
in);
213 in >> m_textureImage;
222 in >> m_enableTransparency;
233 pointsUpToDate =
false;
244 if ((!m_modified_Z) && (!m_modified_Image))
return;
250 const size_t cols = m_textureImage.getWidth();
251 const size_t rows = m_textureImage.getHeight();
253 if ((cols != Z.getColCount()) || (rows != Z.getRowCount()))
255 printf(
"\nTexture Image and Z sizes have to be equal");
257 else if (m_textureImage.isColor())
259 C_r.setSize(rows, cols);
260 C_g.setSize(rows, cols);
261 C_b.setSize(rows, cols);
262 m_textureImage.getAsRGBMatrices(C_r, C_g, C_b);
266 C.setSize(rows, cols);
267 m_textureImage.getAsMatrix(C);
272 const size_t cols = Z.getColCount();
273 const size_t rows = Z.getRowCount();
275 C.setSize(rows, cols);
280 C.normalize(0.01f, 0.99f);
283 m_modified_Image =
false;
284 m_modified_Z =
false;
285 pointsUpToDate =
false;
292 pointsUpToDate =
false;
305 bb_min.
z = Z.minCoeff();
309 bb_max.
z = Z.maxCoeff();
312 m_pose.composePoint(bb_min, bb_min);
313 m_pose.composePoint(bb_max, bb_max);
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
A matrix of dynamic size.
A planar (XY) grid where each cell has an associated height and, optionally, a texture map.
void setZ(const mrpt::math::CMatrixTemplateNumeric< float > &in_Z)
This method sets the matrix of heights for each position (cell) in the mesh grid.
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 writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
void render_dl() const override
Render.
void updateColorsMatrix() const
Called internally to assure C is updated.
void assignImage(const mrpt::utils::CImage &img)
Assigns a texture image, and disable transparency.
void assignImageAndZ(const mrpt::utils::CImage &img, const mrpt::math::CMatrixTemplateNumeric< float > &in_Z)
Assigns a texture image and Z simultaneously, and disable transparency.
A renderizable object suitable for rendering with OpenGL's display lists.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
A class for storing images as grayscale or RGB bitmaps.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
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
TColormap
Different colormaps for use in mrpt::utils::colormap()
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.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
This base provides a set of functions for maths stuff.
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
The namespace for 3D scene representation and rendering.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double x
X,Y,Z coordinates.