-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera.h
54 lines (44 loc) · 2.15 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
#ifndef CAMERA_H
#define CAMERA_H
#include <cmath>
#include <map>
class Camera
{
public:
enum KEYBOARD {AZERTY, QWERTY}; /* type of keyboard */
Camera ();
~Camera() {}
void init (KEYBOARD, float, float, float, float, float, float, float, int, int);
int getMouseX () { return mouse_x; }
int getMouseY () { return mouse_y; }
float getSightX () { return X + sinf (theta) * sinf (psi); }
float getSightY () { return Y + cosf (psi); }
float getSightZ () { return Z + cosf (theta) * sinf (psi); }
float getX () { return X; }
float getY () { return Y; }
float getZ () { return Z; }
void setKeyboard (int i, bool state) { keys[i] = state; }
void setMouse (int x, int y) { mouse_x = x; mouse_y = y; }
void setX (float p_X) { X = p_X; }
void setY (float p_Y) { Y = p_Y; }
void setZ (float p_Z) { Z = p_Z; }
void rotation (int, int);
void translation ();
private:
enum DIR {FORWARD, BACKWARD, LEFT, RIGHT}; /* translation direction */
typedef std::map<DIR, int> k_map;
k_map key_map; /* associations keys - directions */
KEYBOARD keyboard; /* keyboard type */
bool keys[255]; /* keys being pushed (true if pushed) */
float X; /* sphere center x axis */
float Y; /* sphere center y axis */
float Z; /* sphere center z axis */
int mouse_x; /* mouse x position */
int mouse_y; /* mouse y position */
float psi; /* psi angle in spherical coordinates */
float theta; /* theta angle in spherical coordinates */
float rotation_speed; /* equivalent to mouse sensibility */
float translation_speed; /* equivalent to keyboard sensibility */
int time; /* to keep track of the time between two function calls */
};
#endif