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
float getHorzFOVLeft() const
Definition: CFrustum.h:118
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:97
float m_min_distance
Near and far planes.
Definition: CFrustum.h:60
void setVertFOV(const float fov_vert_degrees)
Changes vertical FOV (symmetric)
Definition: CFrustum.cpp:195
float getHorzFOVRight() const
Definition: CFrustum.h:119
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:121
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:84
CFrustum()
Basic empty constructor.
Definition: CFrustum.cpp:104
const GLubyte * c
Definition: glext.h:6313
float getLineWidth() const
Definition: CFrustum.h:81
static Ptr Create(Args &&... args)
Definition: CFrustum.h:56
float getHorzFOV() const
Definition: CFrustum.h:110
const mrpt::img::TColor & getPlaneColor() const
Definition: CFrustum.h:89
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#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:76
mrpt::img::TColor m_planes_color
Definition: CFrustum.h:67
float m_fov_horz_left
Semi FOVs (in radians)
Definition: CFrustum.h:62
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
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
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:143
A solid or wireframe frustum in 3D (a rectangular truncated pyramid), with arbitrary (possibly assyme...
Definition: CFrustum.h:54
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:22
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:114
float getFarPlaneDistance() const
Definition: CFrustum.h:98
float m_fov_vert_down
Semi FOVs (in radians)
Definition: CFrustum.h:64
float getVertFOVDown() const
Definition: CFrustum.h:120



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019