Main MRPT website > C++ reference
MRPT logo
CTexturedPlane.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef opengl_CTexturedPlane_H
29 #define opengl_CTexturedPlane_H
30 
32 
33 namespace mrpt
34 {
35  namespace opengl
36  {
38 
39  // This must be added to any CSerializable derived class:
41 
42  /** A 2D plane in the XY plane with a texture image.
43  * \sa opengl::COpenGLScene
44  * \ingroup mrpt_opengl_grp
45  */
47  {
49  protected:
50  mutable float m_tex_x_min,m_tex_x_max;
51  mutable float m_tex_y_min,m_tex_y_max;
52 
53  float m_xMin, m_xMax;
54  float m_yMin, m_yMax;
55 
56  mutable bool polygonUpToDate;
57  mutable std::vector<mrpt::math::TPolygonWithPlane> tmpPoly; //!< Used for ray-tracing
58  void updatePoly() const;
59  void unloadTexture();
60 
61  void render_texturedobj() const;
62 
63  public:
64  /** Set the texture coordinates of the four corners (in the range 0-1). */
65  void setTextureCornerCoords( float tex_x_min, float tex_x_max, float tex_y_min, float tex_y_max)
66  {
67  m_tex_x_min=tex_x_min;
68  m_tex_x_max=tex_x_max;
69  m_tex_y_min=tex_y_min;
70  m_tex_y_max=tex_y_max;
72  }
73 
74  /** Set the coordinates of the four corners that define the plane on the XY plane. */
75  void setPlaneCorners(float xMin, float xMax, float yMin, float yMax)
76  {
77  m_xMin = xMin; m_xMax = xMax;
78  m_yMin = yMin; m_yMax = yMax;
79  polygonUpToDate=false;
81  }
82 
83  /** Get the coordinates of the four corners that define the plane on the XY plane. */
84  inline void getPlaneCorners(float &xMin, float &xMax, float &yMin, float &yMax) const
85  {
86  xMin = m_xMin; xMax = m_xMax;
87  yMin = m_yMin; yMax = m_yMax;
88  }
89 
90  /** Class factory */
91  static CTexturedPlanePtr Create(
92  float x_min,
93  float x_max,
94  float y_min,
95  float y_max)
96  {
97  return CTexturedPlanePtr( new CTexturedPlane(x_min, x_max, y_min, y_max) );
98  }
99 
100  /** Ray trace
101  */
102  virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const;
103 
104  private:
105  /** Constructor
106  */
108  float x_min = -1,
109  float x_max = 1,
110  float y_min = -1,
111  float y_max = 1
112  );
113 
114  /** Private, virtual destructor: only can be deleted from smart pointers */
115  virtual ~CTexturedPlane();
116  };
117 
118  } // end namespace
119 
120 } // End of namespace
121 
122 
123 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013