Main MRPT website > C++ reference
MRPT logo

CTexturedPlane.h

Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                   http://mrpt.sourceforge.net/                            |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef opengl_CTexturedPlane_H
00029 #define opengl_CTexturedPlane_H
00030 
00031 #include <mrpt/opengl/CTexturedObject.h>
00032 
00033 namespace mrpt
00034 {
00035         namespace opengl
00036         {
00037                 class OPENGL_IMPEXP CTexturedPlane;
00038 
00039                 // This must be added to any CSerializable derived class:
00040                 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CTexturedPlane, CTexturedObject, OPENGL_IMPEXP )
00041 
00042                 /** A 2D plane in the XY plane with a texture image.
00043                   *  \sa opengl::COpenGLScene
00044                   */
00045                 class OPENGL_IMPEXP CTexturedPlane : public CTexturedObject
00046                 {
00047                         DEFINE_SERIALIZABLE( CTexturedPlane )
00048                 protected:
00049                         mutable float                           m_tex_x_min,m_tex_x_max;
00050                         mutable float                           m_tex_y_min,m_tex_y_max;
00051 
00052                         float                   m_xMin, m_xMax;
00053                         float                   m_yMin, m_yMax;
00054 
00055                         mutable bool polygonUpToDate;
00056                         mutable std::vector<mrpt::math::TPolygonWithPlane> tmpPoly;   //!< Used for ray-tracing
00057                         void updatePoly() const;
00058                         void unloadTexture();
00059 
00060                         void  render_texturedobj() const;
00061 
00062                 public:
00063                         /** Set the texture coordinates of the four corners (in the range 0-1). */
00064                         void setTextureCornerCoords( float tex_x_min, float tex_x_max, float tex_y_min, float tex_y_max)
00065                         {
00066                                 m_tex_x_min=tex_x_min;
00067                                 m_tex_x_max=tex_x_max;
00068                                 m_tex_y_min=tex_y_min;
00069                                 m_tex_y_max=tex_y_max;
00070                                 CRenderizableDisplayList::notifyChange();
00071                         }
00072 
00073                         /** Set the coordinates of the four corners that define the plane on the XY plane. */
00074                         void setPlaneCorners(float xMin, float xMax, float yMin, float yMax)
00075                         {
00076                                 m_xMin = xMin; m_xMax = xMax;
00077                                 m_yMin = yMin; m_yMax = yMax;
00078                                 polygonUpToDate=false;
00079                                 CRenderizableDisplayList::notifyChange();
00080                         }
00081 
00082                         /** Get the coordinates of the four corners that define the plane on the XY plane. */
00083                         inline void getPlaneCorners(float &xMin, float &xMax, float &yMin, float &yMax) const
00084                         {
00085                                 xMin = m_xMin; xMax = m_xMax;
00086                                 yMin = m_yMin; yMax = m_yMax;
00087                         }
00088 
00089                         /** Class factory  */
00090                         static CTexturedPlanePtr Create(
00091                                 float                           x_min,
00092                                 float                           x_max,
00093                                 float                           y_min,
00094                                 float                           y_max)
00095                         {
00096                                 return CTexturedPlanePtr( new CTexturedPlane(x_min, x_max, y_min, y_max) );
00097                         }
00098 
00099                         /** Ray trace
00100                           */
00101                         virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const;
00102 
00103                 private:
00104                         /** Constructor
00105                           */
00106                         CTexturedPlane(
00107                                 float                           x_min = -1,
00108                                 float                           x_max = 1,
00109                                 float                           y_min = -1,
00110                                 float                           y_max = 1
00111                                 );
00112 
00113                         /** Private, virtual destructor: only can be deleted from smart pointers */
00114                         virtual ~CTexturedPlane();
00115                 };
00116 
00117         } // end namespace
00118 
00119 } // End of namespace
00120 
00121 
00122 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:16:28 UTC 2011