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::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, m_y, m_z;
36  /** 2D texture coordinates. Notice that the texture coordinates are 2D
37  * pixels!!! */
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(
59  mrpt::math::TPoint3D& bb_min,
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  virtual bool traceRay(
93  const mrpt::poses::CPose3D& o, double& dist) const override;
94 
95  /** Constructor
96  */
98  /** Private, virtual destructor: only can be deleted from smart pointers */
99  virtual ~CSetOfTexturedTriangles();
100 };
101 
102 }
103 
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
#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:52
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:86
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
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020