summaryrefslogtreecommitdiff
path: root/gfx/gl/camera.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-03-05 22:16:56 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2025-03-05 22:16:56 +0000
commit2454b5449bbda815eb15327476e376d0d3a39617 (patch)
tree405643f93a6e8eb2cd3f8b38a17649fd2f85f5a6 /gfx/gl/camera.h
parentHave Camera keep an array of frustum plane definitions (diff)
downloadilt-2454b5449bbda815eb15327476e376d0d3a39617.tar.bz2
ilt-2454b5449bbda815eb15327476e376d0d3a39617.tar.xz
ilt-2454b5449bbda815eb15327476e376d0d3a39617.zip
Move camera out of gl folder, it's not OpenGL specific
Diffstat (limited to 'gfx/gl/camera.h')
-rw-r--r--gfx/gl/camera.h94
1 files changed, 0 insertions, 94 deletions
diff --git a/gfx/gl/camera.h b/gfx/gl/camera.h
deleted file mode 100644
index d4fe6de..0000000
--- a/gfx/gl/camera.h
+++ /dev/null
@@ -1,94 +0,0 @@
-#pragma once
-
-#include "config/types.h"
-#include <glm/glm.hpp>
-#include <maths.h>
-#include <ray.h>
-
-class Camera {
-public:
- Camera(GlobalPosition3D, Angle fov, Angle aspect, GlobalDistance zNear, GlobalDistance zFar);
-
- [[nodiscard]] glm::mat4
- getViewProjection() const
- {
- return viewProjection;
- }
-
- [[nodiscard]] Ray<GlobalPosition3D> unProject(const ScreenRelCoord &) const;
-
- void
- setPosition(const GlobalPosition3D & p)
- {
- position = p;
- updateView();
- }
-
- void
- setForward(const Direction3D & f)
- {
- setForward(f, upFromForward(f));
- }
-
- void
- setForward(const Direction3D & f, const Direction3D & u)
- {
- forward = f;
- up = u;
- updateView();
- }
-
- void
- setView(const GlobalPosition3D & p, const Direction3D & f)
- {
- position = p;
- setForward(f);
- }
-
- void
- setView(const GlobalPosition3D & p, const Direction3D & f, const Direction3D & u)
- {
- position = p;
- setView(f, u);
- }
-
- void
- lookAt(const GlobalPosition3D & target)
- {
- setForward(glm::normalize(RelativePosition3D(target - position)));
- }
-
- [[nodiscard]] auto
- getForward() const
- {
- return forward;
- }
-
- [[nodiscard]] auto
- getPosition() const
- {
- return position;
- }
-
- [[nodiscard]] auto &
- getFrustumPlanes() const
- {
- return frustumPlanes;
- }
-
- [[nodiscard]] std::array<GlobalPosition4D, 4> extentsAtDist(GlobalDistance) const;
-
- [[nodiscard]] static Direction3D upFromForward(const Direction3D & forward);
-
-private:
- void updateView();
-
- GlobalPosition3D position;
- Direction3D forward;
- Direction3D up;
-
- GlobalDistance near, far;
- glm::mat4 view, projection;
- glm::mat4 viewProjection, inverseViewProjection;
- std::array<glm::vec4, 6> frustumPlanes;
-};