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



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020