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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020