00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef opengl_CTexturedPlane_H
00029 #define opengl_CTexturedPlane_H
00030
00031 #include <mrpt/opengl/CRenderizable.h>
00032 #include <mrpt/utils/CImage.h>
00033 #include <mrpt/math/geometry.h>
00034
00035 namespace mrpt
00036 {
00037 namespace opengl
00038 {
00039 class MRPTDLLIMPEXP CTexturedPlane;
00040
00041
00042 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CTexturedPlane, CRenderizable )
00043
00044
00045
00046
00047 class MRPTDLLIMPEXP CTexturedPlane : public CRenderizable
00048 {
00049 DEFINE_SERIALIZABLE( CTexturedPlane )
00050 protected:
00051 mutable unsigned int m_glTextureName;
00052 mutable bool m_init;
00053 mutable mrpt::utils::CImage m_textureImage;
00054 mutable mrpt::utils::CImage m_textureImageAlpha;
00055 mutable bool m_enableTransparency;
00056 mutable int r_width,r_height;
00057
00058 mutable float m_tex_x_min,m_tex_x_max;
00059 mutable float m_tex_y_min,m_tex_y_max;
00060
00061 float m_xMin, m_xMax;
00062 float m_yMin, m_yMax;
00063 mutable bool polygonUpToDate;
00064 mutable std::vector<mrpt::math::TPolygonWithPlane> tmpPoly;
00065 void updatePoly() const;
00066
00067 public:
00068
00069 void setTextureCornerCoords( float tex_x_min, float tex_x_max, float tex_y_min, float tex_y_max)
00070 {
00071 m_tex_x_min=tex_x_min;
00072 m_tex_x_max=tex_x_max;
00073 m_tex_y_min=tex_y_min;
00074 m_tex_y_max=tex_y_max;
00075 }
00076
00077
00078 void setPlaneCorners(float xMin, float xMax, float yMin, float yMax)
00079 {
00080 m_xMin = xMin; m_xMax = xMax;
00081 m_yMin = yMin; m_yMax = yMax;
00082 polygonUpToDate=false;
00083 }
00084
00085
00086
00087 void assignImage(
00088 const mrpt::utils::CImage& img,
00089 const mrpt::utils::CImage& imgAlpha );
00090
00091
00092
00093 void assignImage(
00094 const mrpt::utils::CImage& img );
00095
00096
00097
00098 void assignImage_fast(
00099 mrpt::utils::CImage& img,
00100 mrpt::utils::CImage& imgAlpha );
00101
00102
00103
00104 void assignImage_fast(
00105 mrpt::utils::CImage& img );
00106
00107
00108
00109 void render() const;
00110
00111
00112
00113
00114 void loadTextureInOpenGL() const;
00115
00116
00117
00118 static CTexturedPlanePtr Create(
00119 float x_min,
00120 float x_max,
00121 float y_min,
00122 float y_max)
00123 {
00124 return CTexturedPlanePtr( new CTexturedPlane(x_min, x_max, y_min, y_max) );
00125 }
00126
00127
00128
00129 virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const;
00130
00131 private:
00132
00133
00134 CTexturedPlane(
00135 float x_min = -1,
00136 float x_max = 1,
00137 float y_min = -1,
00138 float y_max = 1
00139 );
00140
00141
00142 virtual ~CTexturedPlane();
00143 };
00144
00145 }
00146
00147 }
00148
00149
00150 #endif