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



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