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
mrpt::opengl::CSetOfTexturedTriangles::TVertex::m_x
float m_x
3D vertex coordinates.
Definition: CSetOfTexturedTriangles.h:37
mrpt::opengl::CSetOfTexturedTriangles::TVertex::m_z
float m_z
Definition: CSetOfTexturedTriangles.h:37
mrpt::opengl::CSetOfTexturedTriangles::TVertex::TVertex
TVertex()
Default constructor
Definition: CSetOfTexturedTriangles.cpp:185
mrpt::opengl::CSetOfTexturedTriangles::TTriangle::TTriangle
TTriangle()
Default constructor.
Definition: CSetOfTexturedTriangles.cpp:207
t
GLdouble GLdouble t
Definition: glext.h:3689
mrpt::opengl::CSetOfTexturedTriangles::TVertex::readFromStream
void readFromStream(mrpt::serialization::CArchive &in)
Definition: CSetOfTexturedTriangles.cpp:201
mrpt::opengl::CSetOfTexturedTriangles::TTriangle::writeToStream
void writeToStream(mrpt::serialization::CArchive &out) const
Definition: CSetOfTexturedTriangles.cpp:214
mrpt::opengl::CSetOfTexturedTriangles::TTriangle::readFromStream
void readFromStream(mrpt::serialization::CArchive &in)
Definition: CSetOfTexturedTriangles.cpp:221
mrpt::opengl::CRenderizableDisplayList::notifyChange
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
Definition: CRenderizableDisplayList.h:57
mrpt::opengl::CSetOfTexturedTriangles::TTriangle
Triangle.
Definition: CSetOfTexturedTriangles.h:47
mrpt::opengl::CSetOfTexturedTriangles::CSetOfTexturedTriangles
CSetOfTexturedTriangles()
Constructor.
Definition: CSetOfTexturedTriangles.h:99
mrpt::opengl::CSetOfTexturedTriangles::getTrianglesCount
size_t getTrianglesCount() const
Definition: CSetOfTexturedTriangles.h:76
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
ASSERT_
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
mrpt::opengl::CSetOfTexturedTriangles::TVertex::writeToStream
void writeToStream(mrpt::serialization::CArchive &out) const
Definition: CSetOfTexturedTriangles.cpp:196
mrpt::opengl::CSetOfTexturedTriangles::getBoundingBox
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...
Definition: CSetOfTexturedTriangles.cpp:143
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
v
const GLdouble * v
Definition: glext.h:3678
mrpt::opengl::CSetOfTexturedTriangles::TTriangle::m_v3
TVertex m_v3
Definition: CSetOfTexturedTriangles.h:53
v1
GLfloat GLfloat v1
Definition: glext.h:4105
mrpt::opengl::CSetOfTexturedTriangles::~CSetOfTexturedTriangles
virtual ~CSetOfTexturedTriangles()
Private, virtual destructor: only can be deleted from smart pointers.
v2
GLfloat GLfloat GLfloat v2
Definition: glext.h:4107
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::opengl::CSetOfTexturedTriangles::getTriangle
void getTriangle(size_t idx, TTriangle &t) const
Definition: CSetOfTexturedTriangles.h:82
mrpt::opengl::CSetOfTexturedTriangles::insertTriangle
void insertTriangle(const TTriangle &t)
Definition: CSetOfTexturedTriangles.h:88
mrpt::opengl::CSetOfTexturedTriangles::getTriangle
const TTriangle & getTriangle(size_t idx) const
Definition: CSetOfTexturedTriangles.h:77
mrpt::opengl::CSetOfTexturedTriangles::TVertex
Triangle vertex.
Definition: CSetOfTexturedTriangles.h:31
mrpt::opengl::CTexturedObject
A base class for all OpenGL objects with loadable textures.
Definition: CTexturedObject.h:25
mrpt::opengl::CSetOfTexturedTriangles::TVertex::m_v
uint32_t m_v
Definition: CSetOfTexturedTriangles.h:40
v3
GLfloat GLfloat GLfloat GLfloat v3
Definition: glext.h:4109
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
mrpt::opengl::CSetOfTexturedTriangles::TVertex::m_y
float m_y
Definition: CSetOfTexturedTriangles.h:37
mrpt::opengl::CSetOfTexturedTriangles::traceRay
virtual bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Simulation of ray-trace, given a pose.
Definition: CSetOfTexturedTriangles.cpp:134
mrpt::opengl::CSetOfTexturedTriangles::render_texturedobj
void render_texturedobj() const override
Must be implemented by derived classes.
Definition: CSetOfTexturedTriangles.cpp:33
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::opengl::CSetOfTexturedTriangles::m_triangles
std::vector< TTriangle > m_triangles
Triangle array.
Definition: CSetOfTexturedTriangles.h:66
mrpt::opengl::CSetOfTexturedTriangles::TTriangle::m_v2
TVertex m_v2
Definition: CSetOfTexturedTriangles.h:53
mrpt::opengl::CSetOfTexturedTriangles::clearTriangles
void clearTriangles()
Definition: CSetOfTexturedTriangles.h:71
z
GLdouble GLdouble z
Definition: glext.h:3872
in
GLuint in
Definition: glext.h:7274
mrpt::opengl::CSetOfTexturedTriangles
A set of textured triangles.
Definition: CSetOfTexturedTriangles.h:23
CTexturedObject.h
mrpt::opengl::CSetOfTexturedTriangles::TVertex::m_u
uint32_t m_u
2D texture coordinates.
Definition: CSetOfTexturedTriangles.h:40
y
GLenum GLint GLint y
Definition: glext.h:3538
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47
x
GLenum GLint x
Definition: glext.h:3538
mrpt::opengl::CSetOfTexturedTriangles::TTriangle::m_v1
TVertex m_v1
vertices
Definition: CSetOfTexturedTriangles.h:53



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST