]> git.localhorst.tv Git - tacos.git/blob - src/graphics/camera.cpp
basic floor idea
[tacos.git] / src / graphics / camera.cpp
1 #include "camera.hpp"
2
3 #include <glm/gtx/rotate_vector.hpp>
4
5
6 namespace tacos {
7
8 Camera::Camera(const glm::vec3 &f)
9 : focus(&f)
10 , distance(100.0f)
11 , pitch(1.04719755119659774614f) // π/3
12 , yaw(0.0f) {
13
14 }
15
16 void Camera::Focus(const glm::vec3 &f) noexcept {
17         focus = &f;
18 }
19
20 glm::mat4 Camera::View() const noexcept {
21         const glm::vec3 position(*focus - distance * rotateY(rotateX(glm::vec3(0.0f, 0.0f, 1.0f), pitch), yaw));
22         return glm::lookAt(position, *focus, glm::vec3(0.0f, 1.0f, 0.0f));
23 }
24
25 }