-
Notifications
You must be signed in to change notification settings - Fork 0
/
Camera.cpp
61 lines (50 loc) · 1.26 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
#include "Camera.hpp"
Camera::Camera(const glm::vec3 &position, const glm::vec3 ¢er) :
_position(position), _center(center)
{
// The transformation of the camera corresponds to its orientation
// and its position : here, the camera is at position (0, 10, 10)
// and it will be oriented towards the position (0, 0, 0)
_up = glm::vec3(0, 1, 0);
}
Camera::~Camera()
{
}
const glm::mat4 &Camera::setPerspective(int _winX, int _winY)
{
// glm::perspective(FOV, windowX / windowY, min plan, far plan)
_transformation = glm::perspective(60.0f, static_cast<float>(_winX) /
static_cast<float>(_winY), 0.1f, 100.0f);
return _transformation;
}
const glm::mat4 &Camera::setLookAt()
{
// The projection of the camera corresponds to the way
// the objects will be drawn on screen
_projection = glm::lookAt(_position, _center, _up);
return _projection;
}
void Camera::setPosition(const glm::vec3 &position)
{
_position = position;
}
void Camera::setCenter(const glm::vec3 ¢er)
{
_center = center;
}
void Camera::setUp(const glm::vec3 &up)
{
_up = up;
}
const glm::vec3 &Camera::getPosition() const
{
return _position;
}
const glm::vec3 &Camera::getCenter() const
{
return _center;
}
const glm::vec3 &Camera::getUp() const
{
return _up;
}