MRPT  1.9.9
CTexturedPlane.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
12 
13 namespace mrpt::opengl
14 {
15 /** A 2D plane in the XY plane with a texture image.
16  * \sa opengl::COpenGLScene
17  * \ingroup mrpt_opengl_grp
18  */
20 {
22  protected:
23  mutable float m_tex_x_min, m_tex_x_max;
24  mutable float m_tex_y_min, m_tex_y_max;
25 
26  float m_xMin, m_xMax;
27  float m_yMin, m_yMax;
28 
29  mutable bool polygonUpToDate{false};
30  /** Used for ray-tracing */
31  mutable std::vector<mrpt::math::TPolygonWithPlane> tmpPoly;
32  void updatePoly() const;
33  void unloadTexture();
34 
35  void render_texturedobj() const override;
36 
37  public:
38  /** Set the texture coordinates of the four corners (in the range 0-1). */
40  float tex_x_min, float tex_x_max, float tex_y_min, float tex_y_max)
41  {
42  m_tex_x_min = tex_x_min;
43  m_tex_x_max = tex_x_max;
44  m_tex_y_min = tex_y_min;
45  m_tex_y_max = tex_y_max;
47  }
48 
49  /** Set the coordinates of the four corners that define the plane on the XY
50  * plane. */
51  void setPlaneCorners(float xMin, float xMax, float yMin, float yMax)
52  {
53  m_xMin = xMin;
54  m_xMax = xMax;
55  m_yMin = yMin;
56  m_yMax = yMax;
57  polygonUpToDate = false;
59  }
60 
61  /** Get the coordinates of the four corners that define the plane on the XY
62  * plane. */
63  inline void getPlaneCorners(
64  float& xMin, float& xMax, float& yMin, float& yMax) const
65  {
66  xMin = m_xMin;
67  xMax = m_xMax;
68  yMin = m_yMin;
69  yMax = m_yMax;
70  }
71 
72  bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override;
73  void getBoundingBox(
75  mrpt::math::TPoint3D& bb_max) const override;
76 
77  /** Constructor
78  */
80  float x_min = -1, float x_max = 1, float y_min = -1, float y_max = 1);
81 
82  /** Private, virtual destructor: only can be deleted from smart pointers */
83  ~CTexturedPlane() override;
84 };
85 
86 } // namespace mrpt::opengl
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
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).
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...
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.
~CTexturedPlane() override
Private, virtual destructor: only can be deleted from smart pointers.
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:84
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
const auto bb_max
const auto bb_min
CTexturedPlane(float x_min=-1, float x_max=1, float y_min=-1, float y_max=1)
Constructor.
Lightweight 3D point.
Definition: TPoint3D.h:90



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019