MRPT  1.9.9
CCamera.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
14 
15 namespace mrpt::opengl
16 {
17 class COpenGLViewport;
18 class CCamera;
19 
20 /** A camera: if added to a scene, the viewpoint defined by this camera will be
21  * used instead of the camera parameters set in COpenGLViewport::m_camera.
22  * A camera can be defined to provide a projective or orthogonal view of the
23  * world by setting the member CCamera::m_projectiveModel.
24  * \sa opengl::COpenGLScene
25  * \ingroup mrpt_opengl_grp
26  */
27 class CCamera : public CRenderizable
28 {
29  friend class COpenGLViewport;
30 
32  protected:
34  float m_distanceZoom{10};
35  float m_azimuthDeg{45}, m_elevationDeg{45};
36 
37  /** If set to true (default), camera model is projective, otherwise, it's
38  * orthogonal. */
39  bool m_projectiveModel{true};
40  /** Field-of-View in degs, only when projectiveModel=true (default=30 deg).
41  */
42  float m_projectiveFOVdeg{30};
43  /** If set to true, camera pose is used when rendering the viewport */
44  bool m_6DOFMode{false};
45 
46  public:
47  void setPointingAt(float x, float y, float z)
48  {
49  m_pointingX = x;
50  m_pointingY = y;
51  m_pointingZ = z;
52  }
53 
54  template <class POSEORPOINT>
55  void setPointingAt(const POSEORPOINT& p)
56  {
57  m_pointingX = p.x();
58  m_pointingY = p.y();
59  m_pointingZ = p.is3DPoseOrPoint() ? p.m_coords[2] : 0;
60  }
61  inline void setPointingAt(const mrpt::math::TPoint3D& p)
62  {
63  setPointingAt(p.x, p.y, p.z);
64  }
65 
66  float getPointingAtX() const { return m_pointingX; }
67  float getPointingAtY() const { return m_pointingY; }
68  float getPointingAtZ() const { return m_pointingZ; }
69  void setZoomDistance(float z) { m_distanceZoom = z; }
70  float getZoomDistance() const { return m_distanceZoom; }
71  float getAzimuthDegrees() const { return m_azimuthDeg; }
72  float getElevationDegrees() const { return m_elevationDeg; }
73  void setAzimuthDegrees(float ang) { m_azimuthDeg = ang; }
74  void setElevationDegrees(float ang) { m_elevationDeg = ang; }
75  /** Enable/Disable projective mode (vs. orthogonal) */
76  void setProjectiveModel(bool v = true) { m_projectiveModel = v; }
77  /** Enable/Disable orthogonal mode (vs. projective) */
78  void setOrthogonal(bool v = true) { m_projectiveModel = !v; }
79  /** Set 6DOFMode, if enabled camera is set according to its pose
80  *(default=false).
81  * Conventionally, eye is set looking towards the positive direction of Z
82  *axis.
83  * Up is set as the Y axis.
84  * In this mode azimuth/elevation are ignored.
85  **/
86  void set6DOFMode(bool v) { m_6DOFMode = v; }
87  bool isProjective() const { return m_projectiveModel; }
88  bool isOrthogonal() const { return !m_projectiveModel; }
89  bool is6DOFMode() const { return m_6DOFMode; }
90  /** Field-of-View in degs, only when projectiveModel=true (default=30 deg).
91  */
92  void setProjectiveFOVdeg(float ang) { m_projectiveFOVdeg = ang; }
93  /** Field-of-View in degs, only when projectiveModel=true (default=30 deg).
94  */
95  float getProjectiveFOVdeg() const { return m_projectiveFOVdeg; }
96  /** Render does nothing here. */
97  void render() const override {}
98  /** In this class, returns a fixed box (max,max,max), (-max,-max,-max). */
99  void getBoundingBox(
101  mrpt::math::TPoint3D& bb_max) const override;
102 
103  /** Constructor
104  */
105  CCamera();
106 
107  /** Private, virtual destructor: only can be deleted from smart pointers */
108  ~CCamera() override = default;
109 };
110 
111 } // namespace mrpt::opengl
float m_projectiveFOVdeg
Field-of-View in degs, only when projectiveModel=true (default=30 deg).
Definition: CCamera.h:42
void render() const override
Render does nothing here.
Definition: CCamera.h:97
GLdouble GLdouble z
Definition: glext.h:3879
void setOrthogonal(bool v=true)
Enable/Disable orthogonal mode (vs.
Definition: CCamera.h:78
float getPointingAtY() const
Definition: CCamera.h:67
void set6DOFMode(bool v)
Set 6DOFMode, if enabled camera is set according to its pose (default=false).
Definition: CCamera.h:86
The base class of 3D objects that can be directly rendered through OpenGL.
Definition: CRenderizable.h:40
void setProjectiveModel(bool v=true)
Enable/Disable projective mode (vs.
Definition: CCamera.h:76
float getZoomDistance() const
Definition: CCamera.h:70
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
~CCamera() override=default
Private, virtual destructor: only can be deleted from smart pointers.
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
In this class, returns a fixed box (max,max,max), (-max,-max,-max).
Definition: CCamera.cpp:65
CCamera()
Constructor.
void setZoomDistance(float z)
Definition: CCamera.h:69
void setPointingAt(const mrpt::math::TPoint3D &p)
Definition: CCamera.h:61
void setAzimuthDegrees(float ang)
Definition: CCamera.h:73
float getPointingAtX() const
Definition: CCamera.h:66
float getPointingAtZ() const
Definition: CCamera.h:68
float getAzimuthDegrees() const
Definition: CCamera.h:71
void setProjectiveFOVdeg(float ang)
Field-of-View in degs, only when projectiveModel=true (default=30 deg).
Definition: CCamera.h:92
const GLdouble * v
Definition: glext.h:3684
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
float getElevationDegrees() const
Definition: CCamera.h:72
void setElevationDegrees(float ang)
Definition: CCamera.h:74
bool m_projectiveModel
If set to true (default), camera model is projective, otherwise, it&#39;s orthogonal. ...
Definition: CCamera.h:39
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
const auto bb_max
GLenum GLint GLint y
Definition: glext.h:3542
const auto bb_min
bool m_6DOFMode
If set to true, camera pose is used when rendering the viewport.
Definition: CCamera.h:44
GLenum GLint x
Definition: glext.h:3542
float getProjectiveFOVdeg() const
Field-of-View in degs, only when projectiveModel=true (default=30 deg).
Definition: CCamera.h:95
Lightweight 3D point.
Definition: TPoint3D.h:90
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
Definition: CCamera.h:27
void setPointingAt(const POSEORPOINT &p)
Definition: CCamera.h:55
bool is6DOFMode() const
Definition: CCamera.h:89
GLfloat GLfloat p
Definition: glext.h:6398
bool isProjective() const
Definition: CCamera.h:87
bool isOrthogonal() const
Definition: CCamera.h:88
void setPointingAt(float x, float y, float z)
Definition: CCamera.h:47



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ce1a28c9f Fri Aug 23 08:02:09 2019 +0200 at vie ago 23 08:10:11 CEST 2019