Main MRPT website > C++ reference for MRPT 1.5.9
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
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
void getTriangle(size_t idx, TTriangle &t) const
uint32_t m_v
2D texture coordinates. Notice that the texture coordinates are 2D pixels!!!
GLdouble GLdouble t
Definition: glext.h:3610
GLdouble GLdouble z
Definition: glext.h:3734
A base class for all OpenGL objects with loadable textures.
const TTriangle & getTriangle(size_t idx) const
#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&#39; properties.
Definition: geometry.cpp:1989
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
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...
GLfloat GLfloat GLfloat GLfloat v3
Definition: glext.h:3924
std::vector< TTriangle > m_triangles
Triangle array.
const GLdouble * v
Definition: glext.h:3603
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...
GLfloat GLfloat v1
Definition: glext.h:3922
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
GLuint in
Definition: glext.h:6301
#define ASSERT_(f)
GLenum GLint GLint y
Definition: glext.h:3516
GLfloat GLfloat GLfloat v2
Definition: glext.h:3923
GLenum GLint x
Definition: glext.h:3516
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.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020