Main MRPT website > C++ reference
MRPT logo
CCamera.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 
29 #ifndef opengl_CCamera_H
30 #define opengl_CCamera_H
31 
34 
35 namespace mrpt
36 {
37  namespace opengl
38  {
39  class COpenGLViewport;
40  class CCamera;
41 
42  // This must be added to any CSerializable derived class:
44 
45  /** 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.
46  * A camera can be defined to provide a projective or orthogonal view of the world by setting the member CCamera::m_projectiveModel.
47  * \sa opengl::COpenGLScene
48  * \ingroup mrpt_opengl_grp
49  */
51  {
52  friend class COpenGLViewport;
53 
55  protected:
56 
57  float m_pointingX,m_pointingY,m_pointingZ;
58  float m_distanceZoom;
59  float m_azimuthDeg,m_elevationDeg;
60 
61  bool m_projectiveModel; //!< If set to true (default), camera model is projective, otherwise, it's orthogonal.
62  float m_projectiveFOVdeg; //!< Field-of-View in degs, only when projectiveModel=true (default=30 deg).
63  bool m_6DOFMode; //!< If set to true, camera pose is used when rendering the viewport
64 
65 
66  public:
67  void setPointingAt(float x,float y, float z) { m_pointingX=x; m_pointingY=y; m_pointingZ=z; }
68 
69  template <class POSEORPOINT>
70  void setPointingAt(const POSEORPOINT &p)
71  {
72  m_pointingX=p.x();
73  m_pointingY=p.y();
74  m_pointingZ=p.is3DPoseOrPoint() ? p.m_coords[2] : 0;
75  }
76  inline void setPointingAt(const mrpt::math::TPoint3D &p) { setPointingAt(p.x,p.y,p.z); }
77 
78 
79  float getPointingAtX() const { return m_pointingX; }
80  float getPointingAtY() const { return m_pointingY; }
81  float getPointingAtZ() const { return m_pointingZ; }
82 
83  void setZoomDistance(float z) { m_distanceZoom=z; }
84  float getZoomDistance() const { return m_distanceZoom; }
85 
86  float getAzimuthDegrees() const { return m_azimuthDeg; }
87  float getElevationDegrees() const { return m_elevationDeg; }
88 
89  void setAzimuthDegrees(float ang) { m_azimuthDeg=ang; }
90  void setElevationDegrees(float ang) { m_elevationDeg=ang; }
91 
92  void setProjectiveModel(bool v=true) { m_projectiveModel=v; } //!< Enable/Disable projective mode (vs. orthogonal)
93  void setOrthogonal(bool v=true) { m_projectiveModel=!v; } //!< Enable/Disable orthogonal mode (vs. projective)
94 
95  /** Set 6DOFMode, if enabled camera is set according to its pose (default=false).
96  * Conventionally, eye is set looking towards the positive direction of Z axis.
97  * Up is set as the Y axis.
98  * In this mode azimuth/elevation are ignored.
99  **/
100  void set6DOFMode(bool v) { m_6DOFMode=v; }
101 
102  bool isProjective() const { return m_projectiveModel; }
103  bool isOrthogonal() const { return !m_projectiveModel; }
104  bool is6DOFMode() const { return m_6DOFMode; }
105 
106  void setProjectiveFOVdeg(float ang) { m_projectiveFOVdeg=ang; } //!< Field-of-View in degs, only when projectiveModel=true (default=30 deg).
107  float getProjectiveFOVdeg() const { return m_projectiveFOVdeg; } //!< Field-of-View in degs, only when projectiveModel=true (default=30 deg).
108 
109 
110  /** Render does nothing here.
111  */
112  void render() const { }
113 
114  private:
115  /** Constructor
116  */
117  CCamera();
118 
119  /** Private, virtual destructor: only can be deleted from smart pointers */
120  virtual ~CCamera() { }
121 
122  };
123 
124  } // end namespace opengl
125 
126 } // End of namespace
127 
128 
129 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013