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_texture_is_loaded;
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
00064 mutable bool polygonUpToDate;
00065 mutable std::vector<mrpt::math::TPolygonWithPlane> tmpPoly;
00066 void updatePoly() const;
00067 void unloadTexture();
00068
00069 public:
00070
00071 void setTextureCornerCoords( float tex_x_min, float tex_x_max, float tex_y_min, float tex_y_max)
00072 {
00073 m_tex_x_min=tex_x_min;
00074 m_tex_x_max=tex_x_max;
00075 m_tex_y_min=tex_y_min;
00076 m_tex_y_max=tex_y_max;
00077 }
00078
00079
00080 void setPlaneCorners(float xMin, float xMax, float yMin, float yMax)
00081 {
00082 m_xMin = xMin; m_xMax = xMax;
00083 m_yMin = yMin; m_yMax = yMax;
00084 polygonUpToDate=false;
00085 }
00086
00087
00088
00089 void assignImage(
00090 const mrpt::utils::CImage& img,
00091 const mrpt::utils::CImage& imgAlpha );
00092
00093
00094
00095 void assignImage(
00096 const mrpt::utils::CImage& img );
00097
00098
00099
00100 void assignImage_fast(
00101 mrpt::utils::CImage& img,
00102 mrpt::utils::CImage& imgAlpha );
00103
00104
00105
00106 void assignImage_fast(
00107 mrpt::utils::CImage& img );
00108
00109
00110
00111 void render() const;
00112
00113
00114
00115
00116 void loadTextureInOpenGL() const;
00117
00118
00119
00120 static CTexturedPlanePtr Create(
00121 float x_min,
00122 float x_max,
00123 float y_min,
00124 float y_max)
00125 {
00126 return CTexturedPlanePtr( new CTexturedPlane(x_min, x_max, y_min, y_max) );
00127 }
00128
00129
00130
00131 virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const;
00132
00133 private:
00134
00135
00136 CTexturedPlane(
00137 float x_min = -1,
00138 float x_max = 1,
00139 float y_min = -1,
00140 float y_max = 1
00141 );
00142
00143
00144 virtual ~CTexturedPlane();
00145 };
00146
00147 }
00148
00149 }
00150
00151
00152 #endif