Main MRPT website > C++ reference
MRPT logo
CSetOfTexturedTriangles.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2014, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef opengl_CSetOfTexturedTriangles_H
10 #define opengl_CSetOfTexturedTriangles_H
11 
13 
14 namespace mrpt
15 {
16  namespace utils { class CStream; }
17 
18  namespace opengl
19  {
21 
22 
23 
24  // This must be added to any CSerializable derived class:
25  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CSetOfTexturedTriangles, CTexturedObject, OPENGL_IMPEXP )
26 
27  /** A set of textured triangles.
28  * This class can be used to draw any solid, arbitrarily complex object with textures.
29  * \sa opengl::COpenGLScene
30  * \ingroup mrpt_opengl_grp
31  */
33  {
35 
36  public:
37  /** Triangle vertex. This structure encapsulates the vertex coordinates and the image pixels.
38  */
40  {
41  TVertex( ); //!< Default constructor
42  TVertex(float x, float y, float z, uint32_t u, uint32_t v);
43  float m_x, m_y, m_z; //!< 3D vertex coordinates.
44  uint32_t m_u, m_v; //!< 2D texture coordinates. Notice that the texture coordinates are 2D pixels!!!
45  void writeToStream(CStream &out) const;
46  void readFromStream(CStream &in);
47  };
48 
49  /** Triangle. This structure encapsulates the triangle vertices.
50  */
52  {
53  TTriangle( ); //!< Default constructor
54  TTriangle(TVertex v1, TVertex v2, TVertex v3);
55  TVertex m_v1, m_v2, m_v3; //!< vertices
56  void writeToStream(CStream &out) const;
57  void readFromStream(CStream &in);
58  };
59 
60  /** Evaluates the bounding box of this object (including possible children) in the coordinate frame of the object parent. */
61  virtual void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const;
62 
63  protected:
64  /** Triangle array. */
65  std::vector<TTriangle> m_triangles;
66 
67  /** Render */
68  void render_texturedobj( ) const;
69 
70  public:
71  void clearTriangles( ) { m_triangles.clear(); CRenderizableDisplayList::notifyChange(); }
72  size_t getTrianglesCount( ) const { return m_triangles.size(); }
73  const TTriangle & getTriangle( size_t idx) const { ASSERT_(idx<m_triangles.size()); return m_triangles[idx]; }
74  void getTriangle( size_t idx, TTriangle &t ) const { ASSERT_(idx<m_triangles.size()); t = m_triangles[idx]; CRenderizableDisplayList::notifyChange(); }
75  void insertTriangle( const TTriangle &t ) { m_triangles.push_back(t); CRenderizableDisplayList::notifyChange(); }
76 
77 
78  /** Ray Trace
79  */
80  virtual bool traceRay( const mrpt::poses::CPose3D &o,double &dist ) const;
81 
82  private:
83  /** Constructor
84  */
85  CSetOfTexturedTriangles( ) : m_triangles()
86  { }
87 
88  /** Private, virtual destructor: only can be deleted from smart pointers */
89  virtual ~CSetOfTexturedTriangles();
90  };
91  DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE( CSetOfTexturedTriangles, CTexturedObject, OPENGL_IMPEXP )
92 
93  } // end namespace
94 
95 } // End of namespace
96 
97 #endif
uint32_t m_v
2D texture coordinates. Notice that the texture coordinates are 2D pixels!!!
A base class for all OpenGL objects with loadable textures.
EIGEN_STRONG_INLINE const AdjointReturnType t() const
Transpose.
class BASE_IMPEXP CStream
Definition: math_frwds.h:26
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
const TTriangle & getTriangle(size_t idx) const
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
std::vector< TTriangle > m_triangles
Triangle array.
bool BASE_IMPEXP traceRay(const vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
Fast ray tracing method using polygons' properties.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:69
#define ASSERT_(f)
void getTriangle(size_t idx, TTriangle &t) const
Lightweight 3D point.
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014