Main MRPT website > C++ reference for MRPT 1.5.6
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-2017, 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  {
20  // This must be added to any CSerializable derived class:
21  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CSetOfTexturedTriangles, CTexturedObject, OPENGL_IMPEXP )
22 
23  /** A set of textured triangles.
24  * This class can be used to draw any solid, arbitrarily complex object with textures.
25  * \sa opengl::COpenGLScene
26  * \ingroup mrpt_opengl_grp
27  */
29  {
31 
32  public:
33  /** Triangle vertex. This structure encapsulates the vertex coordinates and the image pixels.
34  */
36  {
37  TVertex( ); //!< Default constructor
38  TVertex(float x, float y, float z, uint32_t u, uint32_t v);
39  float m_x, m_y, m_z; //!< 3D vertex coordinates.
40  uint32_t m_u, m_v; //!< 2D texture coordinates. Notice that the texture coordinates are 2D pixels!!!
41  void writeToStream(mrpt::utils::CStream &out) const;
42  void readFromStream(mrpt::utils::CStream &in);
43  };
44 
45  /** Triangle. This structure encapsulates the triangle vertices.
46  */
48  {
49  TTriangle( ); //!< Default constructor
50  TTriangle(TVertex v1, TVertex v2, TVertex v3);
51  TVertex m_v1, m_v2, m_v3; //!< vertices
52  void writeToStream(mrpt::utils::CStream &out) const;
53  void readFromStream(mrpt::utils::CStream &in);
54  };
55 
56  /** Evaluates the bounding box of this object (including possible children) in the coordinate frame of the object parent. */
57  void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE;
58 
59  protected:
60  /** Triangle array. */
61  std::vector<TTriangle> m_triangles;
62 
63  void render_texturedobj( ) const MRPT_OVERRIDE;
64 
65  public:
66  void clearTriangles( ) { m_triangles.clear(); CRenderizableDisplayList::notifyChange(); }
67  size_t getTrianglesCount( ) const { return m_triangles.size(); }
68  const TTriangle & getTriangle( size_t idx) const { ASSERT_(idx<m_triangles.size()); return m_triangles[idx]; }
69  void getTriangle( size_t idx, TTriangle &t ) const { ASSERT_(idx<m_triangles.size()); t = m_triangles[idx]; CRenderizableDisplayList::notifyChange(); }
70  void insertTriangle( const TTriangle &t ) { m_triangles.push_back(t); CRenderizableDisplayList::notifyChange(); }
71 
72 
73  virtual bool traceRay( const mrpt::poses::CPose3D &o,double &dist ) const MRPT_OVERRIDE;
74 
75  private:
76  /** Constructor
77  */
78  CSetOfTexturedTriangles( ) : m_triangles()
79  { }
80 
81  /** Private, virtual destructor: only can be deleted from smart pointers */
82  virtual ~CSetOfTexturedTriangles();
83  };
84  DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE( CSetOfTexturedTriangles, CTexturedObject, OPENGL_IMPEXP )
85 
86  } // end namespace
87 
88 } // End of namespace
89 
90 #endif
const GLdouble * v
Definition: glew.h:1296
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1166
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.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
bool BASE_IMPEXP traceRay(const std::vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
Fast ray tracing method using polygons' properties.
Definition: geometry.cpp:1996
GLfloat GLfloat v1
Definition: glew.h:1759
GLdouble GLdouble t
Definition: glew.h:1303
GLfloat GLfloat GLfloat v2
Definition: glew.h:1763
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
GLuint in
Definition: glew.h:7146
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...
GLint GLint GLint GLint GLint x
Definition: glew.h:1166
std::vector< TTriangle > m_triangles
Triangle array.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
GLdouble GLdouble z
Definition: glew.h:1464
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
#define ASSERT_(f)
void getTriangle(size_t idx, TTriangle &t) const
GLfloat GLfloat GLfloat GLfloat v3
Definition: glew.h:1767
Lightweight 3D point.
unsigned __int32 uint32_t
Definition: rptypes.h:49
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018