Go to the documentation of this file.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_CSetOfTexturedTriangles_H
00029 #define opengl_CSetOfTexturedTriangles_H
00030
00031 #include <mrpt/opengl/CTexturedObject.h>
00032
00033 namespace mrpt
00034 {
00035 namespace utils { class CStream; }
00036
00037 namespace opengl
00038 {
00039 using mrpt::utils::CStream;
00040
00041 class OPENGL_IMPEXP CSetOfTexturedTriangles;
00042
00043
00044 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CSetOfTexturedTriangles, CTexturedObject, OPENGL_IMPEXP )
00045
00046
00047
00048
00049
00050
00051 class OPENGL_IMPEXP CSetOfTexturedTriangles : public CTexturedObject
00052 {
00053 DEFINE_SERIALIZABLE( CSetOfTexturedTriangles )
00054
00055 public:
00056
00057
00058 struct OPENGL_IMPEXP TVertex
00059 {
00060
00061 TVertex( ) :
00062 m_x(0.0), m_y(0.0), m_z(0.0), m_u(0), m_v(0) { }
00063
00064 TVertex(float x, float y, float z, uint32_t u, uint32_t v) :
00065 m_x(x), m_y(y), m_z(z), m_u(u), m_v(v) { }
00066
00067 float m_x, m_y, m_z;
00068
00069 uint32_t m_u, m_v;
00070
00071 void writeToStream(CStream &out) const { out << m_x << m_y << m_z << m_u << m_v; }
00072 void readFromStream(CStream &in) { in >> m_x >> m_y >> m_z >> m_u >> m_v; }
00073 };
00074
00075
00076
00077 struct OPENGL_IMPEXP TTriangle
00078 {
00079
00080 TTriangle( ) :
00081 m_v1(), m_v2(), m_v3() { }
00082
00083 TTriangle(TVertex v1, TVertex v2, TVertex v3) :
00084 m_v1(v1), m_v2(v2), m_v3(v3) { }
00085
00086 TVertex m_v1, m_v2, m_v3;
00087
00088 void writeToStream(CStream &out) const { m_v1.writeToStream(out); m_v2.writeToStream(out); m_v3.writeToStream(out); }
00089 void readFromStream(CStream &in) { m_v1.readFromStream(in); m_v2.readFromStream(in); m_v3.readFromStream(in); }
00090 };
00091
00092 protected:
00093
00094 std::vector<TTriangle> m_triangles;
00095
00096
00097 void render_texturedobj( ) const;
00098
00099 public:
00100 void clearTriangles( ) { m_triangles.clear(); CRenderizableDisplayList::notifyChange(); }
00101 size_t getTrianglesCount( ) const { return m_triangles.size(); }
00102 const TTriangle & getTriangle( size_t idx) const { ASSERT_(idx<m_triangles.size()); return m_triangles[idx]; }
00103 void getTriangle( size_t idx, TTriangle &t ) const { ASSERT_(idx<m_triangles.size()); t = m_triangles[idx]; CRenderizableDisplayList::notifyChange(); }
00104 void insertTriangle( const TTriangle &t ) { m_triangles.push_back(t); CRenderizableDisplayList::notifyChange(); }
00105
00106
00107
00108
00109 virtual bool traceRay( const mrpt::poses::CPose3D &o,double &dist ) const;
00110
00111 private:
00112
00113
00114 CSetOfTexturedTriangles( ) : m_triangles()
00115 { }
00116
00117
00118 virtual ~CSetOfTexturedTriangles();
00119 };
00120
00121 }
00122
00123 }
00124
00125 #endif