-
Notifications
You must be signed in to change notification settings - Fork 1
/
Camera.cpp
90 lines (72 loc) · 1.5 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
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
#include "Camera.h"
Camera* Camera::currentCamera = NULL;
Camera::Camera()
{
up.y = 1.0;
}
void Camera::resetCamera()
{
currentCamera = NULL;
//glPopMatrix();
}
void Camera::draw()
{
Size3D temp( 1.0, 1.0, 1.0 );
GLDebug::drawPoint3D( position, temp, 1.0, GLDebug::SQUARE );
}
void Camera::setView()
{
if( currentCamera != this )
{
currentCamera = this;
//glPushMatrix();
}
gluLookAt ( position.x, position.y, position.z, position.x+(sin( Math::DegToRad( rotation.y ) )), position.y+ rotation.x, position.z-(cos( Math::DegToRad( rotation.y ) )), up.x, up.y, up.z);
}
void Camera::addToPosition( double x, double y, double z )
{
position.x += x;
position.y += y;
position.z += z;
}
void Camera::setPosition( double x, double y, double z )
{
position.x = x;
position.y = y;
position.z = z;
}
void Camera::setPosition( Point3D position )
{
this->position.x = position.x;
this->position.y = position.y;
this->position.z = position.z;
}
Point3D Camera::getPosition()
{
return position;
}
void Camera::setRotation( double x, double y, double z )
{
rotation.x = x;
rotation.y = y;
rotation.z = z;
rotation.keepInRange();
}
void Camera::setRotation( Rotation3D rotation )
{
this->rotation.x = rotation.x;
this->rotation.y = rotation.y;
this->rotation.z = rotation.z;
this->rotation.keepInRange();
}
void Camera::addToRotation( double x, double y, double z )
{
rotation.x += x;
rotation.y += y;
rotation.z += z;
rotation.keepInRange();
}
Rotation3D Camera::getRotation()
{
return rotation;
}