OpenWalnut 1.2.5

WGECamera.h

00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WGECAMERA_H
00026 #define WGECAMERA_H
00027 
00028 #include <osg/Camera>
00029 
00030 #include "WExportWGE.h"
00031 
00032 /**
00033  * Class for wrapping around the OSG Camera class. It adds some utility
00034  * functions for simply setting some camera defaults.
00035  * \ingroup ge
00036  */
00037 class WGE_EXPORT WGECamera: public osg::Camera
00038 {
00039 public:
00040     /**
00041      * List of possible camera modes. The TWO_D modes use a standard two dimensional orthogonal projection. TWO_D_UNOT is somewhat special. It
00042      * creates a view-cube with an edge-length of 1, centered at 0 for X and Y. For Z, it is from 0 to 1. This relates to the standard glOrtho
00043      * command.
00044      */
00045     enum ProjectionMode
00046     {
00047         ORTHOGRAPHIC,
00048         PERSPECTIVE,
00049         TWO_D,  // two dimensional ortographic projection, dimension is viewport
00050         TWO_D_UNIT // like TWO_D but size is unit-cube with proper scaling and aspect ratio. This is useful for widgets where viewport size is
00051                    // unimportant.
00052     };
00053 
00054     /**
00055      * Constructor which sets defaults
00056      *
00057      * \param width width of the viewport.
00058      * \param height height of the viewport.
00059      * \param projectionMode projection mode of the viewer.
00060      */
00061     WGECamera( int width, int height, ProjectionMode projectionMode );
00062 
00063     /**
00064      * Sets the default projection mode used for cameras getting reset.
00065      *
00066      * \param mode the mode to set.
00067      */
00068     void setDefaultProjectionMode( ProjectionMode mode );
00069 
00070     /**
00071      * Returns the current default projection mode.
00072      *
00073      * \return the currently set mode.
00074      */
00075     ProjectionMode getDefaultProjectionMode();
00076 
00077     /**
00078      * Resets the camera and activates the prior set defaults.
00079      */
00080     void reset();
00081 
00082     /**
00083      * Change camera parameters which should be changed on a resize.
00084      */
00085     void resize();
00086 
00087 protected:
00088     /**
00089      * Destructor. This desctructor is protected to avoid accidentally deleting
00090      * a instance of WGECamera.
00091      * This follows the philosophy of OSG to avoid problems in multithreaded
00092      * environments, since these camera pointers are used deep in the OSG where
00093      * an deletion could cause a segfault.
00094      */
00095     virtual ~WGECamera();
00096 
00097     /**
00098      * The projection mode used as default.
00099      */
00100     ProjectionMode m_DefProjMode;
00101 
00102 private:
00103 };
00104 
00105 #endif  // WGECAMERA_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends