Main MRPT website > C++ reference
MRPT logo
CCamera.h
Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                       http://www.mrpt.org/                                |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 
00029 #ifndef opengl_CCamera_H
00030 #define opengl_CCamera_H
00031 
00032 #include <mrpt/opengl/CRenderizable.h>
00033 #include <mrpt/poses/CPoseOrPoint.h>
00034 
00035 namespace mrpt
00036 {
00037         namespace opengl
00038         {
00039                 class COpenGLViewport;
00040                 class CCamera;
00041 
00042                 // This must be added to any CSerializable derived class:
00043                 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CCamera, CRenderizable, OPENGL_IMPEXP )
00044 
00045                 /** 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.
00046                   *  A camera can be defined to provide a projective or orthogonal view of the world by setting the member CCamera::m_projectiveModel.
00047                   *  \sa opengl::COpenGLScene
00048                   * \ingroup mrpt_opengl_grp
00049                   */
00050                 class OPENGL_IMPEXP CCamera : public CRenderizable
00051                 {
00052                         friend class COpenGLViewport;
00053 
00054                         DEFINE_SERIALIZABLE( CCamera )
00055                 protected:
00056 
00057                         float   m_pointingX,m_pointingY,m_pointingZ;
00058                         float   m_distanceZoom;
00059                         float   m_azimuthDeg,m_elevationDeg;
00060 
00061                         bool    m_projectiveModel;      //!< If set to true (default), camera model is projective, otherwise, it's orthogonal.
00062                         float   m_projectiveFOVdeg;     //!< Field-of-View in degs, only when projectiveModel=true (default=30 deg).
00063                         bool    m_6DOFMode; //!< If set to true, camera pose is used when rendering the viewport
00064 
00065 
00066                 public:
00067                         void setPointingAt(float x,float y, float z) { m_pointingX=x; m_pointingY=y; m_pointingZ=z; }
00068 
00069                         template <class POSEORPOINT>
00070                         void setPointingAt(const POSEORPOINT &p)
00071                         {
00072                                 m_pointingX=p.x();
00073                                 m_pointingY=p.y();
00074                                 m_pointingZ=p.is3DPoseOrPoint() ? p.m_coords[2] : 0;
00075                         }
00076                         inline void setPointingAt(const mrpt::math::TPoint3D &p) { setPointingAt(p.x,p.y,p.z); }
00077 
00078 
00079                         float getPointingAtX() const { return m_pointingX; }
00080                         float getPointingAtY() const { return m_pointingY; }
00081                         float getPointingAtZ() const { return m_pointingZ; }
00082 
00083                         void setZoomDistance(float z) { m_distanceZoom=z; }
00084                         float getZoomDistance() const { return m_distanceZoom; }
00085 
00086                         float getAzimuthDegrees() const { return m_azimuthDeg; }
00087                         float getElevationDegrees() const { return m_elevationDeg; }
00088 
00089                         void setAzimuthDegrees(float ang) { m_azimuthDeg=ang; }
00090                         void setElevationDegrees(float ang) { m_elevationDeg=ang; }
00091 
00092                         void setProjectiveModel(bool v=true) { m_projectiveModel=v; } //!< Enable/Disable projective mode (vs. orthogonal)
00093                         void setOrthogonal(bool v=true) { m_projectiveModel=!v; }     //!< Enable/Disable orthogonal mode (vs. projective)
00094                         
00095                         /** Set 6DOFMode, if enabled camera is set according to its pose (default=false).
00096                          *  Conventionally, eye is set looking towards the positive direction of Z axis.
00097                          *  Up is set as the Y axis.
00098                          *  In this mode azimuth/elevation are ignored.
00099                          **/                    
00100                         void set6DOFMode(bool v) { m_6DOFMode=v; }    
00101                         
00102                         bool isProjective() const { return m_projectiveModel; }
00103                         bool isOrthogonal() const { return !m_projectiveModel; }
00104                         bool is6DOFMode() const { return m_6DOFMode; }
00105 
00106                         void setProjectiveFOVdeg(float ang) { m_projectiveFOVdeg=ang; }  //!< Field-of-View in degs, only when projectiveModel=true (default=30 deg).
00107                         float getProjectiveFOVdeg() const { return m_projectiveFOVdeg; }  //!< Field-of-View in degs, only when projectiveModel=true (default=30 deg).
00108 
00109 
00110                         /** Render does nothing here.
00111                           */
00112                         void  render()  const {  }
00113 
00114                 private:
00115                         /** Constructor
00116                           */
00117                         CCamera();
00118 
00119                         /** Private, virtual destructor: only can be deleted from smart pointers */
00120                         virtual ~CCamera() { }
00121 
00122                 };
00123 
00124         } // end namespace opengl
00125 
00126 } // End of namespace
00127 
00128 
00129 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011