Main MRPT website > C++ reference for MRPT 1.9.9
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-2018, 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 
15 namespace mrpt
16 {
17 namespace opengl
18 {
19 using _GLENUM = uint32_t;
20 
21 /**
22  * Objects of this class represent a generic openGL object without specific
23  * geometric properties.
24  * \ingroup mrpt_opengl_grp
25  */
27 {
29  protected:
30  /**
31  * OpenGL identifier of the object type.
32  */
34  /**
35  * Set of points in which consists this object.
36  */
37  std::vector<mrpt::math::TPoint3D> vertices;
38  /**
39  * Granularity of the openGL elements. 3 for GL_TRIANGLES, 4 for GL_QUADS,
40  * and so on. Setting it to 0 will generate a single openGL object.
41  */
43  /**
44  * Set of openGL properties enabled in the rendering of this object.
45  */
46  std::vector<_GLENUM> enabled;
47  float normal[3];
48 
49  public:
50  /**
51  * Render.
52  * \sa mrpt::opengl::CRenderizable
53  */
54  virtual void render_dl() const override;
55  /** Evaluates the bounding box of this object (including possible children)
56  * in the coordinate frame of the object parent. */
57  void getBoundingBox(
58  mrpt::math::TPoint3D& bb_min,
59  mrpt::math::TPoint3D& bb_max) const override;
60  /**
61  * Ray Tracing. Will always return false, since objects of this class are
62  * not intended to have geometric properties.
63  * \sa mrpt::opengl::CRenderizable
64  */
65  bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override;
66  /**
67  * Creation of object from type, vertices, chunk size and a list of enabled
68  * openGL flags.
69  * \throw std::logic_error if the number of vertices is not an exact
70  * multiple of the chunk size.
71  */
73  _GLENUM t, const std::vector<mrpt::math::TPoint3D>& v, uint32_t cs = 0,
74  const std::vector<_GLENUM>& en = std::vector<_GLENUM>());
75 
76  /**
77  * Enable some openGL flag.
78  */
79  inline void enable(_GLENUM flag)
80  {
81  if (find(enabled.begin(), enabled.end(), flag) == enabled.end())
82  enabled.push_back(flag);
84  }
85  /**
86  * Disable some openGL flag.
87  */
88  void disable(_GLENUM flag);
89  /**
90  * Check whether an openGL will be enabled during the rendering of this
91  * object.
92  */
93  inline bool isEnabled(_GLENUM flag) const
94  {
95  return find(enabled.begin(), enabled.end(), flag) != enabled.end();
96  }
97  /**
98  * Get a list of all currently enabled openGL flags.
99  */
100  inline void getEnabledFlags(std::vector<_GLENUM>& v) const { v = enabled; }
101  /**
102  * Set the list of all openGL flags.
103  */
104  inline void setFlags(const std::vector<_GLENUM>& v)
105  {
106  enabled = v;
108  }
109  /**
110  * Set the normal vector to this object.
111  */
112  inline void setNormal(const float (&n)[3])
113  {
114  for (size_t i = 0; i < 3; i++) normal[i] = n[i];
116  }
117  /**
118  * Gets the normal vector to this object.
119  */
120  inline void getNormal(float (&n)[3]) const
121  {
122  for (size_t i = 0; i < 3; i++) n[i] = normal[i];
123  }
124  /**
125  * Constructor with all the information.
126  */
128  _GLENUM t, const std::vector<mrpt::math::TPoint3D>& v, uint32_t cs,
129  const std::vector<_GLENUM>& en)
130  : type(t), vertices(v), chunkSize(cs), enabled(en)
131  {
132  for (size_t i = 0; i < 3; i++) normal[i] = 0.0;
133  }
134  /**
135  * Baic empty constructor, initializes to default.
136  */
138  : type(0),
139  vertices(std::vector<mrpt::math::TPoint3D>(0)),
140  chunkSize(0),
141  enabled(std::vector<_GLENUM>())
142  {
143  for (size_t i = 0; i < 3; i++) normal[i] = 0.0;
144  }
145  /**
146  * Destructor.
147  */
149 };
150 } // end namespace
151 } // End of namespace
152 #endif
n
GLenum GLsizei n
Definition: glext.h:5074
mrpt::opengl::COpenGLStandardObject
Objects of this class represent a generic openGL object without specific geometric properties.
Definition: COpenGLStandardObject.h:26
mrpt::opengl::COpenGLStandardObject::enabled
std::vector< _GLENUM > enabled
Set of openGL properties enabled in the rendering of this object.
Definition: COpenGLStandardObject.h:46
mrpt::opengl::_GLENUM
uint32_t _GLENUM
Definition: COpenGLStandardObject.h:19
mrpt::opengl::COpenGLStandardObject::setNormal
void setNormal(const float(&n)[3])
Set the normal vector to this object.
Definition: COpenGLStandardObject.h:112
geometry.h
t
GLdouble GLdouble t
Definition: glext.h:3689
mrpt::opengl::COpenGLStandardObject::isEnabled
bool isEnabled(_GLENUM flag) const
Check whether an openGL will be enabled during the rendering of this object.
Definition: COpenGLStandardObject.h:93
CRenderizableDisplayList.h
mrpt::opengl::CRenderizableDisplayList
A renderizable object suitable for rendering with OpenGL's display lists.
Definition: CRenderizableDisplayList.h:39
mrpt::opengl::CRenderizableDisplayList::notifyChange
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
Definition: CRenderizableDisplayList.h:57
mrpt::containers::find
const_iterator find(const KEY &key) const
Definition: ts_hash_map.h:219
mrpt::opengl::COpenGLStandardObject::getEnabledFlags
void getEnabledFlags(std::vector< _GLENUM > &v) const
Get a list of all currently enabled openGL flags.
Definition: COpenGLStandardObject.h:100
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::opengl::COpenGLStandardObject::type
_GLENUM type
OpenGL identifier of the object type.
Definition: COpenGLStandardObject.h:33
type
GLuint GLuint GLsizei GLenum type
Definition: glext.h:3528
mrpt::opengl::COpenGLStandardObject::~COpenGLStandardObject
virtual ~COpenGLStandardObject()
Destructor.
Definition: COpenGLStandardObject.h:148
v
const GLdouble * v
Definition: glext.h:3678
mrpt::opengl::COpenGLStandardObject::COpenGLStandardObject
COpenGLStandardObject(_GLENUM t, const std::vector< mrpt::math::TPoint3D > &v, uint32_t cs, const std::vector< _GLENUM > &en)
Constructor with all the information.
Definition: COpenGLStandardObject.h:127
mrpt::opengl::COpenGLStandardObject::enable
void enable(_GLENUM flag)
Enable some openGL flag.
Definition: COpenGLStandardObject.h:79
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::opengl::COpenGLStandardObject::getNormal
void getNormal(float(&n)[3]) const
Gets the normal vector to this object.
Definition: COpenGLStandardObject.h:120
mrpt::opengl::COpenGLStandardObject::chunkSize
uint32_t chunkSize
Granularity of the openGL elements.
Definition: COpenGLStandardObject.h:42
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
mrpt::opengl::COpenGLStandardObject::Ptr
std::shared_ptr< COpenGLStandardObject > Ptr
Definition: COpenGLStandardObject.h:28
mrpt::opengl::COpenGLStandardObject::normal
float normal[3]
Definition: COpenGLStandardObject.h:47
mrpt::opengl::COpenGLStandardObject::traceRay
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray Tracing.
Definition: COpenGLStandardObject.cpp:100
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::opengl::COpenGLStandardObject::getBoundingBox
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...
Definition: COpenGLStandardObject.cpp:110
mrpt::opengl::COpenGLStandardObject::COpenGLStandardObject
COpenGLStandardObject()
Baic empty constructor, initializes to default.
Definition: COpenGLStandardObject.h:137
mrpt::opengl::COpenGLStandardObject::render_dl
virtual void render_dl() const override
Render.
Definition: COpenGLStandardObject.cpp:43
mrpt::opengl::COpenGLStandardObject::vertices
std::vector< mrpt::math::TPoint3D > vertices
Set of points in which consists this object.
Definition: COpenGLStandardObject.h:37
mrpt::opengl::COpenGLStandardObject::Create
static Ptr Create(Args &&... args)
Definition: COpenGLStandardObject.h:28
mrpt::opengl::COpenGLStandardObject::disable
void disable(_GLENUM flag)
Disable some openGL flag.
Definition: COpenGLStandardObject.cpp:126
mrpt::opengl::COpenGLStandardObject::setFlags
void setFlags(const std::vector< _GLENUM > &v)
Set the list of all openGL flags.
Definition: COpenGLStandardObject.h:104
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47



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