Main MRPT website > C++ reference for MRPT 1.9.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
17 {
18 class CStream;
19 }
20 
21 namespace opengl
22 {
23 /** A set of textured triangles.
24  * This class can be used to draw any solid, arbitrarily complex object with
25  * textures.
26  * \sa opengl::COpenGLScene
27  * \ingroup mrpt_opengl_grp
28  */
30 {
32 
33  public:
34  /** Triangle vertex. This structure encapsulates the vertex coordinates and
35  * the image pixels.
36  */
37  struct TVertex
38  {
39  /** Default constructor */
40  TVertex();
41  TVertex(float x, float y, float z, uint32_t u, uint32_t v);
42  /** 3D vertex coordinates. */
43  float m_x, m_y, m_z;
44  /** 2D texture coordinates. Notice that the texture coordinates are 2D
45  * pixels!!! */
47  void writeToStream(mrpt::utils::CStream& out) const;
49  };
50 
51  /** Triangle. This structure encapsulates the triangle vertices.
52  */
53  struct TTriangle
54  {
55  /** Default constructor */
56  TTriangle();
58  /** vertices */
60  void writeToStream(mrpt::utils::CStream& out) const;
62  };
63 
64  /** Evaluates the bounding box of this object (including possible children)
65  * in the coordinate frame of the object parent. */
66  void getBoundingBox(
67  mrpt::math::TPoint3D& bb_min,
68  mrpt::math::TPoint3D& bb_max) const override;
69 
70  protected:
71  /** Triangle array. */
72  std::vector<TTriangle> m_triangles;
73 
74  void render_texturedobj() const override;
75 
76  public:
78  {
79  m_triangles.clear();
81  }
82  size_t getTrianglesCount() const { return m_triangles.size(); }
83  const TTriangle& getTriangle(size_t idx) const
84  {
85  ASSERT_(idx < m_triangles.size());
86  return m_triangles[idx];
87  }
88  void getTriangle(size_t idx, TTriangle& t) const
89  {
90  ASSERT_(idx < m_triangles.size());
91  t = m_triangles[idx];
93  }
94  void insertTriangle(const TTriangle& t)
95  {
96  m_triangles.push_back(t);
98  }
99 
100  virtual bool traceRay(
101  const mrpt::poses::CPose3D& o, double& dist) const override;
102 
103  /** Constructor
104  */
106  /** Private, virtual destructor: only can be deleted from smart pointers */
107  virtual ~CSetOfTexturedTriangles();
108 };
109 
110 } // end namespace
111 
112 } // End of namespace
113 
114 #endif
void getTriangle(size_t idx, TTriangle &t) const
GLdouble GLdouble t
Definition: glext.h:3689
GLdouble GLdouble z
Definition: glext.h:3872
A base class for all OpenGL objects with loadable textures.
const TTriangle & getTriangle(size_t idx) const
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
void writeToStream(mrpt::utils::CStream &out) const
void render_texturedobj() const override
Must be implemented by derived classes.
void writeToStream(mrpt::utils::CStream &out) const
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
virtual bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Simulation of ray-trace, given a pose.
GLfloat GLfloat GLfloat GLfloat v3
Definition: glext.h:4109
std::vector< TTriangle > m_triangles
Triangle array.
const GLdouble * v
Definition: glext.h:3678
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:4105
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
virtual ~CSetOfTexturedTriangles()
Private, virtual destructor: only can be deleted from smart pointers.
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
GLuint in
Definition: glext.h:7274
#define ASSERT_(f)
GLenum GLint GLint y
Definition: glext.h:3538
GLfloat GLfloat GLfloat v2
Definition: glext.h:4107
GLenum GLint x
Definition: glext.h:3538
Lightweight 3D point.
unsigned __int32 uint32_t
Definition: rptypes.h:47



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019