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
mrpt::opengl::CCamera::getProjectiveFOVdeg
float getProjectiveFOVdeg() const
Field-of-View in degs, only when projectiveModel=true (default=30 deg).
Definition: CCamera.h:98
mrpt::opengl::CCamera::setAzimuthDegrees
void setAzimuthDegrees(float ang)
Definition: CCamera.h:76
mrpt::opengl::CCamera::m_pointingZ
float m_pointingZ
Definition: CCamera.h:36
mrpt::opengl::CCamera::m_elevationDeg
float m_elevationDeg
Definition: CCamera.h:38
mrpt::opengl::CCamera::setPointingAt
void setPointingAt(const POSEORPOINT &p)
Definition: CCamera.h:58
mrpt::opengl::CCamera::setProjectiveModel
void setProjectiveModel(bool v=true)
Enable/Disable projective mode (vs.
Definition: CCamera.h:79
mrpt::opengl::CCamera::setProjectiveFOVdeg
void setProjectiveFOVdeg(float ang)
Field-of-View in degs, only when projectiveModel=true (default=30 deg).
Definition: CCamera.h:95
mrpt::opengl::CCamera::m_pointingY
float m_pointingY
Definition: CCamera.h:36
mrpt::opengl::CCamera::getZoomDistance
float getZoomDistance() const
Definition: CCamera.h:73
mrpt::opengl::CRenderizable
The base class of 3D objects that can be directly rendered through OpenGL.
Definition: CRenderizable.h:43
mrpt::opengl::CCamera::m_projectiveFOVdeg
float m_projectiveFOVdeg
Field-of-View in degs, only when projectiveModel=true (default=30 deg).
Definition: CCamera.h:45
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::opengl::CCamera::m_6DOFMode
bool m_6DOFMode
If set to true, camera pose is used when rendering the viewport.
Definition: CCamera.h:47
mrpt::opengl::CCamera::setPointingAt
void setPointingAt(float x, float y, float z)
Definition: CCamera.h:50
p
GLfloat GLfloat p
Definition: glext.h:6305
mrpt::opengl::CCamera::m_azimuthDeg
float m_azimuthDeg
Definition: CCamera.h:38
mrpt::opengl::CCamera::is6DOFMode
bool is6DOFMode() const
Definition: CCamera.h:92
v
const GLdouble * v
Definition: glext.h:3678
mrpt::opengl::CCamera::getPointingAtX
float getPointingAtX() const
Definition: CCamera.h:69
mrpt::opengl::CCamera::getPointingAtZ
float getPointingAtZ() const
Definition: CCamera.h:71
mrpt::opengl::CCamera::set6DOFMode
void set6DOFMode(bool v)
Set 6DOFMode, if enabled camera is set according to its pose (default=false).
Definition: CCamera.h:89
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:30
CRenderizable.h
mrpt::opengl::CCamera::~CCamera
virtual ~CCamera()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CCamera.h:111
mrpt::opengl::CCamera::setZoomDistance
void setZoomDistance(float z)
Definition: CCamera.h:72
mrpt::opengl::CCamera::CCamera
CCamera()
Constructor.
Definition: CCamera.cpp:28
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
mrpt::opengl::CCamera::setPointingAt
void setPointingAt(const mrpt::math::TPoint3D &p)
Definition: CCamera.h:64
mrpt::opengl::CCamera::getPointingAtY
float getPointingAtY() const
Definition: CCamera.h:70
CPoseOrPoint.h
mrpt::opengl::CCamera::setOrthogonal
void setOrthogonal(bool v=true)
Enable/Disable orthogonal mode (vs.
Definition: CCamera.h:81
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::opengl::CCamera::setElevationDegrees
void setElevationDegrees(float ang)
Definition: CCamera.h:77
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:60
z
GLdouble GLdouble z
Definition: glext.h:3872
mrpt::opengl::CCamera::isProjective
bool isProjective() const
Definition: CCamera.h:90
mrpt::opengl::CCamera::getAzimuthDegrees
float getAzimuthDegrees() const
Definition: CCamera.h:74
mrpt::opengl::CCamera::m_distanceZoom
float m_distanceZoom
Definition: CCamera.h:37
mrpt::opengl::CCamera::render
void render() const override
Render does nothing here.
Definition: CCamera.h:100
mrpt::opengl::CCamera::isOrthogonal
bool isOrthogonal() const
Definition: CCamera.h:91
y
GLenum GLint GLint y
Definition: glext.h:3538
mrpt::opengl::CCamera::getBoundingBox
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
x
GLenum GLint x
Definition: glext.h:3538
mrpt::opengl::CCamera::m_pointingX
float m_pointingX
Definition: CCamera.h:36
mrpt::opengl::CCamera::getElevationDegrees
float getElevationDegrees() const
Definition: CCamera.h:75



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST