Main MRPT website > C++ reference for MRPT 1.4.0
COpenGLStandardObject.h
Go to the documentation of this file.
1/* +---------------------------------------------------------------------------+
2 | Mobile Robot Programming Toolkit (MRPT) |
3 | http://www.mrpt.org/ |
4 | |
5 | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6 | See: http://www.mrpt.org/Authors - All rights reserved. |
7 | Released under BSD License. See details in http://www.mrpt.org/License |
8 +---------------------------------------------------------------------------+ */
9#ifndef opengl_COpenGLStandardObject_H
10#define opengl_COpenGLStandardObject_H
11
13#include <mrpt/math/geometry.h>
14
15namespace mrpt {
16 namespace opengl {
18
20 /**
21 * Objects of this class represent a generic openGL object without specific geometric properties.
22 * \ingroup mrpt_opengl_grp
23 */
26 protected:
27 /**
28 * OpenGL identifier of the object type.
29 */
31 /**
32 * Set of points in which consists this object.
33 */
34 std::vector<mrpt::math::TPoint3D> vertices;
35 /**
36 * Granularity of the openGL elements. 3 for GL_TRIANGLES, 4 for GL_QUADS, and so on. Setting it to 0 will generate a single openGL object.
37 */
39 /**
40 * Set of openGL properties enabled in the rendering of this object.
41 */
42 std::vector<_GLENUM> enabled;
43 float normal[3];
44 public:
45 /**
46 * Render.
47 * \sa mrpt::opengl::CRenderizable
48 */
49 virtual void render_dl() const MRPT_OVERRIDE;
50 /** Evaluates the bounding box of this object (including possible children) in the coordinate frame of the object parent. */
51 void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE;
52 /**
53 * Ray Tracing. Will always return false, since objects of this class are not intended to have geometric properties.
54 * \sa mrpt::opengl::CRenderizable
55 */
56 bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const MRPT_OVERRIDE;
57 /**
58 * Creation of object from type, vertices, chunk size and a list of enabled openGL flags.
59 * \throw std::logic_error if the number of vertices is not an exact multiple of the chunk size.
60 */
61 static COpenGLStandardObjectPtr Create(_GLENUM t,const std::vector<mrpt::math::TPoint3D> &v,uint32_t cs=0,const std::vector<_GLENUM> &en=std::vector<_GLENUM>());
62
63 /**
64 * Enable some openGL flag.
65 */
66 inline void enable(_GLENUM flag) {
67 if (find(enabled.begin(),enabled.end(),flag)==enabled.end()) enabled.push_back(flag);
69 }
70 /**
71 * Disable some openGL flag.
72 */
73 void disable(_GLENUM flag);
74 /**
75 * Check whether an openGL will be enabled during the rendering of this object.
76 */
77 inline bool isEnabled(_GLENUM flag) const {
78 return find(enabled.begin(),enabled.end(),flag)!=enabled.end();
79 }
80 /**
81 * Get a list of all currently enabled openGL flags.
82 */
83 inline void getEnabledFlags(std::vector<_GLENUM> &v) const {
84 v=enabled;
85 }
86 /**
87 * Set the list of all openGL flags.
88 */
89 inline void setFlags(const std::vector<_GLENUM> &v) {
90 enabled=v;
92 }
93 /**
94 * Set the normal vector to this object.
95 */
96 inline void setNormal(const float (&n)[3]) {
97 for (size_t i=0;i<3;i++) normal[i]=n[i];
99 }
100 /**
101 * Gets the normal vector to this object.
102 */
103 inline void getNormal(float (&n)[3]) const {
104 for (size_t i=0;i<3;i++) n[i]=normal[i];
105 }
106 private:
107 /**
108 * Constructor with all the information.
109 */
110 COpenGLStandardObject(_GLENUM t,const std::vector<mrpt::math::TPoint3D> &v,uint32_t cs,const std::vector<_GLENUM> &en):type(t),vertices(v),chunkSize(cs),enabled(en) {
111 for (size_t i=0;i<3;i++) normal[i]=0.0;
112 }
113 /**
114 * Baic empty constructor, initializes to default.
115 */
116 COpenGLStandardObject():type(0),vertices(std::vector<mrpt::math::TPoint3D>(0)),chunkSize(0),enabled(std::vector<_GLENUM>()) {
117 for (size_t i=0;i<3;i++) normal[i]=0.0;
118 }
119 /**
120 * Destructor.
121 */
123 };
124 DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(COpenGLStandardObject,CRenderizableDisplayList, OPENGL_IMPEXP)
125 } // end namespace
126} // End of namespace
127#endif
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
Objects of this class represent a generic openGL object without specific geometric properties.
std::vector< _GLENUM > enabled
Set of openGL properties enabled in the rendering of this object.
COpenGLStandardObject()
Baic empty constructor, initializes to default.
_GLENUM type
OpenGL identifier of the object type.
bool isEnabled(_GLENUM flag) const
Check whether an openGL will be enabled during the rendering of this object.
void setFlags(const std::vector< _GLENUM > &v)
Set the list of all openGL flags.
void setNormal(const float(&n)[3])
Set the normal vector to this object.
COpenGLStandardObject(_GLENUM t, const std::vector< mrpt::math::TPoint3D > &v, uint32_t cs, const std::vector< _GLENUM > &en)
Constructor with all the information.
void getEnabledFlags(std::vector< _GLENUM > &v) const
Get a list of all currently enabled openGL flags.
virtual void render_dl() const MRPT_OVERRIDE
Render.
std::vector< mrpt::math::TPoint3D > vertices
Set of points in which consists this object.
void disable(_GLENUM flag)
Disable some openGL flag.
void getNormal(float(&n)[3]) const
Gets the normal vector to this object.
uint32_t chunkSize
Granularity of the openGL elements.
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)
EIGEN_STRONG_INLINE const AdjointReturnType t() const
Transpose.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28
struct OPENGL_IMPEXP COpenGLStandardObjectPtr
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
STL namespace.
unsigned long uint32_t
Definition: pstdint.h:216



Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Wed Feb 15 01:46:32 UTC 2023