Main MRPT website > C++ reference for MRPT 1.4.0
CTexturedPlane.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_CTexturedPlane_H
10 #define opengl_CTexturedPlane_H
11 
13 
14 namespace mrpt
15 {
16  namespace opengl
17  {
18 
19 
20  // This must be added to any CSerializable derived class:
21  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CTexturedPlane, CTexturedObject, OPENGL_IMPEXP )
22 
23  /** A 2D plane in the XY plane with a texture image.
24  * \sa opengl::COpenGLScene
25  * \ingroup mrpt_opengl_grp
26  */
28  {
30  protected:
31  mutable float m_tex_x_min,m_tex_x_max;
32  mutable float m_tex_y_min,m_tex_y_max;
33 
34  float m_xMin, m_xMax;
35  float m_yMin, m_yMax;
36 
37  mutable bool polygonUpToDate;
38  mutable std::vector<mrpt::math::TPolygonWithPlane> tmpPoly; //!< Used for ray-tracing
39  void updatePoly() const;
40  void unloadTexture();
41 
42  void render_texturedobj() const MRPT_OVERRIDE;
43 
44  public:
45  /** Set the texture coordinates of the four corners (in the range 0-1). */
46  void setTextureCornerCoords( float tex_x_min, float tex_x_max, float tex_y_min, float tex_y_max)
47  {
48  m_tex_x_min=tex_x_min;
49  m_tex_x_max=tex_x_max;
50  m_tex_y_min=tex_y_min;
51  m_tex_y_max=tex_y_max;
53  }
54 
55  /** Set the coordinates of the four corners that define the plane on the XY plane. */
56  void setPlaneCorners(float xMin, float xMax, float yMin, float yMax)
57  {
58  m_xMin = xMin; m_xMax = xMax;
59  m_yMin = yMin; m_yMax = yMax;
60  polygonUpToDate=false;
62  }
63 
64  /** Get the coordinates of the four corners that define the plane on the XY plane. */
65  inline void getPlaneCorners(float &xMin, float &xMax, float &yMin, float &yMax) const
66  {
67  xMin = m_xMin; xMax = m_xMax;
68  yMin = m_yMin; yMax = m_yMax;
69  }
70 
71  /** Class factory */
72  static CTexturedPlanePtr Create(float x_min, float x_max, float y_min, float y_max);
73 
74  virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const MRPT_OVERRIDE;
75  virtual void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE;
76 
77  private:
78  /** Constructor
79  */
81  float x_min = -1,
82  float x_max = 1,
83  float y_min = -1,
84  float y_max = 1
85  );
86 
87  /** Private, virtual destructor: only can be deleted from smart pointers */
88  virtual ~CTexturedPlane();
89  };
90  DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE( CTexturedPlane, CTexturedObject, OPENGL_IMPEXP )
91 
92  } // end namespace
93 
94 } // End of namespace
95 
96 
97 #endif
mrpt::opengl::CTexturedPlane::m_tex_y_min
float m_tex_y_min
Definition: CTexturedPlane.h:32
mrpt::opengl::CTexturedPlane::m_tex_x_min
float m_tex_x_min
Definition: CTexturedPlane.h:31
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:49
mrpt::opengl::CTexturedPlane::getPlaneCorners
void getPlaneCorners(float &xMin, float &xMax, float &yMin, float &yMax) const
Get the coordinates of the four corners that define the plane on the XY plane.
Definition: CTexturedPlane.h:65
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CParticleFilter.h:16
mrpt::opengl::CTexturedPlane
A 2D plane in the XY plane with a texture image.
Definition: CTexturedPlane.h:27
mrpt::opengl::CTexturedPlane::tmpPoly
std::vector< mrpt::math::TPolygonWithPlane > tmpPoly
Used for ray-tracing.
Definition: CTexturedPlane.h:38
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
Definition: CSerializable.h:174
mrpt::opengl::CTexturedObject
A base class for all OpenGL objects with loadable textures.
Definition: CTexturedObject.h:29
mrpt::opengl::CTexturedPlane::setPlaneCorners
void setPlaneCorners(float xMin, float xMax, float yMin, float yMax)
Set the coordinates of the four corners that define the plane on the XY plane.
Definition: CTexturedPlane.h:56
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:229
DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE
#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...
Definition: CSerializable.h:170
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:147
mrpt::opengl::CTexturedPlane::polygonUpToDate
bool polygonUpToDate
Definition: CTexturedPlane.h:37
mrpt::opengl::CTexturedPlane::m_yMin
float m_yMin
Definition: CTexturedPlane.h:35
mrpt::math::traceRay
bool BASE_IMPEXP traceRay(const vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
Fast ray tracing method using polygons' properties.
CTexturedObject.h
mrpt::opengl::CTexturedPlane::m_xMin
float m_xMin
Definition: CTexturedPlane.h:34
MRPT_OVERRIDE
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28



Page generated by Doxygen 1.8.16 for MRPT 1.4.0 SVN: at Mon Oct 14 22:32:58 UTC 2019