-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCamera.cpp
More file actions
25 lines (23 loc) · 945 Bytes
/
Copy pathCamera.cpp
File metadata and controls
25 lines (23 loc) · 945 Bytes
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
#include "Camera.h"
// such a kawai constructor
Camera::Camera(glm::vec3 startPos, float aspectRatio) {
Position = startPos;
Front = glm::vec3(0.0f, 0.0f, -1.0f);
Up = glm::vec3(0.0f, 1.0f, 0.0f);
Fov = 45.0f;
AspectRatio = aspectRatio;
NearPlane = 0.1f;
FarPlane = 100.0f;
}
// Returns the view matrix that transforms world coordinates into the camera's view space.
// This uses the camera's Position as the eye, Position + Front as the target (center),
// and Up as the upward direction, effectively placing the "world" relative to the camera.
glm::mat4 Camera::GetViewMatrix() {
return glm::lookAt(Position, Position + Front, Up);
}
// Returns the projection matrix that defines how 3D points are projected onto a 2D screen.
// Math magic wooo skeri horror
// Todo: Learn the actual fucking math of this shit
glm::mat4 Camera::GetProjectionMatrix() {
return glm::perspective(glm::radians(Fov), AspectRatio, NearPlane, FarPlane);
}