-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.cpp
More file actions
65 lines (54 loc) · 1.1 KB
/
Copy pathcamera.cpp
File metadata and controls
65 lines (54 loc) · 1.1 KB
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
#include "camera.h"
GLfloat Camera::getCameraFOV() const
{
return this->properties.fov;
}
GLfloat Camera::getNearClippingPlane() const
{
return this->properties.near_clip_plane;
}
GLfloat Camera::getFarClippingPlane() const
{
return this->properties.far_clip_plane;
}
glm::vec3 Camera::getEye() const
{
return this->eye;
}
void Camera::setEye(glm::vec3& eye)
{
this->eye = eye;
updateView();
}
glm::vec3 Camera::getCentre() const
{
return this->centre;
}
void Camera::setCentre(glm::vec3& centre)
{
this->centre = centre;
updateView();
}
glm::vec3 Camera::getUpVector() const
{
return this->up_vector;
}
void Camera::setUpVector(glm::vec3 up)
{
this->up_vector = up;
}
void Camera::updateView()
{
// lookAt function calculation - https://learnopengl.com/Getting-started/Camera - Date Accessed: 04/12/2023
this->view = glm::lookAt(this->eye, this->eye + this->centre, this->up_vector);
}
void Camera::update_perspective(GLfloat aspect_ratio)
{
this->projection = glm::perspective
(
this->properties.fov,
aspect_ratio,
this->properties.near_clip_plane,
this->properties.far_clip_plane
);
}