MRPT  1.9.9
CSetOfTexturedTriangles.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
12 
13 namespace mrpt::opengl
14 {
15 /** A set of textured triangles.
16  * This class can be used to draw any solid, arbitrarily complex object with
17  * textures.
18  * \sa opengl::COpenGLScene
19  * \ingroup mrpt_opengl_grp
20  */
22 {
24 
25  public:
26  /** Triangle vertex. This structure encapsulates the vertex coordinates and
27  * the image pixels.
28  */
29  struct TVertex
30  {
31  /** Default constructor */
32  TVertex();
33  TVertex(float x, float y, float z, uint32_t u, uint32_t v);
34  /** 3D vertex coordinates. */
35  float m_x{0.0}, m_y{0.0}, m_z{0.0};
36  /** 2D texture coordinates. Notice that the texture coordinates are 2D
37  * pixels!!! */
38  uint32_t m_u{0}, m_v{0};
41  };
42 
43  /** Triangle. This structure encapsulates the triangle vertices.
44  */
45  struct TTriangle
46  {
47  /** Default constructor */
48  TTriangle();
50  /** vertices */
54  };
55 
56  /** Evaluates the bounding box of this object (including possible children)
57  * in the coordinate frame of the object parent. */
58  void getBoundingBox(
60  mrpt::math::TPoint3D& bb_max) const override;
61 
62  protected:
63  /** Triangle array. */
64  std::vector<TTriangle> m_triangles;
65 
66  void render_texturedobj() const override;
67 
68  public:
70  {
71  m_triangles.clear();
73  }
74  size_t getTrianglesCount() const { return m_triangles.size(); }
75  const TTriangle& getTriangle(size_t idx) const
76  {
77  ASSERT_(idx < m_triangles.size());
78  return m_triangles[idx];
79  }
80  void getTriangle(size_t idx, TTriangle& t) const
81  {
82  ASSERT_(idx < m_triangles.size());
83  t = m_triangles[idx];
85  }
86  void insertTriangle(const TTriangle& t)
87  {
88  m_triangles.push_back(t);
90  }
91 
92  bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override;
93 
94  /** Constructor
95  */
97  /** Private, virtual destructor: only can be deleted from smart pointers */
98  ~CSetOfTexturedTriangles() override;
99 };
100 
101 } // namespace mrpt::opengl
void getTriangle(size_t idx, TTriangle &t) const
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
GLdouble GLdouble t
Definition: glext.h:3695
GLdouble GLdouble z
Definition: glext.h:3879
A base class for all OpenGL objects with loadable textures.
const TTriangle & getTriangle(size_t idx) const
~CSetOfTexturedTriangles() override
Private, virtual destructor: only can be deleted from smart pointers.
void render_texturedobj() const override
Must be implemented by derived classes.
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
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:4125
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:3684
#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:53
GLfloat GLfloat v1
Definition: glext.h:4121
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:84
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:7391
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
const auto bb_max
void writeToStream(mrpt::serialization::CArchive &out) const
GLenum GLint GLint y
Definition: glext.h:3542
const auto bb_min
GLfloat GLfloat GLfloat v2
Definition: glext.h:4123
GLenum GLint x
Definition: glext.h:3542
Lightweight 3D point.
Definition: TPoint3D.h:90
unsigned __int32 uint32_t
Definition: rptypes.h:50



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019