Go to the documentation of this file.
31 #if MRPT_HAS_OPENGL_GLUT
33 if (m_enableTransparency)
50 for (it = m_triangles.begin(); it != m_triangles.end(); ++it)
54 float ax = it->x[1] - it->x[0];
55 float ay = it->y[1] - it->y[0];
56 float az = it->z[1] - it->z[0];
58 float bx = it->x[2] - it->x[0];
59 float by = it->y[2] - it->y[0];
60 float bz = it->z[2] - it->z[0];
64 glColor4f(it->r[0], it->g[0], it->b[0], it->a[0]);
67 glColor4f(it->r[1], it->g[1], it->b[1], it->a[1]);
70 glColor4f(it->r[2], it->g[2], it->b[2], it->a[2]);
109 writeToStreamRender(out);
115 out << m_enableTransparency;
125 readFromStreamRender(
in);
129 for (
size_t i = 0; i <
n; i++)
133 in >> m_enableTransparency;
135 m_enableTransparency =
true;
141 polygonsUpToDate =
false;
148 if (!polygonsUpToDate) updatePolygons();
150 tmpPolygons, (o - this->m_pose).asTPose(), dist);
289 it != m_triangles.end(); ++it)
290 for (
size_t i = 0; i < 3; i++)
304 const float col =
r / 255.f;
306 it != m_triangles.end(); ++it)
307 for (
size_t i = 0; i < 3; i++) it->r[i] = col;
315 const float col =
g / 255.f;
317 it != m_triangles.end(); ++it)
318 for (
size_t i = 0; i < 3; i++) it->g[i] = col;
326 const float col =
b / 255.f;
328 it != m_triangles.end(); ++it)
329 for (
size_t i = 0; i < 3; i++) it->b[i] = col;
337 const float col =
a / 255.f;
339 it != m_triangles.end(); ++it)
340 for (
size_t i = 0; i < 3; i++) it->a[i] = col;
345 std::vector<mrpt::math::TPolygon3D>& polys)
const
347 if (!polygonsUpToDate) updatePolygons();
348 size_t N = tmpPolygons.size();
349 for (
size_t i = 0; i < N; i++) polys[i] = tmpPolygons[i].poly;
355 size_t N = m_triangles.size();
356 tmpPolygons.resize(N);
357 for (
size_t i = 0; i < N; i++)
358 for (
size_t j = 0; j < 3; j++)
364 tmpPolygons[i] = tmp;
366 polygonsUpToDate =
true;
374 std::numeric_limits<double>::max(), std::numeric_limits<double>::max(),
375 std::numeric_limits<double>::max());
377 -std::numeric_limits<double>::max(),
378 -std::numeric_limits<double>::max(),
379 -std::numeric_limits<double>::max());
381 for (
size_t i = 0; i < m_triangles.size(); i++)
408 m_pose.composePoint(bb_min, bb_min);
409 m_pose.composePoint(bb_max, bb_max);
414 reserve(m_triangles.size() +
p->m_triangles.size());
416 m_triangles.end(),
p->m_triangles.begin(),
p->m_triangles.end());
417 polygonsUpToDate =
false;
void keep_min(T &var, const K test_val)
If the second argument is below the first one, set the first argument to this lower value.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
const Scalar * const_iterator
void insertTriangles(const InputIterator &begin, const InputIterator &end)
Inserts a set of triangles, bounded by iterators, into this set.
A set of colored triangles.
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray tracing.
The base class of 3D objects that can be directly rendered through OpenGL.
CRenderizable & setColorR_u8(const uint8_t r) override
Color components in the range [0,255].
A renderizable object suitable for rendering with OpenGL's display lists.
GLAPI void GLAPIENTRY glDisable(GLenum cap)
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
GLAPI void GLAPIENTRY glEnable(GLenum cap)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
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 updatePolygons() const
Polygon cache updating.
CRenderizable & setColor_u8(const mrpt::img::TColor &c) override
Changes the default object color.
bool traceRay(const std::vector< TPolygonWithPlane > &vec, const mrpt::math::TPose3D &pose, double &dist)
Fast ray tracing method using polygons' properties.
Virtual base class for "archives": classes abstracting I/O streams.
GLAPI void GLAPIENTRY glEnd(void)
GLdouble GLdouble GLdouble r
CRenderizable & setColorB_u8(const uint8_t b) override
Color components in the range [0,255].
#define GL_ONE_MINUS_SRC_ALPHA
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
static void triangle_writeToStream(mrpt::serialization::CArchive &o, const CSetOfTriangles::TTriangle &t)
double x
X,Y,Z coordinates.
CRenderizable & setColorA_u8(const uint8_t a) override
Color components in the range [0,255].
A RGB color - floats in the range [0,1].
static void triangle_readFromStream(mrpt::serialization::CArchive &i, CSetOfTriangles::TTriangle &t)
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
3D polygon, inheriting from std::vector<TPoint3D>
std::shared_ptr< CSetOfTriangles > Ptr
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
CRenderizable & setColorG_u8(const uint8_t g) override
Color components in the range [0,255].
GLAPI void GLAPIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
size_t ReadBufferFixEndianness(T *ptr, size_t ElementCount)
Reads a sequence of elemental datatypes, taking care of reordering their bytes from the MRPT stream s...
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
This base provides a set of functions for maths stuff.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
void getPolygons(std::vector< mrpt::math::TPolygon3D > &polys) const
Gets the polygon cache.
void WriteBufferFixEndianness(const T *ptr, size_t ElementCount)
Writes a sequence of elemental datatypes, taking care of reordering their bytes from the running arch...
The namespace for 3D scene representation and rendering.
unsigned __int32 uint32_t
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
GLubyte GLubyte GLubyte a
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at mié 12 jul 2023 10:03:34 CEST | |