-
Notifications
You must be signed in to change notification settings - Fork 0
/
Camera.hpp
80 lines (55 loc) · 1.66 KB
/
Camera.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef GAME3D_CAMERA_HPP
#define GAME3D_CAMERA_HPP
#include <string>
#include <Ogre.h>
#include "Node.hpp"
#include "Vector.hpp"
namespace Game3D{
struct CameraInfo{
std::string name;
double nearClipDistance, farClipDistance;
Ogre::Vector3 initialPosition;
double initialPitch, initialYaw, initialRoll;
double aspectRatio;
inline CameraInfo()
: name("camera"),
nearClipDistance(0), farClipDistance(1000.0),
initialPosition(0.0, 0.0, 0.0),
initialPitch(0.0), initialYaw(0.0), initialRoll(0.0),
aspectRatio(16.0/9.0){ }
};
struct AngleVector{
// Rotation around x axis.
double pitch;
// Rotation around y axis.
double yaw;
// Rotation around z axis.
double roll;
inline AngleVector(double p = 0.0, double y = 0.0, double r = 0.0)
: pitch(p), yaw(y), roll(r){ }
};
struct OrientationVector{
Ogre::Quaternion pitchOrientation, yawOrientation, rollOrientation;
};
class Camera{
public:
Camera(const CameraInfo& info, Ogre::SceneManager * sceneManager, NodePtr node);
Ogre::Camera * getCamera();
void setAspectRatio(double aspectRatio);
Ogre::Vector3 getPosition() const;
void rotate(const AngleVector& angles);
void setRotation(const AngleVector& angles);
AngleVector getRotation() const;
OrientationVector getOrientation() const;
void translate(const Vector& translateVector);
private:
Ogre::Camera* camera_;
Ogre::SceneManager* sceneManager_;
Ogre::SceneNode* cameraNode_;
Ogre::SceneNode* cameraYawNode_;
Ogre::SceneNode* cameraPitchNode_;
Ogre::SceneNode* cameraRollNode_;
};
typedef boost::shared_ptr<Camera> CameraPtr;
}
#endif