-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera.cpp
64 lines (51 loc) · 1.07 KB
/
camera.cpp
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
#include <GL/gl.h>
#include <GL/glu.h>
#include <math.h>
#include "camera.h"
using namespace BE;
Camera::Camera() {
init(0.0f, 0.0f, 0.0f);
lookAhead();
}
Camera::Camera(const float &x, const float &y, const float &z) : Object(x, y, z) {
}
void Camera::render() {
glTranslatef(-_position.x, -_position.y, -_position.z);
glRotatef(_angles.x, 1.0, 0.0, 0.0);
glRotatef(_angles.y, 0.0, 1.0, 0.0);
}
void Camera::resetLook() {
_position.x = 0.0f;
_position.y = 0.0f;
_position.z = 0.0f;
_angles.x = 0.0f;
_angles.y = 0.0f;
}
void Camera::lookLeft() {
_angles.y = -90.0f;
resetLook();
}
void Camera::lookRight() {
_angles.y = 90.0f;
resetLook();
}
void Camera::lookAhead() {
_angles.y = 0.0f;
resetLook();
}
void Camera::lookRear() {
_angles.y = 180.0f;
resetLook();
}
void Camera::zoomIn() {
_position.z++;
}
void Camera::zoomOut() {
_position.z--;
}
float Camera::getZoom() {
return _position.z;
}
void Camera::setZoom(const float &z) {
_position.z = z;
}