Main MRPT website > C++ reference for MRPT 1.9.9
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-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_CTexturedPlane_H
10 #define opengl_CTexturedPlane_H
11 
13 
14 namespace mrpt
15 {
16 namespace opengl
17 {
18 /** A 2D plane in the XY plane with a texture image.
19  * \sa opengl::COpenGLScene
20  * \ingroup mrpt_opengl_grp
21  */
23 {
25  protected:
26  mutable float m_tex_x_min, m_tex_x_max;
27  mutable float m_tex_y_min, m_tex_y_max;
28 
29  float m_xMin, m_xMax;
30  float m_yMin, m_yMax;
31 
32  mutable bool polygonUpToDate;
33  /** Used for ray-tracing */
34  mutable std::vector<mrpt::math::TPolygonWithPlane> tmpPoly;
35  void updatePoly() const;
36  void unloadTexture();
37 
38  void render_texturedobj() const override;
39 
40  public:
41  /** Set the texture coordinates of the four corners (in the range 0-1). */
43  float tex_x_min, float tex_x_max, float tex_y_min, float tex_y_max)
44  {
45  m_tex_x_min = tex_x_min;
46  m_tex_x_max = tex_x_max;
47  m_tex_y_min = tex_y_min;
48  m_tex_y_max = tex_y_max;
50  }
51 
52  /** Set the coordinates of the four corners that define the plane on the XY
53  * plane. */
54  void setPlaneCorners(float xMin, float xMax, float yMin, float yMax)
55  {
56  m_xMin = xMin;
57  m_xMax = xMax;
58  m_yMin = yMin;
59  m_yMax = yMax;
60  polygonUpToDate = false;
62  }
63 
64  /** Get the coordinates of the four corners that define the plane on the XY
65  * plane. */
66  inline void getPlaneCorners(
67  float& xMin, float& xMax, float& yMin, float& yMax) const
68  {
69  xMin = m_xMin;
70  xMax = m_xMax;
71  yMin = m_yMin;
72  yMax = m_yMax;
73  }
74 
75  /** Class factory */
77  float x_min, float x_max, float y_min, float y_max);
78 
79  virtual bool traceRay(
80  const mrpt::poses::CPose3D& o, double& dist) const override;
81  virtual void getBoundingBox(
82  mrpt::math::TPoint3D& bb_min,
83  mrpt::math::TPoint3D& bb_max) const override;
84 
85  /** Constructor
86  */
88  float x_min = -1, float x_max = 1, float y_min = -1, float y_max = 1);
89 
90  /** Private, virtual destructor: only can be deleted from smart pointers */
91  virtual ~CTexturedPlane();
92 };
93 
94 } // end namespace
95 
96 } // End of namespace
97 
98 #endif
static Ptr Create(Args &&... args)
A base class for all OpenGL objects with loadable textures.
std::shared_ptr< CTexturedPlane > Ptr
void setTextureCornerCoords(float tex_x_min, float tex_x_max, float tex_y_min, float tex_y_max)
Set the texture coordinates of the four corners (in the range 0-1).
virtual 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...
virtual ~CTexturedPlane()
Private, virtual destructor: only can be deleted from smart pointers.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
virtual bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Simulation of ray-trace, given a pose.
A 2D plane in the XY plane with a texture image.
void render_texturedobj() const override
Must be implemented by derived classes.
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.
std::vector< mrpt::math::TPolygonWithPlane > tmpPoly
Used for ray-tracing.
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.
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
CTexturedPlane(float x_min=-1, float x_max=1, float y_min=-1, float y_max=1)
Constructor.
Lightweight 3D point.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019