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
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:219
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:88
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: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019