OpenWalnut  1.3.1
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 
32 /**
33  * Class for wrapping around the OSG Camera class. It adds some utility
34  * functions for simply setting some camera defaults.
35  * \ingroup ge
36  */
37 class WGECamera: public osg::Camera
38 {
39 public:
40  /**
41  * List of possible camera modes. The TWO_D modes use a standard two dimensional orthogonal projection. TWO_D_UNOT is somewhat special. It
42  * 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
43  * command.
44  */
46  {
47  ORTHOGRAPHIC,
48  PERSPECTIVE,
49  TWO_D, // two dimensional ortographic projection, dimension is viewport
50  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
51  // unimportant.
52  };
53 
54  /**
55  * Constructor which sets defaults
56  *
57  * \param width width of the viewport.
58  * \param height height of the viewport.
59  * \param projectionMode projection mode of the viewer.
60  */
61  WGECamera( int width, int height, ProjectionMode projectionMode );
62 
63  /**
64  * Sets the default projection mode used for cameras getting reset.
65  *
66  * \param mode the mode to set.
67  */
69 
70  /**
71  * Returns the current default projection mode.
72  *
73  * \return the currently set mode.
74  */
76 
77  /**
78  * Resets the camera and activates the prior set defaults.
79  */
80  void reset();
81 
82  /**
83  * Change camera parameters which should be changed on a resize.
84  */
85  void resize();
86 
87 protected:
88  /**
89  * Destructor. This desctructor is protected to avoid accidentally deleting
90  * a instance of WGECamera.
91  * This follows the philosophy of OSG to avoid problems in multithreaded
92  * environments, since these camera pointers are used deep in the OSG where
93  * an deletion could cause a segfault.
94  */
95  virtual ~WGECamera();
96 
97  /**
98  * The projection mode used as default.
99  */
101 
102 private:
103 };
104 
105 #endif // WGECAMERA_H