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
00029 #ifndef opengl_CMesh_H
00030 #define opengl_CMesh_H
00031
00032 #include <mrpt/opengl/CRenderizable.h>
00033 #include <mrpt/math/CMatrix.h>
00034 #include <mrpt/utils/CMRPTImage.h>
00035 #include <mrpt/vision/utils.h>
00036
00037 namespace mrpt
00038 {
00039 namespace opengl
00040 {
00041 class MRPTDLLIMPEXP CMesh;
00042
00043
00044 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CMesh, CRenderizable )
00045
00046
00050 class MRPTDLLIMPEXP CMesh : public CRenderizable
00051 {
00052 DEFINE_SERIALIZABLE( CMesh )
00053 protected:
00054 mrpt::utils::CMRPTImage m_textureImage;
00055
00056 bool m_enableTransparency;
00057 bool m_colorFromZ;
00058 bool m_isWireFrame;
00059
00060 math::CMatrix Z;
00061 math::CMatrix mask;
00062 math::CMatrix U, V;
00063 math::CMatrix C;
00064
00065 mrpt::vision::TColormap m_colorMap;
00066
00067 bool m_modified_Z;
00068
00069 void updateColorsMatrix();
00070
00071 public:
00072
00073 void enableTransparency( bool v ) { m_enableTransparency = v; }
00074 void enableWireFrame( bool v ) { m_isWireFrame = v; }
00075 void enableColorFromZ( bool v, mrpt::vision::TColormap colorMap = mrpt::vision::cmJET )
00076 {
00077 m_colorFromZ = v;
00078 m_colorMap = colorMap;
00079 }
00080
00082 void setZ( const mrpt::math::CMatrixTemplateNumeric<float> &in_Z );
00083
00085 mrpt::math::CMatrixFloat & getZ();
00086
00088 mrpt::math::CMatrixFloat & getMask();
00089
00091 void setMask( const mrpt::math::CMatrixTemplateNumeric<float> &in_mask );
00092
00094 void setUV( const mrpt::math::CMatrixTemplateNumeric<float> &in_U, const mrpt::math::CMatrixTemplateNumeric<float> &in_V);
00095
00096 float xMin, xMax, yMin, yMax;
00097
00099 static CMeshPtr Create(bool enableTransparency = false, float xMin = 0.0f, float xMax = 0.0f, float yMin = 0.0f, float yMax = 0.0f )
00100 {
00101 return CMeshPtr( new CMesh( enableTransparency, xMin ,xMax , yMin ,yMax ) );
00102 }
00103
00106 void render();
00107
00110 void assignImage(
00111 const utils::CMRPTImage& img );
00112
00113 private:
00116 CMesh( bool enableTransparency = false, float xMin = 0.0f, float xMax = 0.0f, float yMin = 0.0f, float yMax = 0.0f ) :
00117 m_textureImage(0,0),
00118 m_enableTransparency(enableTransparency),
00119 m_colorFromZ(false),
00120 m_isWireFrame(false),
00121 Z(0,0), mask(0,0), U(0,0), V(0,0), C(0,0),
00122 m_colorMap( mrpt::vision::cmJET ),
00123 m_modified_Z(true),
00124 xMin(xMin), xMax(xMax), yMin(yMin), yMax(yMax)
00125 {
00126 m_color_A = 1.0f;
00127 m_color_R = 0.0f;
00128 m_color_G = 0.0f;
00129 m_color_B = 0.6f;
00130 }
00132 virtual ~CMesh() { }
00133
00134 };
00135
00136 }
00137
00138 }
00139
00140 #endif