-
Notifications
You must be signed in to change notification settings - Fork 2
/
Camera.cpp
46 lines (33 loc) · 1.16 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
////////////////////////////////////////
// Camera.cpp
////////////////////////////////////////
#include "Camera.h"
#include "glm/gtx/euler_angles.hpp"
////////////////////////////////////////////////////////////////////////////////
Camera::Camera() {
Reset();
}
////////////////////////////////////////////////////////////////////////////////
void Camera::Update() {
// Compute camera world matrix
glm::mat4 world(1);
world[3][2]=Distance;
world=glm::eulerAngleY(glm::radians(-Azimuth)) * glm::eulerAngleX(glm::radians(-Incline)) * world;
// Compute view matrix (inverse of world matrix)
glm::mat4 view=glm::inverse(world);
// Compute perspective projection matrix
glm::mat4 project=glm::perspective(glm::radians(FOV),Aspect,NearClip,FarClip);
// Compute final view-projection matrix
ViewProjectMtx=project * view;
}
////////////////////////////////////////////////////////////////////////////////
void Camera::Reset() {
FOV=45.0f;
Aspect=1.33f;
NearClip=0.1f;
FarClip=100.0f;
Distance=10.0f;
Azimuth=0.0f;
Incline=20.0f;
}
////////////////////////////////////////////////////////////////////////////////