xoreos  0.0.5
camera.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef GRAPHICS_CAMERA_H
26 #define GRAPHICS_CAMERA_H
27 
28 #include "src/common/types.h"
29 #include "src/common/maths.h"
30 #include "src/common/singleton.h"
31 
32 namespace Graphics {
33 
34 class CameraManager : public Common::Singleton<CameraManager> {
35 public:
36  CameraManager();
37 
38  const float *getPosition () const;
39  const float *getOrientation() const;
40 
41  void reset();
42 
44  void limit(float minX = -FLT_MAX, float minY = -FLT_MAX, float minZ = -FLT_MAX,
45  float maxX = FLT_MAX, float maxY = FLT_MAX, float maxZ = FLT_MAX);
46 
47  void setPosition (float x, float y, float z);
48  void setOrientation(float x, float y, float z);
49 
50  void turn(float x, float y, float z);
51  void move(float x, float y, float z);
52 
54  void moveRelative(float x, float y, float z);
55 
56  uint32 lastChanged() const;
57 
63  void update();
64 
65 private:
67 
68  float _minPosition[3];
69  float _maxPosition[3];
70 
71  float _position[3];
72  float _orientation[3];
73 
74  float _positionCache[3];
75  float _orientationCache[3];
76 
78 };
79 
80 } // End of namespace Graphics
81 
83 #define CameraMan Graphics::CameraManager::instance()
84 
85 #endif // GRAPHICS_CAMERA_H
void setOrientation(float x, float y, float z)
Set the camera orientation.
Definition: camera.cpp:134
const float * getOrientation() const
Get the current camera orientation cache.
Definition: camera.cpp:91
Class and macro for implementing singletons.
float _orientation[3]
Current orientation.
Definition: camera.h:72
const float * getPosition() const
Get the current camera position cache.
Definition: camera.cpp:87
Mathematical helpers.
void reset()
Reset the current position and orientation.
Definition: camera.cpp:95
void moveRelative(float x, float y, float z)
Move relative to the current view axis.
Definition: camera.cpp:152
float _position[3]
Current position.
Definition: camera.h:71
float _minPosition[3]
Definition: camera.h:68
uint32 lastChanged() const
The timestamp the camera was changed last.
Definition: camera.cpp:164
float _orientationCache[3]
Current orientation, cached.
Definition: camera.h:75
void move(float x, float y, float z)
Move along axes.
Definition: camera.cpp:148
Generic template base class for implementing the singleton design pattern.
Definition: singleton.h:61
void turn(float x, float y, float z)
Turn along axes.
Definition: camera.cpp:144
float _positionCache[3]
Current position, cached.
Definition: camera.h:74
Low-level type definitions to handle fixed width types portably.
void limit(float minX=-FLT_MAX, float minY=-FLT_MAX, float minZ=-FLT_MAX, float maxX=FLT_MAX, float maxY=FLT_MAX, float maxZ=FLT_MAX)
Set limits on the camera position.
Definition: camera.cpp:115
uint32_t uint32
Definition: types.h:204
float _maxPosition[3]
Definition: camera.h:69
void setPosition(float x, float y, float z)
Set the camera position.
Definition: camera.cpp:124
#define FLT_MAX
Definition: maths.h:47
void update()
Update the caches with the current position and orientation.
Definition: camera.cpp:68