Main MRPT website > C++ reference for MRPT 1.9.9
CFrustum.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 #ifndef opengl_CFrustum_H
10 #define opengl_CFrustum_H
11 
14 
15 namespace mrpt
16 {
17 namespace opengl
18 {
19 /** A solid or wireframe frustum in 3D (a rectangular truncated pyramid), with
20  * arbitrary (possibly assymetric) field-of-view angles.
21  *
22  * You can switch whether to show only the lines, the surface of the frustum,
23  * or both.
24  * By default only the lines are drawn.
25  *
26  * The color of the object (via CRenderizable::setColor()) affects the color
27  * of lines.
28  * To set the color of planes use \a setPlaneColor()
29  *
30  * As usual in MRPT, the +X axis is assumed to by the main direction, in this
31  * case of the pyramid axis.
32  *
33  * The horizontal and vertical FOVs can be set directly with \a setHorzFOV()
34  * and \a setVertFOV() if
35  * they are symmetric, or with \a setHorzFOVAsymmetric() and \a
36  * setVertFOVAsymmetric() otherwise.
37  *
38  * All FOV angles are positive numbers. FOVs must be below 90deg on each side
39  * (below 180deg in total).
40  * If you try to set FOVs to larger values they'll truncated to 89.9deg.
41  *
42  * \sa opengl::COpenGLScene,opengl::CRenderizable
43  *
44  * <div align="center">
45  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
46  * border-style: solid;">
47  * <tr> <td> mrpt::opengl::CFrustum </td> <td> \image html
48  * preview_CFrustum.png </td> </tr>
49  * </table>
50  * </div>
51  *
52  * \ingroup mrpt_opengl_grp
53  */
55 {
57 
58  protected:
59  /** Near and far planes */
61  /** Semi FOVs (in radians) */
63  /** Semi FOVs (in radians) */
66  float m_lineWidth;
68 
69  public:
70  /** Constructor returning a smart pointer to the newly created object. */
71  static CFrustum::Ptr Create(
72  float near_distance, float far_distance, float horz_FOV_degrees,
73  float vert_FOV_degrees, float lineWidth = 1.5f, bool draw_lines = true,
74  bool draw_planes = false);
75 
76  inline void setLineWidth(float width)
77  {
80  }
81  inline float getLineWidth() const { return m_lineWidth; }
82  /** Changes the color of the planes; to change color of lines, use
83  * CRenderizable base methods. */
84  inline void setPlaneColor(const mrpt::img::TColor& c)
85  {
86  m_planes_color = c;
88  }
89  inline const mrpt::img::TColor& getPlaneColor() const
90  {
91  return m_planes_color;
92  }
93 
94  /** Changes distance of near & far planes */
95  void setNearFarPlanes(const float near_distance, const float far_distance);
96 
97  float getNearPlaneDistance() const { return m_min_distance; }
98  float getFarPlaneDistance() const { return m_max_distance; }
99  /** Changes horizontal FOV (symmetric) */
100  void setHorzFOV(const float fov_horz_degrees);
101  /** Changes vertical FOV (symmetric) */
102  void setVertFOV(const float fov_vert_degrees);
103  /** Changes horizontal FOV (asymmetric) */
105  const float fov_horz_left_degrees, const float fov_horz_right_degrees);
106  /** Changes vertical FOV (asymmetric) */
108  const float fov_vert_down_degrees, const float fov_vert_up_degrees);
109 
110  float getHorzFOV() const
111  {
113  }
114  float getVertFOV() const
115  {
117  }
118  float getHorzFOVLeft() const { return mrpt::RAD2DEG(m_fov_horz_left); }
119  float getHorzFOVRight() const { return mrpt::RAD2DEG(m_fov_horz_right); }
120  float getVertFOVDown() const { return mrpt::RAD2DEG(m_fov_vert_down); }
121  float getVertFOVUp() const { return mrpt::RAD2DEG(m_fov_vert_up); }
122  /** Render \sa mrpt::opengl::CRenderizable */
123  void render_dl() const override;
124 
125  /** Ray tracing. \sa mrpt::opengl::CRenderizable */
126  bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override;
127 
128  /** Evaluates the bounding box of this object (including possible children)
129  * in the coordinate frame of the object parent. */
130  void getBoundingBox(
131  mrpt::math::TPoint3D& bb_min,
132  mrpt::math::TPoint3D& bb_max) const override;
133 
134  /** Basic empty constructor. Set all parameters to default. */
135  CFrustum();
136  /** Constructor with some parameters */
137  CFrustum(
138  float near_distance, float far_distance, float horz_FOV_degrees,
139  float vert_FOV_degrees, float lineWidth, bool draw_lines,
140  bool draw_planes);
141 
142  /** Destructor */
143  virtual ~CFrustum() {}
144 };
145 }
146 }
147 #endif
mrpt::opengl::CFrustum::m_draw_planes
bool m_draw_planes
Definition: CFrustum.h:65
mrpt::opengl::CFrustum::m_fov_vert_up
float m_fov_vert_up
Definition: CFrustum.h:64
mrpt::opengl::CFrustum::getPlaneColor
const mrpt::img::TColor & getPlaneColor() const
Definition: CFrustum.h:89
mrpt::opengl::CFrustum::m_planes_color
mrpt::img::TColor m_planes_color
Definition: CFrustum.h:67
mrpt::opengl::CFrustum::getVertFOVUp
float getVertFOVUp() const
Definition: CFrustum.h:121
mrpt::opengl::CFrustum::setHorzFOVAsymmetric
void setHorzFOVAsymmetric(const float fov_horz_left_degrees, const float fov_horz_right_degrees)
Changes horizontal FOV (asymmetric)
Definition: CFrustum.cpp:204
mrpt::opengl::CFrustum::setLineWidth
void setLineWidth(float width)
Definition: CFrustum.h:76
mrpt::opengl::CFrustum::setNearFarPlanes
void setNearFarPlanes(const float near_distance, const float far_distance)
Changes distance of near & far planes.
Definition: CFrustum.cpp:179
mrpt::opengl::CFrustum::setPlaneColor
void setPlaneColor(const mrpt::img::TColor &c)
Changes the color of the planes; to change color of lines, use CRenderizable base methods.
Definition: CFrustum.h:84
mrpt::opengl::CFrustum::getFarPlaneDistance
float getFarPlaneDistance() const
Definition: CFrustum.h:98
CRenderizableDisplayList.h
c
const GLubyte * c
Definition: glext.h:6313
mrpt::opengl::CFrustum::m_fov_horz_left
float m_fov_horz_left
Semi FOVs (in radians)
Definition: CFrustum.h:62
mrpt::opengl::CRenderizableDisplayList
A renderizable object suitable for rendering with OpenGL's display lists.
Definition: CRenderizableDisplayList.h:39
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::CFrustum::m_max_distance
float m_max_distance
Definition: CFrustum.h:60
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::opengl::CFrustum::getVertFOVDown
float getVertFOVDown() const
Definition: CFrustum.h:120
mrpt::RAD2DEG
double RAD2DEG(const double x)
Radians to degrees.
Definition: core/include/mrpt/core/bits_math.h:48
mrpt::opengl::CFrustum::getHorzFOV
float getHorzFOV() const
Definition: CFrustum.h:110
mrpt::opengl::CFrustum::setVertFOVAsymmetric
void setVertFOVAsymmetric(const float fov_vert_down_degrees, const float fov_vert_up_degrees)
Changes vertical FOV (asymmetric)
Definition: CFrustum.cpp:215
mrpt::opengl::CFrustum::Ptr
std::shared_ptr< CFrustum > Ptr
Definition: CFrustum.h:56
mrpt::opengl::CFrustum::getLineWidth
float getLineWidth() const
Definition: CFrustum.h:81
lightweight_geom_data.h
mrpt::opengl::CFrustum::m_lineWidth
float m_lineWidth
Definition: CFrustum.h:66
mrpt::opengl::CFrustum::setVertFOV
void setVertFOV(const float fov_vert_degrees)
Changes vertical FOV (symmetric)
Definition: CFrustum.cpp:195
mrpt::opengl::CFrustum::render_dl
void render_dl() const override
Render.
Definition: CFrustum.cpp:28
mrpt::opengl::CFrustum::getVertFOV
float getVertFOV() const
Definition: CFrustum.h:114
mrpt::opengl::CFrustum::getHorzFOVLeft
float getHorzFOVLeft() const
Definition: CFrustum.h:118
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::img::TColor
A RGB color - 8bit.
Definition: TColor.h:22
mrpt::opengl::CFrustum::setHorzFOV
void setHorzFOV(const float fov_horz_degrees)
Changes horizontal FOV (symmetric)
Definition: CFrustum.cpp:186
mrpt::opengl::CFrustum::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: CFrustum.cpp:227
mrpt::opengl::CFrustum
A solid or wireframe frustum in 3D (a rectangular truncated pyramid), with arbitrary (possibly assyme...
Definition: CFrustum.h:54
mrpt::opengl::CFrustum::Create
static Ptr Create(Args &&... args)
Definition: CFrustum.h:56
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
mrpt::opengl::CFrustum::m_fov_vert_down
float m_fov_vert_down
Semi FOVs (in radians)
Definition: CFrustum.h:64
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::CFrustum::traceRay
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray tracing.
Definition: CFrustum.cpp:171
width
GLenum GLsizei width
Definition: glext.h:3531
mrpt::opengl::CFrustum::m_fov_horz_right
float m_fov_horz_right
Definition: CFrustum.h:62
mrpt::opengl::CFrustum::getHorzFOVRight
float getHorzFOVRight() const
Definition: CFrustum.h:119
mrpt::opengl::CFrustum::m_draw_lines
bool m_draw_lines
Definition: CFrustum.h:65
mrpt::opengl::CFrustum::CFrustum
CFrustum()
Basic empty constructor.
Definition: CFrustum.cpp:104
mrpt::opengl::CFrustum::getNearPlaneDistance
float getNearPlaneDistance() const
Definition: CFrustum.h:97
mrpt::opengl::CFrustum::m_min_distance
float m_min_distance
Near and far planes.
Definition: CFrustum.h:60
mrpt::opengl::CFrustum::~CFrustum
virtual ~CFrustum()
Destructor
Definition: CFrustum.h:143



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