MRPT  2.0.1
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-2020, 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 
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 
24  protected:
25  float m_xMin = -1.0f, m_xMax = 1.0f;
26  float m_yMin = -1.0f, m_yMax = 1.0f;
27 
28  mutable bool polygonUpToDate{false};
29  /** Used for ray-tracing */
30  mutable std::vector<mrpt::math::TPolygonWithPlane> tmpPoly;
31  void updatePoly() const;
32  void unloadTexture();
33 
34  public:
35  /** @name Renderizable shader API virtual methods
36  * @{ */
37  virtual void onUpdateBuffers_TexturedTriangles() override;
38  /** @} */
39 
41  float x_min = -1, float x_max = 1, float y_min = -1, float y_max = 1);
42  virtual ~CTexturedPlane() override = default;
43 
44  /** Set the coordinates of the four corners that define the plane on the XY
45  * plane. */
46  void setPlaneCorners(float xMin, float xMax, float yMin, float yMax)
47  {
48  m_xMin = xMin;
49  m_xMax = xMax;
50  m_yMin = yMin;
51  m_yMax = yMax;
52  polygonUpToDate = false;
54  }
55 
56  /** Get the coordinates of the four corners that define the plane on the XY
57  * plane. */
58  inline void getPlaneCorners(
59  float& xMin, float& xMax, float& yMin, float& yMax) const
60  {
61  xMin = m_xMin;
62  xMax = m_xMax;
63  yMin = m_yMin;
64  yMax = m_yMax;
65  }
66 
67  bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override;
68  void getBoundingBox(
70  mrpt::math::TPoint3D& bb_max) const override;
71 };
72 
73 } // namespace mrpt::opengl
virtual ~CTexturedPlane() override=default
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
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 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.
virtual void onUpdateBuffers_TexturedTriangles() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
const auto bb_max
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
const auto bb_min
CTexturedPlane(float x_min=-1, float x_max=1, float y_min=-1, float y_max=1)
Renderizable generic renderer for objects using the triangles-with-a-texture shader.



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020