diff options
Diffstat (limited to 'big-atlas-tool/big-atlas.hpp')
-rw-r--r-- | big-atlas-tool/big-atlas.hpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/big-atlas-tool/big-atlas.hpp b/big-atlas-tool/big-atlas.hpp new file mode 100644 index 00000000..8d3f166a --- /dev/null +++ b/big-atlas-tool/big-atlas.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include <Magnum/Magnum.h> +#include <Magnum/Math/Vector2.h> +#include <opencv2/core/mat.hpp> + +namespace std::filesystem { class path; } + +struct big_atlas_frame { + cv::Mat4b frame; + Magnum::Vector2i position; +}; + +struct big_atlas_row { + std::vector<big_atlas_frame> frames; + int xpos = 0, ypos = 0; +}; + +struct big_atlas_builder { + [[nodiscard]] std::vector<big_atlas_frame> add_atlas(const std::filesystem::path& filename); + big_atlas_frame& add_frame(const cv::Mat4b& frame); + constexpr Magnum::Vector2i size() const { return {maxy, maxx}; } + const std::vector<big_atlas_row>& rows() const { return _rows; } + +private: + std::tuple<big_atlas_row&, int, int> advance(); + std::vector<big_atlas_row> _rows = {{}}; + int ypos = 0, maxx = 0, maxy = 0; + + static constexpr Magnum::Vector2i TILE_SIZE = { 100, 100 }, + MAX_TEXTURE_SIZE = { 500, 500 }; + + static_assert(!!TILE_SIZE[0] && !!TILE_SIZE[1] && !!MAX_TEXTURE_SIZE[0] && !!MAX_TEXTURE_SIZE[1]); + static_assert(MAX_TEXTURE_SIZE[0] >= TILE_SIZE[0] && MAX_TEXTURE_SIZE[1] >= TILE_SIZE[1]); +}; |