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/CMRPTImage.h>
00033
00034 namespace mrpt
00035 {
00036 namespace opengl
00037 {
00038 class MRPTDLLIMPEXP CTexturedPlane;
00039
00040
00041 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CTexturedPlane, CRenderizable )
00042
00043
00046 class MRPTDLLIMPEXP CTexturedPlane : public CRenderizable
00047 {
00048 DEFINE_SERIALIZABLE( CTexturedPlane )
00049 protected:
00050 mutable unsigned int m_glTextureName;
00051 mutable bool m_init;
00052 mutable mrpt::utils::CMRPTImage m_textureImage;
00053 mutable mrpt::utils::CMRPTImage m_textureImageAlpha;
00054 mutable bool m_enableTransparency;
00055 mutable int r_width,r_height;
00056
00057 mutable float m_tex_x_min,m_tex_x_max;
00058 mutable float m_tex_y_min,m_tex_y_max;
00059
00060 float m_xMin, m_xMax;
00061 float m_yMin, m_yMax;
00062
00063 public:
00065 void setTextureCornerCoords( float tex_x_min, float tex_x_max, float tex_y_min, float tex_y_max)
00066 {
00067 m_tex_x_min=tex_x_min;
00068 m_tex_x_max=tex_x_max;
00069 m_tex_y_min=tex_y_min;
00070 m_tex_y_max=tex_y_max;
00071 }
00072
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 }
00079
00082 void assignImage(
00083 const mrpt::utils::CMRPTImage& img,
00084 const mrpt::utils::CMRPTImage& imgAlpha );
00085
00088 void assignImage(
00089 const mrpt::utils::CMRPTImage& img );
00090
00093 void assignImage_fast(
00094 mrpt::utils::CMRPTImage& img,
00095 mrpt::utils::CMRPTImage& imgAlpha );
00096
00099 void assignImage_fast(
00100 mrpt::utils::CMRPTImage& img );
00101
00104 void render() const;
00105
00109 void loadTextureInOpenGL() const;
00110
00111
00113 static CTexturedPlanePtr Create(
00114 float x_min = -1,
00115 float x_max = 1,
00116 float y_min = -1,
00117 float y_max = 1 )
00118 {
00119 return CTexturedPlanePtr( new CTexturedPlane(x_min, x_max, y_min, y_max) );
00120 }
00121
00124 virtual bool traceRay(const mrpt::poses::CPose3D &o,float &dist) const;
00125
00126 private:
00129 CTexturedPlane(
00130 float x_min = -1,
00131 float x_max = 1,
00132 float y_min = -1,
00133 float y_max = 1
00134 );
00135
00137 virtual ~CTexturedPlane();
00138 };
00139
00140 }
00141
00142 }
00143
00144
00145 #endif