Main MRPT website > C++ reference for MRPT 1.5.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-2017, 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  namespace opengl {
17  typedef uint32_t _GLENUM;
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
GLdouble GLdouble t
Definition: glext.h:3610
void setFlags(const std::vector< _GLENUM > &v)
Set the list of all openGL flags.
COpenGLStandardObject(_GLENUM t, const std::vector< mrpt::math::TPoint3D > &v, uint32_t cs, const std::vector< _GLENUM > &en)
Constructor with all the information.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
bool BASE_IMPEXP traceRay(const std::vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
Fast ray tracing method using polygons&#39; properties.
Definition: geometry.cpp:1989
COpenGLStandardObject()
Baic empty constructor, initializes to default.
GLenum GLsizei n
Definition: glext.h:4618
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.
const_iterator find(const KEY &key) const
Definition: ts_hash_map.h:139
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
#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...
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.
const GLdouble * v
Definition: glext.h:3603
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...
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...
unsigned __int32 uint32_t
Definition: rptypes.h:49
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
GLuint GLuint GLsizei GLenum type
Definition: glext.h:3512



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020