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-2018, 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 #pragma once
10 
12 
13 namespace mrpt
14 {
15 namespace opengl
16 {
17 /** A set of textured triangles.
18  * This class can be used to draw any solid, arbitrarily complex object with
19  * textures.
20  * \sa opengl::COpenGLScene
21  * \ingroup mrpt_opengl_grp
22  */
24 {
26 
27  public:
28  /** Triangle vertex. This structure encapsulates the vertex coordinates and
29  * the image pixels.
30  */
31  struct TVertex
32  {
33  /** Default constructor */
34  TVertex();
35  TVertex(float x, float y, float z, uint32_t u, uint32_t v);
36  /** 3D vertex coordinates. */
37  float m_x, m_y, m_z;
38  /** 2D texture coordinates. Notice that the texture coordinates are 2D
39  * pixels!!! */
43  };
44 
45  /** Triangle. This structure encapsulates the triangle vertices.
46  */
47  struct TTriangle
48  {
49  /** Default constructor */
50  TTriangle();
52  /** vertices */
56  };
57 
58  /** Evaluates the bounding box of this object (including possible children)
59  * in the coordinate frame of the object parent. */
60  void getBoundingBox(
61  mrpt::math::TPoint3D& bb_min,
62  mrpt::math::TPoint3D& bb_max) const override;
63 
64  protected:
65  /** Triangle array. */
66  std::vector<TTriangle> m_triangles;
67 
68  void render_texturedobj() const override;
69 
70  public:
72  {
73  m_triangles.clear();
75  }
76  size_t getTrianglesCount() const { return m_triangles.size(); }
77  const TTriangle& getTriangle(size_t idx) const
78  {
79  ASSERT_(idx < m_triangles.size());
80  return m_triangles[idx];
81  }
82  void getTriangle(size_t idx, TTriangle& t) const
83  {
84  ASSERT_(idx < m_triangles.size());
85  t = m_triangles[idx];
87  }
88  void insertTriangle(const TTriangle& t)
89  {
90  m_triangles.push_back(t);
92  }
93 
94  virtual bool traceRay(
95  const mrpt::poses::CPose3D& o, double& dist) const override;
96 
97  /** Constructor
98  */
100  /** Private, virtual destructor: only can be deleted from smart pointers */
101  virtual ~CSetOfTexturedTriangles();
102 };
103 
104 } // namespace opengl
105 } // namespace mrpt
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 render_texturedobj() const override
Must be implemented by derived classes.
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
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.
void writeToStream(mrpt::serialization::CArchive &out) const
void readFromStream(mrpt::serialization::CArchive &in)
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...
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
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 readFromStream(mrpt::serialization::CArchive &in)
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
void writeToStream(mrpt::serialization::CArchive &out) const
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: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019