OpenWalnut  1.5.0dev
WGECamera.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WGECAMERA_H
26 #define WGECAMERA_H
27 
28 #include <osg/Camera>
29 
30 /**
31  * Class for wrapping around the OSG Camera class. It adds some utility
32  * functions for simply setting some camera defaults.
33  * \ingroup ge
34  */
35 class WGECamera: public osg::Camera
36 {
37 public:
38  /**
39  * List of possible camera modes. The TWO_D modes use a standard two dimensional orthogonal projection. TWO_D_UNOT is somewhat special. It
40  * 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
41  * command.
42  */
44  {
45  ORTHOGRAPHIC,
46  PERSPECTIVE,
47  TWO_D, // two dimensional ortographic projection, dimension is viewport
48  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
49  // unimportant.
50  };
51 
52  /**
53  * Constructor which sets defaults
54  *
55  * \param width width of the viewport.
56  * \param height height of the viewport.
57  * \param projectionMode projection mode of the viewer.
58  */
59  WGECamera( int width, int height, ProjectionMode projectionMode );
60 
61  /**
62  * Constructor which sets defaults
63  */
64  WGECamera();
65 
66  /**
67  * Sets the default projection mode used for cameras getting reset.
68  *
69  * \param mode the mode to set.
70  */
72 
73  /**
74  * Returns the current default projection mode.
75  *
76  * \return the currently set mode.
77  */
79 
80  /**
81  * Resets the camera and activates the prior set defaults.
82  */
83  void reset();
84 
85  /**
86  * Change camera parameters which should be changed on a resize.
87  */
88  void resize();
89 
90 protected:
91  /**
92  * Destructor. This desctructor is protected to avoid accidentally deleting
93  * a instance of WGECamera.
94  * This follows the philosophy of OSG to avoid problems in multithreaded
95  * environments, since these camera pointers are used deep in the OSG where
96  * an deletion could cause a segfault.
97  */
98  virtual ~WGECamera();
99 
100  /**
101  * The projection mode used as default.
102  */
104 
105 private:
106 };
107 
108 #endif // WGECAMERA_H
Class for wrapping around the OSG Camera class.
Definition: WGECamera.h:36
void reset()
Resets the camera and activates the prior set defaults.
Definition: WGECamera.cpp:88
virtual ~WGECamera()
Destructor.
Definition: WGECamera.cpp:73
ProjectionMode m_DefProjMode
The projection mode used as default.
Definition: WGECamera.h:103
void setDefaultProjectionMode(ProjectionMode mode)
Sets the default projection mode used for cameras getting reset.
Definition: WGECamera.cpp:78
ProjectionMode
List of possible camera modes.
Definition: WGECamera.h:44
void resize()
Change camera parameters which should be changed on a resize.
Definition: WGECamera.cpp:114
WGECamera()
Constructor which sets defaults.
Definition: WGECamera.cpp:54
ProjectionMode getDefaultProjectionMode()
Returns the current default projection mode.
Definition: WGECamera.cpp:83