summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--big-atlas-tool/CMakeLists.txt10
-rw-r--r--big-atlas-tool/big-atlas.cpp77
-rw-r--r--big-atlas-tool/big-atlas.hpp35
-rw-r--r--big-atlas-tool/main.cpp34
5 files changed, 0 insertions, 157 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 85fe9829..5bb59495 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,7 +58,6 @@ if(NOT BOOTSTRAP_DEPENDS)
include_directories(.)
add_subdirectory(anim-crop-tool)
- add_subdirectory(big-atlas-tool)
add_subdirectory(anim)
add_subdirectory(tile)
diff --git a/big-atlas-tool/CMakeLists.txt b/big-atlas-tool/CMakeLists.txt
deleted file mode 100644
index 15b8e73f..00000000
--- a/big-atlas-tool/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-find_package(OpenCV QUIET REQUIRED COMPONENTS core imgcodecs imgproc)
-set(self "${PROJECT_NAME}-big-atlas-tool")
-
-include_directories(SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS})
-link_libraries(Corrade::Utility)
-link_libraries(${PROJECT_NAME}-tile)
-
-file(GLOB sources "*.cpp" CONFIGURE_ARGS)
-add_executable(${self} ${sources})
-install(TARGETS ${self} RUNTIME DESTINATION "bin")
diff --git a/big-atlas-tool/big-atlas.cpp b/big-atlas-tool/big-atlas.cpp
deleted file mode 100644
index 50a659a3..00000000
--- a/big-atlas-tool/big-atlas.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#undef NDEBUG
-
-#include "big-atlas.hpp"
-#include <cassert>
-#include <filesystem>
-#include <Corrade/Utility/DebugStl.h>
-#include <opencv2/imgproc/imgproc.hpp>
-#include <opencv2/imgcodecs/imgcodecs.hpp>
-
-using Corrade::Utility::Error;
-
-std::vector<big_atlas_frame> big_atlas_builder::add_atlas(const std::filesystem::path& filename)
-{
- std::vector<big_atlas_frame> ret;
- cv::Mat mat = cv::imread(filename.string(), cv::IMREAD_UNCHANGED);
- if (mat.empty() || (mat.type() != CV_8UC4 && mat.type() != CV_8UC3))
- {
- Error{} << "failed to load" << filename << "as RGBA32 image";
- return {};
- }
- if (mat.type() == CV_8UC3) {
- cv::Mat mat2;
- cv::cvtColor(mat, mat2, cv::COLOR_RGB2RGBA);
- mat = std::move(mat2);
- }
-
- Error{} << "file" << filename;
-
- assert(mat.cols % TILE_SIZE[0] == 0 && mat.rows % TILE_SIZE[1] == 0);
-
- cv::Mat1b cn;
-
- for (int y = 0; y + TILE_SIZE[1] <= mat.rows; y += TILE_SIZE[1])
- for (int x = 0; x + TILE_SIZE[0] <= mat.cols; x += TILE_SIZE[0])
- {
- cv::Rect roi { x, y, TILE_SIZE[0], TILE_SIZE[1] };
- const auto m = mat(roi);
- cv::extractChannel(m, cn, 3);
- if (cv::countNonZero(cn) > 0)
- {
- auto frame = add_frame(m);
- ret.push_back(frame);
- }
- }
-
- return ret;
-}
-
-big_atlas_frame& big_atlas_builder::add_frame(const cv::Mat4b& frame)
-{
- auto [row, xpos, ypos] = advance();
- row.frames.push_back({ frame, { xpos, ypos } });
- return row.frames.back();
-}
-
-std::tuple<big_atlas_row&, int, int> big_atlas_builder::advance()
-{
- auto& row = _rows.back();
- const int xpos_ = row.xpos;
- row.xpos += TILE_SIZE[0];
-
- if (row.xpos + TILE_SIZE[0] > MAX_TEXTURE_SIZE[0])
- {
- ypos += TILE_SIZE[1];
- assert(ypos < MAX_TEXTURE_SIZE[1]);
- _rows.emplace_back();
- auto& row = _rows.back();
- row.ypos = ypos;
- row.xpos = 0;
- return { row, 0, row.ypos };
- }
- else {
- maxx = std::max(maxx, row.xpos);
- maxy = row.ypos + TILE_SIZE[1];
- return { row, xpos_, row.ypos };
- }
-}
diff --git a/big-atlas-tool/big-atlas.hpp b/big-atlas-tool/big-atlas.hpp
deleted file mode 100644
index b95da00f..00000000
--- a/big-atlas-tool/big-atlas.hpp
+++ /dev/null
@@ -1,35 +0,0 @@
-#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 {maxx, maxy}; }
- 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 = { 8192, 8192 };
-
- 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]);
-};
diff --git a/big-atlas-tool/main.cpp b/big-atlas-tool/main.cpp
deleted file mode 100644
index edc882ad..00000000
--- a/big-atlas-tool/main.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "big-atlas.hpp"
-#include "tile/serialize.hpp"
-#include <tuple>
-#include <filesystem>
-#include <Corrade/Utility/Arguments.h>
-
-using Corrade::Utility::Arguments;
-
-struct options final {
- std::filesystem::path input_dir, output_file;
-};
-
-static std::tuple<options, Arguments, bool> parse_cmdline(int argc, const char* const* argv) noexcept
-{
- Corrade::Utility::Arguments args{};
- args.addOption('o', "output")
- .addArrayArgument("input");
- args.parse(argc, argv);
- options opts;
- opts.input_dir = args.value<std::string>("input");
-
- if (opts.input_dir.empty())
- opts.output_file = opts.input_dir.parent_path() / "big-atlas.json";
-
- return { std::move(opts), std::move(args), true };
-}
-
-int main(int argc, char** argv)
-{
- big_atlas_builder builder;
- builder.add_atlas("images/metal1.png");
- builder.add_atlas("images/metal2.png");
- return 0;
-}