summaryrefslogtreecommitdiff
path: root/game/geoData.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-01-02 18:04:00 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-01-02 18:04:00 +0000
commitc2421c3ac2018faf5d47205ee979acec181d9672 (patch)
tree53651bfd3e5839c8334862f311466041da5f4d91 /game/geoData.h
parentUse Cache system to persist font rendering for Text (diff)
downloadilt-c2421c3ac2018faf5d47205ee979acec181d9672.tar.bz2
ilt-c2421c3ac2018faf5d47205ee979acec181d9672.tar.xz
ilt-c2421c3ac2018faf5d47205ee979acec181d9672.zip
Separate geographic data (GeoData) from its visual representation(s) (Terrain)
Diffstat (limited to 'game/geoData.h')
-rw-r--r--game/geoData.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/game/geoData.h b/game/geoData.h
new file mode 100644
index 0000000..39c149c
--- /dev/null
+++ b/game/geoData.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <filesystem>
+#include <glm/glm.hpp>
+#include <span>
+#include <utility>
+#include <vector>
+
+class GeoData {
+public:
+ struct Node {
+ float height {-1.5F};
+ };
+
+ using Limits = std::pair<glm::ivec2, glm::ivec2>;
+
+ GeoData() = default;
+ explicit GeoData(Limits limit, float scale = 10.F);
+
+ void generateRandom();
+ void loadFromImages(const std::filesystem::path &, float scale);
+
+ [[nodiscard]] unsigned int at(glm::ivec2) const;
+ [[nodiscard]] unsigned int at(int x, int y) const;
+
+ [[nodiscard]] Limits getLimit() const;
+ [[nodiscard]] glm::uvec2 getSize() const;
+ [[nodiscard]] float getScale() const;
+ [[nodiscard]] std::span<const Node> getNodes() const;
+
+protected:
+ Limits limit {}; // Base grid limits first(x,y) -> second(x,y)
+ glm::uvec2 size {};
+ float scale {1};
+ std::vector<Node> nodes;
+};