]> git.localhorst.tv Git - tacos.git/blobdiff - src/graphics/camera.cpp
basic floor idea
[tacos.git] / src / graphics / camera.cpp
diff --git a/src/graphics/camera.cpp b/src/graphics/camera.cpp
new file mode 100644 (file)
index 0000000..bc43e04
--- /dev/null
@@ -0,0 +1,25 @@
+#include "camera.hpp"
+
+#include <glm/gtx/rotate_vector.hpp>
+
+
+namespace tacos {
+
+Camera::Camera(const glm::vec3 &f)
+: focus(&f)
+, distance(100.0f)
+, pitch(1.04719755119659774614f) // π/3
+, yaw(0.0f) {
+
+}
+
+void Camera::Focus(const glm::vec3 &f) noexcept {
+       focus = &f;
+}
+
+glm::mat4 Camera::View() const noexcept {
+       const glm::vec3 position(*focus - distance * rotateY(rotateX(glm::vec3(0.0f, 0.0f, 1.0f), pitch), yaw));
+       return glm::lookAt(position, *focus, glm::vec3(0.0f, 1.0f, 0.0f));
+}
+
+}