forked from tharvik/COG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCamera.h
233 lines (202 loc) · 4.19 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#pragma once
#include "opengl.h"
#include <set>
#include <math.h>
#include <array>
#include "Logger.h"
#include "utilities.h"
#include "Vvector.h"
/**
* Handle the Camera for OpenGL
*/
class Camera {
private:
/**
* Current position
*/
Vvector p;
/**
* Current orientation
*/
Vvector o;
/**
* Inertia Vvector of deplacement
*/
Vvector d;
/**
* Inertia Vvector of rotation
*/
Vvector r;
public:
/**
* Construct with the default values in config.h
*
* \ref p is initialized with POS_* from config.h
*
* \ref o and \ref r are initstate with ORI_* from config.h and
* normalized
*
* \ref d is set to zero
*/
Camera();
/**
* Construct with the given values
*
* \param posX Position on x
* \param posY Position on y
* \param posZ Position on z
* \param oriX Orientation on x
* \param oriY Orientation on y
* \param oriZ Orientation on z
*/
Camera(const GLdouble posX, const GLdouble posY,
const GLdouble posZ, const GLdouble oriX,
const GLdouble oriY, const GLdouble oriZ);
/**
* Rotate from the angle
*
* \param alpha Angle in radian to move on the horizontal plan
* \param beta Angle in radian to move on the vertical plan
*/
void rotate(const GLdouble alpha, const GLdouble beta);
/**
* Look at the given point
*
* \param posX Position on x
* \param posY Position on y
* \param posZ Position on z
*/
void lookTo(const GLdouble posX, const GLdouble posY,
const GLdouble posZ);
/**
* Begin a move of the given values
*
* \param movForward Move forward of this much
* \param movSideward Move sideway of this much
* \param movUpward Move upward of this much
*/
void move(const GLdouble movForward, const GLdouble movSideward,
const GLdouble movUpward);
/**
* Begin a move to the given position
*
* \param oriX X position to go to
* \param oriY Y position to go to
* \param oriZ Z position to go to
*/
void goTo(const GLdouble oriX, const GLdouble oriY,
const GLdouble oriZ);
/**
* Set the x position
*
* \param posX New x value
*/
void setPositionX(const GLdouble posX);
/**
* Set the y position
*
* \param posY New y value
*/
void setPositionY(const GLdouble posY);
/**
* Set the z position
*
* \param posZ New z value
*/
void setPositionZ(const GLdouble posZ);
/**
* Set the x orientation
*
* \param posX New x value
*/
void setOrientationX(const GLdouble posX);
/**
* Set the y orientation
*
* \param posY New y value
*/
void setOrientationY(const GLdouble posY);
/**
* Set the z orientation
*
* \param posZ New z value
*/
void setOrientationZ(const GLdouble posZ);
/**
* get the camera position
*
* \return position
*/
const Vvector& getPosition() const;
/**
* Return the x position
*
* \return X position
*/
GLdouble getPositionX() const;
/**
* Return the y position
*
* \return Y position
*/
GLdouble getPositionY() const;
/**
* Return the z position
*
* \return Z position
*/
GLdouble getPositionZ() const;
/**
* Return the x orientation
*
* \return X orientation
*/
GLdouble getOrientationX() const;
/**
* Return the y orientation
*
* \return Y orientation
*/
GLdouble getOrientationY() const;
/**
* Return the z orientation
*
* \return Z orientation
*/
GLdouble getOrientationZ() const;
/**
* Return the x direction
*
* \return X direction
*/
GLdouble getDirectionX() const;
/**
* Return the y direction
*
* \return Y direction
*/
GLdouble getDirectionY() const;
/**
* Return the z direction
*
* \return Z direction
*/
GLdouble getDirectionZ() const;
/**
* Handle keydowns from GLUT
*
* \param keysPressed Set of key currently down
*/
void keyDown(std::set<int> &keysPressed);
/**
* Calculate the next position
*
* \param physicDelta Relative move to compute by step, the smaller, the
* more it will be but the more call it will need
*/
void physic(const double &physicDelta);
/**
* Launch gluLookAt with the current state
*/
void look();
};