-
Notifications
You must be signed in to change notification settings - Fork 0
/
Camera3D.h
155 lines (128 loc) · 3.6 KB
/
Camera3D.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/**
* @file Camera3D.h
* @author Donal Evans
* @date 31 Aug 2016
* @brief This class handles Camera3D movement.
*
* Detailed description goes here
*/
#ifndef CAMERA3D_H
#define CAMERA3D_H
#include <QVector3D>
#include <QQuaternion>
#include <QMatrix4x4>
class Camera3D
{
public:
/**
* @brief Setter for the default view matrix.
* @param defaultView The QMatrix4x4 to be used as the default view.
*/
void SetDefaultView(QMatrix4x4 defaultView);
/**
* @brief Setter for the transformation matrix.
* @param matrix The new value for the transformation matrix.
*/
void SetMatrix(QMatrix4x4 matrix);
/**
* @brief Getter for the rotation QQuaternion.
* @return The current rotation as a QQuaternion.
*/
QQuaternion GetRotation();
/**
* @brief Setter for the rotation QQuaternion.
* @param scale A QQuaternion representing a rotation.
*/
void SetRotation(QQuaternion rotation);
/**
* @brief Getter for the translation QVector3D.
* @return The current translation as a QVector3D.
*/
QVector3D GetTranslation();
/**
* @brief Setter for the translation QVector3D.
* @param translation A QVector3D representing a translation.
*/
void SetTranslation(QVector3D translation);
/**
* @brief Constructor
*/
Camera3D();
/**
* @brief A function for determining the current forward direction.
* @return A QVector3D representing the transformed forward direction.
*/
QVector3D Forward();
/**
* @brief Sets the rotation quaternion to the identity quaternion.
*/
void ResetRotation();
/**
* @brief Sets the translation to zero.
*/
void ResetTranslation();
/**
* @brief Sets the camera position and orientation to the default.
*/
void ResetView();
/**
* @brief A function for determining the current right direction.
* @return A QVector3D representing the transformed right direction.
*/
QVector3D Right();
/**
* @brief Applies a rotation to the existing rotation quaternion.
* @param rotation A QQuaternion representing a rotation.
*/
void Rotate(QQuaternion rotation);
/**
* @brief Converts the translation and rotation vectors into a QMatrix4x4.
* @return A QMatrix4x4 representing the total 3D transformation.
*/
QMatrix4x4 ToMatrix();
/**
* @brief Applies a translation to the existing translate vector.
* @param translate A QVector3D representing a translation.
*/
void Translate(QVector3D translate);
/**
* @brief A function for determining the current up direction.
* @return A QVector3D representing the transformed up direction.
*/
QVector3D Up();
/**
* @brief The default forward direction.
*/
static const QVector3D FORWARD;
/**
* @brief The default right direction.
*/
static const QVector3D RIGHT;
/**
* @brief The default up direction.
*/
static const QVector3D UP;
private:
/**
* @brief True if the transformation matrix has been changed since the last
* time ToMatrix() was called, false otherwise.
*/
bool m_Changed;
/**
* @brief Matrix describing the default camera view.
*/
QMatrix4x4 m_DefaultView;
/**
* @brief The current rotation to be applied.
*/
QQuaternion m_Rotation;
/**
* @brief The current translation to be applied.
*/
QVector3D m_Translation;
/**
* @brief The total 3D transformation to be applied.
*/
QMatrix4x4 m_World;
};
#endif // CAMERA3D_H