From c2421c3ac2018faf5d47205ee979acec181d9672 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 2 Jan 2022 18:04:00 +0000 Subject: Separate geographic data (GeoData) from its visual representation(s) (Terrain) --- game/geoData.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 game/geoData.h (limited to 'game/geoData.h') 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 +#include +#include +#include +#include + +class GeoData { +public: + struct Node { + float height {-1.5F}; + }; + + using Limits = std::pair; + + 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 getNodes() const; + +protected: + Limits limit {}; // Base grid limits first(x,y) -> second(x,y) + glm::uvec2 size {}; + float scale {1}; + std::vector nodes; +}; -- cgit v1.2.3