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-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_CTexturedPlane_H
10 #define opengl_CTexturedPlane_H
11 
13 
14 namespace mrpt::opengl
15 {
16 /** A 2D plane in the XY plane with a texture image.
17  * \sa opengl::COpenGLScene
18  * \ingroup mrpt_opengl_grp
19  */
21 {
23  protected:
24  mutable float m_tex_x_min, m_tex_x_max;
25  mutable float m_tex_y_min, m_tex_y_max;
26 
27  float m_xMin, m_xMax;
28  float m_yMin, m_yMax;
29 
30  mutable bool polygonUpToDate;
31  /** Used for ray-tracing */
32  mutable std::vector<mrpt::math::TPolygonWithPlane> tmpPoly;
33  void updatePoly() const;
34  void unloadTexture();
35 
36  void render_texturedobj() const override;
37 
38  public:
39  /** Set the texture coordinates of the four corners (in the range 0-1). */
41  float tex_x_min, float tex_x_max, float tex_y_min, float tex_y_max)
42  {
43  m_tex_x_min = tex_x_min;
44  m_tex_x_max = tex_x_max;
45  m_tex_y_min = tex_y_min;
46  m_tex_y_max = tex_y_max;
48  }
49 
50  /** Set the coordinates of the four corners that define the plane on the XY
51  * plane. */
52  void setPlaneCorners(float xMin, float xMax, float yMin, float yMax)
53  {
54  m_xMin = xMin;
55  m_xMax = xMax;
56  m_yMin = yMin;
57  m_yMax = yMax;
58  polygonUpToDate = false;
60  }
61 
62  /** Get the coordinates of the four corners that define the plane on the XY
63  * plane. */
64  inline void getPlaneCorners(
65  float& xMin, float& xMax, float& yMin, float& yMax) const
66  {
67  xMin = m_xMin;
68  xMax = m_xMax;
69  yMin = m_yMin;
70  yMax = m_yMax;
71  }
72 
73  /** Class factory */
75  float x_min, float x_max, float y_min, float y_max);
76 
77  virtual bool traceRay(
78  const mrpt::poses::CPose3D& o, double& dist) const override;
79  virtual void getBoundingBox(
80  mrpt::math::TPoint3D& bb_min,
81  mrpt::math::TPoint3D& bb_max) const override;
82 
83  /** Constructor
84  */
86  float x_min = -1, float x_max = 1, float y_min = -1, float y_max = 1);
87 
88  /** Private, virtual destructor: only can be deleted from smart pointers */
89  virtual ~CTexturedPlane();
90 };
91 
92 }
93 #endif
94 
95 
static Ptr Create(Args &&... args)
A base class for all OpenGL objects with loadable textures.
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.
#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
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020