/
Camera.h
92 lines (68 loc) · 2.22 KB
/
Camera.h
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
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
#include "icameraview.h"
#include "math/Vector3.h"
#include "math/Matrix4.h"
#include "generic/callback.h"
#include "render/View.h"
namespace ui
{
#define SPEED_MOVE 32
#define SPEED_TURN 22.5
class Camera :
public ICameraView
{
static Vector3 _prevOrigin;
static Vector3 _prevAngles;
Vector3 _origin;
Vector3 _angles;
Callback _queueDraw;
Callback _forceRedraw;
float _fieldOfView;
float _farClipPlane;
int _width;
int _height;
Vector3 _forward, _right; // move matrix (TTimo: used to have up but it was not updated)
Vector3 _vup, _vpn, _vright; // view matrix (taken from the modelview matrix)
Matrix4 _projection;
Matrix4 _modelview;
render::View& _view;
public:
Camera(render::View& view, const Callback& queueDraw, const Callback& forceRedraw);
Camera(const Camera& other) = delete;
Camera& operator=(const Camera& other) = delete;
void updateVectors();
void updateModelview();
float getFarClipPlaneDistance() const override;
void setFarClipPlaneDistance(float distance) override;
void freemoveUpdateAxes();
void moveUpdateAxes();
const Vector3& getCameraOrigin() const override;
void setCameraOrigin(const Vector3& newOrigin) override;
const Vector3& getCameraAngles() const override;
void setCameraAngles(const Vector3& newAngles) override;
const Vector3& getRightVector() const override;
const Vector3& getUpVector() const override;
const Vector3& getForwardVector() const override;
const Matrix4& getModelView() const override;
const Matrix4& getProjection() const override;
int getDeviceWidth() const override;
int getDeviceHeight() const override;
void setDeviceDimensions(int width, int height) override;
SelectionTestPtr createSelectionTestForPoint(const Vector2& point) override;
const VolumeTest& getVolumeTest() const override;
void queueDraw() override;
void forceRedraw() override;
void pitchUpDiscrete();
void pitchDownDiscrete();
void rotateRightDiscrete();
void rotateLeftDiscrete();
void moveRightDiscrete(double units);
void moveLeftDiscrete(double units);
void moveDownDiscrete(double units);
void moveUpDiscrete(double units);
void moveBackDiscrete(double units);
void moveForwardDiscrete(double units);
private:
void updateProjection();
};
} // namespace