From 326094caf3f41c56feddf3b7a33f9d4d04606dcb Mon Sep 17 00:00:00 2001 From: Jan Mrna Date: Sat, 4 Oct 2025 17:10:20 +0200 Subject: [PATCH] Adde camera class --- cpp/src/camera.cpp | 16 ++++++++++++++++ cpp/src/camera.hpp | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 cpp/src/camera.cpp create mode 100644 cpp/src/camera.hpp diff --git a/cpp/src/camera.cpp b/cpp/src/camera.cpp new file mode 100644 index 0000000..322fe1f --- /dev/null +++ b/cpp/src/camera.cpp @@ -0,0 +1,16 @@ +#include "camera.hpp" +#include "math.hpp" + + +// for now only pass-through placeholder functions, +// since we draw the whole map + +WindowPos Camera::WorldToWindow(WorldPos world) const +{ + return WindowPos{world[0], world[1]}; +} + +WorldPos Camera::WindowToWorld(WindowPos window) const +{ + return WorldPos{window[0], window[1]}; +} diff --git a/cpp/src/camera.hpp b/cpp/src/camera.hpp new file mode 100644 index 0000000..1df41ec --- /dev/null +++ b/cpp/src/camera.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include "math.hpp" + +class Camera +{ +public: + WindowPos WorldToWindow(WorldPos) const; + WorldPos WindowToWorld(WindowPos) const; + +private: + // TODO this should be replaced with a matrix + float m_Zoom; + WorldPos m_RectCorner; // upper left corner (0,0) of the drawn regios + +};