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



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