Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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). */
96 
97  private:
98  /** Constructor
99  */
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
mrpt::opengl::CCamera::getProjectiveFOVdeg
float getProjectiveFOVdeg() const
Field-of-View in degs, only when projectiveModel=true (default=30 deg).
Definition: CCamera.h:88
mrpt::opengl::CCamera::setAzimuthDegrees
void setAzimuthDegrees(float ang)
Definition: CCamera.h:70
mrpt::opengl::CCamera::m_pointingZ
float m_pointingZ
Definition: CCamera.h:38
mrpt::opengl::CCamera::m_elevationDeg
float m_elevationDeg
Definition: CCamera.h:40
mrpt::opengl::CCamera::setPointingAt
void setPointingAt(const POSEORPOINT &p)
Definition: CCamera.h:51
mrpt::opengl::CCamera::setProjectiveModel
void setProjectiveModel(bool v=true)
Enable/Disable projective mode (vs. orthogonal)
Definition: CCamera.h:73
mrpt::opengl::CCamera::setProjectiveFOVdeg
void setProjectiveFOVdeg(float ang)
Field-of-View in degs, only when projectiveModel=true (default=30 deg).
Definition: CCamera.h:87
mrpt::opengl::CCamera::getZoomDistance
float getZoomDistance() const
Definition: CCamera.h:65
mrpt::opengl::CRenderizable
The base class of 3D objects that can be directly rendered through OpenGL.
Definition: CRenderizable.h:45
mrpt::math::TPoint3D::z
double z
X,Y,Z coordinates.
Definition: lightweight_geom_data.h:231
mrpt::opengl::CCamera::CCamera
CCamera()
Constructor.
mrpt::opengl::CCamera::m_projectiveFOVdeg
float m_projectiveFOVdeg
Field-of-View in degs, only when projectiveModel=true (default=30 deg).
Definition: CCamera.h:43
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CParticleFilter.h:17
mrpt::opengl::CCamera::m_6DOFMode
bool m_6DOFMode
If set to true, camera pose is used when rendering the viewport.
Definition: CCamera.h:44
mrpt::opengl::CCamera::setPointingAt
void setPointingAt(float x, float y, float z)
Definition: CCamera.h:48
mrpt::opengl::CCamera::getBoundingBox
virtual void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE
In this class, returns a fixed box (max,max,max), (-max,-max,-max).
mrpt::opengl::CCamera::is6DOFMode
bool is6DOFMode() const
Definition: CCamera.h:85
mrpt::opengl::CCamera::getPointingAtX
float getPointingAtX() const
Definition: CCamera.h:60
mrpt::opengl::CCamera::getPointingAtZ
float getPointingAtZ() const
Definition: CCamera.h:62
mrpt::math::TPoint3D::x
double x
Definition: lightweight_geom_data.h:231
mrpt::opengl::CCamera::set6DOFMode
void set6DOFMode(bool v)
Set 6DOFMode, if enabled camera is set according to its pose (default=false).
Definition: CCamera.h:81
DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
Definition: CSerializable.h:174
mrpt::opengl::CCamera
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
Definition: CCamera.h:32
CRenderizable.h
mrpt::opengl::CCamera::~CCamera
virtual ~CCamera()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CCamera.h:103
mrpt::opengl::CCamera::setZoomDistance
void setZoomDistance(float z)
Definition: CCamera.h:64
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:229
mrpt::opengl::CCamera::setPointingAt
void setPointingAt(const mrpt::math::TPoint3D &p)
Definition: CCamera.h:57
DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE
#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...
Definition: CSerializable.h:170
mrpt::math::TPoint3D::y
double y
Definition: lightweight_geom_data.h:231
mrpt::opengl::CCamera::getPointingAtY
float getPointingAtY() const
Definition: CCamera.h:61
CPoseOrPoint.h
mrpt::opengl::CCamera::setOrthogonal
void setOrthogonal(bool v=true)
Enable/Disable orthogonal mode (vs. projective)
Definition: CCamera.h:74
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:147
mrpt::opengl::CCamera::setElevationDegrees
void setElevationDegrees(float ang)
Definition: CCamera.h:71
mrpt::opengl::CCamera::m_projectiveModel
bool m_projectiveModel
If set to true (default), camera model is projective, otherwise, it's orthogonal.
Definition: CCamera.h:42
mrpt::opengl::COpenGLViewport
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
Definition: COpenGLViewport.h:59
mrpt::opengl::CCamera::isProjective
bool isProjective() const
Definition: CCamera.h:83
mrpt::opengl::CCamera::getAzimuthDegrees
float getAzimuthDegrees() const
Definition: CCamera.h:67
mrpt::opengl::CCamera::m_distanceZoom
float m_distanceZoom
Definition: CCamera.h:39
mrpt::opengl::CCamera::isOrthogonal
bool isOrthogonal() const
Definition: CCamera.h:84
mrpt::opengl::CCamera::render
void render() const MRPT_OVERRIDE
Render does nothing here.
Definition: CCamera.h:92
MRPT_OVERRIDE
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28
mrpt::opengl::CCamera::getElevationDegrees
float getElevationDegrees() const
Definition: CCamera.h:68



Page generated by Doxygen 1.8.20 for MRPT 1.4.0 SVN: at Thu Aug 27 02:40:23 UTC 2020