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



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