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://mrpt.sourceforge.net/                            |
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                   */
00049                 class OPENGL_IMPEXP CCamera : public CRenderizable
00050                 {
00051                         friend class COpenGLViewport;
00052 
00053                         DEFINE_SERIALIZABLE( CCamera )
00054                 protected:
00055 
00056                         float   m_pointingX,m_pointingY,m_pointingZ;
00057                         float   m_distanceZoom;
00058                         float   m_azimuthDeg,m_elevationDeg;
00059 
00060                         bool    m_projectiveModel;      //!< If set to true (default), camera model is projective, otherwise, it's orthogonal.
00061                         float   m_projectiveFOVdeg;     //!< Field-of-View in degs, only when projectiveModel=true (default=30 deg).
00062 
00063                 public:
00064                         void setPointingAt(float x,float y, float z) { m_pointingX=x; m_pointingY=y; m_pointingZ=z; }
00065 
00066                         template <class POSEORPOINT>
00067                         void setPointingAt(const POSEORPOINT &p)
00068                         {
00069                                 m_pointingX=p.x();
00070                                 m_pointingY=p.y();
00071                                 m_pointingZ=p.is3DPoseOrPoint() ? p.m_coords[2] : 0;
00072                         }
00073                         inline void setPointingAt(const mrpt::math::TPoint3D &p) { setPointingAt(p.x,p.y,p.z); }
00074 
00075 
00076                         float getPointingAtX() const { return m_pointingX; }
00077                         float getPointingAtY() const { return m_pointingY; }
00078                         float getPointingAtZ() const { return m_pointingZ; }
00079 
00080                         void setZoomDistance(float z) { m_distanceZoom=z; }
00081                         float getZoomDistance() const { return m_distanceZoom; }
00082 
00083                         float getAzimuthDegrees() const { return m_azimuthDeg; }
00084                         float getElevationDegrees() const { return m_elevationDeg; }
00085 
00086                         void setAzimuthDegrees(float ang) { m_azimuthDeg=ang; }
00087                         void setElevationDegrees(float ang) { m_elevationDeg=ang; }
00088 
00089                         void setProjectiveModel(bool v=true) { m_projectiveModel=v; } //!< Enable/Disable projective mode (vs. orthogonal)
00090                         void setOrthogonal(bool v=true) { m_projectiveModel=!v; }     //!< Enable/Disable orthogonal mode (vs. projective)
00091 
00092                         bool isProjective() const { return m_projectiveModel; }
00093                         bool isOrthogonal() const { return !m_projectiveModel; }
00094 
00095                         void setProjectiveFOVdeg(float ang) { m_projectiveFOVdeg=ang; }  //!< Field-of-View in degs, only when projectiveModel=true (default=30 deg).
00096                         float getProjectiveFOVdeg() const { return m_projectiveFOVdeg; }  //!< Field-of-View in degs, only when projectiveModel=true (default=30 deg).
00097 
00098 
00099                         /** Render does nothing here.
00100                           */
00101                         void  render()  const {  }
00102 
00103                 private:
00104                         /** Constructor
00105                           */
00106                         CCamera();
00107 
00108                         /** Private, virtual destructor: only can be deleted from smart pointers */
00109                         virtual ~CCamera() { }
00110 
00111                 };
00112 
00113         } // end namespace opengl
00114 
00115 } // End of namespace
00116 
00117 
00118 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:16:28 UTC 2011