diff options
-rw-r--r-- | blender/concrete-wall1/concrete-wall1.json | 51 | ||||
-rw-r--r-- | blender/concrete-wall1/side/n/0001.png (renamed from blender/concrete-wall1/n_side_1.png) | bin | 2302 -> 2302 bytes | |||
-rw-r--r-- | blender/concrete-wall1/top/n/0001.png (renamed from blender/concrete-wall1/n_top_1.png) | bin | 2145 -> 2145 bytes | |||
-rw-r--r-- | blender/concrete-wall1/wall/n/0001.png (renamed from blender/concrete-wall1/n_front_1.png) | bin | 6322 -> 6322 bytes | |||
-rw-r--r-- | blender/concrete-wall1/wall/n/0002.png (renamed from blender/concrete-wall1/n_front_2.png) | bin | 7822 -> 7822 bytes | |||
-rw-r--r-- | blender/concrete-wall1/wall/n/0003.png (renamed from blender/concrete-wall1/n_front_3.png) | bin | 7512 -> 7512 bytes | |||
-rw-r--r-- | serialize/wall-atlas.cpp | 23 | ||||
-rw-r--r-- | test/json/wall-atlas-02_groups.json | 5 | ||||
-rw-r--r-- | test/wall-atlas.cpp | 22 | ||||
-rw-r--r-- | wall-tileset-tool/main.cpp | 4 |
10 files changed, 80 insertions, 25 deletions
diff --git a/blender/concrete-wall1/concrete-wall1.json b/blender/concrete-wall1/concrete-wall1.json new file mode 100644 index 00000000..196085bd --- /dev/null +++ b/blender/concrete-wall1/concrete-wall1.json @@ -0,0 +1,51 @@ +{ + "name": "foo", + "depth": 42, + "frames": [ + { + "offset": "0 x 0", + "size": "64 x 192" + }, + { + + "offset": "64 x 0", + "size": "64 x 64" + }, + { + + "offset": "128 x 0", + "size": "64 x 64" + } + ], + "n": { + "wall": { + "offset": 0, + "count": 1 + } + }, + "w": { + "pass-mode": "shoot-through", + "wall": { + "default-tint": false, + "offset": 0, + "count": 1 + }, + "side": { + "pixel-size": "42 x 192", + "default-tint": true + }, + "top": { + "pixel-size": "192 x 42", + "offset": 1, + "count": 2 + }, + "overlay": { + "pixel-size": "42 x 192", + "tint-mult": [ 0.125, 0.25, 0.5, 1 ], + "tint-add": [ 1, 2, 3 ], + "default-tint": false, + "mirrored": true + }, + "corner-L": { "from-rotation": "n" } + } +} diff --git a/blender/concrete-wall1/n_side_1.png b/blender/concrete-wall1/side/n/0001.png Binary files differindex 69b349c5..69b349c5 100644 --- a/blender/concrete-wall1/n_side_1.png +++ b/blender/concrete-wall1/side/n/0001.png diff --git a/blender/concrete-wall1/n_top_1.png b/blender/concrete-wall1/top/n/0001.png Binary files differindex 495a2e48..495a2e48 100644 --- a/blender/concrete-wall1/n_top_1.png +++ b/blender/concrete-wall1/top/n/0001.png diff --git a/blender/concrete-wall1/n_front_1.png b/blender/concrete-wall1/wall/n/0001.png Binary files differindex 5632b9d5..5632b9d5 100644 --- a/blender/concrete-wall1/n_front_1.png +++ b/blender/concrete-wall1/wall/n/0001.png diff --git a/blender/concrete-wall1/n_front_2.png b/blender/concrete-wall1/wall/n/0002.png Binary files differindex e6320348..e6320348 100644 --- a/blender/concrete-wall1/n_front_2.png +++ b/blender/concrete-wall1/wall/n/0002.png diff --git a/blender/concrete-wall1/n_front_3.png b/blender/concrete-wall1/wall/n/0003.png Binary files differindex 4da9d208..4da9d208 100644 --- a/blender/concrete-wall1/n_front_3.png +++ b/blender/concrete-wall1/wall/n/0003.png diff --git a/serialize/wall-atlas.cpp b/serialize/wall-atlas.cpp index ac37e59c..cbac35d5 100644 --- a/serialize/wall-atlas.cpp +++ b/serialize/wall-atlas.cpp @@ -190,7 +190,6 @@ bool is_direction_defined(const Direction& dir) Group read_group_metadata(const json& jgroup) { fm_assert(jgroup.is_object()); - Group val; { @@ -208,18 +207,24 @@ Group read_group_metadata(const json& jgroup) // todo check index within range } - if (jgroup.contains("pixel-size")) - val.pixel_size = jgroup["pixel-size"]; + val.default_tint = true; if (jgroup.contains("tint-mult")) + { val.tint_mult = jgroup["tint-mult"]; + val.default_tint = false; + } if (jgroup.contains("tint-add")) + { val.tint_add = jgroup["tint-add"]; + val.default_tint = false; + } + + if (jgroup.contains("pixel-size")) + val.pixel_size = jgroup["pixel-size"]; if (jgroup.contains("from-rotation") && !jgroup["from-rotation"].is_null()) val.from_rotation = (uint8_t)direction_index_from_name(std::string{ jgroup["from-rotation"] }); if (jgroup.contains("mirrored")) val.mirrored = !!jgroup["mirrored"]; - if (jgroup.contains("default-tint")) - val.default_tint = !!jgroup["default-tint"]; val.is_defined = true; return val; @@ -287,14 +292,16 @@ void write_group_metadata(json& jgroup, const Group& val) jgroup["count"] = val.count; jgroup["pixel-size"] = val.pixel_size; - jgroup["tint-mult"] = val.tint_mult; - jgroup["tint-add"] = val.tint_add; + if (!val.default_tint) + { + jgroup["tint-mult"] = val.tint_mult; + jgroup["tint-add"] = val.tint_add; + } if (val.from_rotation != group_defaults.from_rotation) jgroup["from-rotation"] = direction_index_to_name(val.from_rotation); else jgroup["from-rotation"] = nullptr; jgroup["mirrored"] = val.mirrored; - jgroup["default-tint"] = val.default_tint; } void write_direction_metadata(json& jdir, const Direction& dir) diff --git a/test/json/wall-atlas-02_groups.json b/test/json/wall-atlas-02_groups.json index 196085bd..ad4f0263 100644 --- a/test/json/wall-atlas-02_groups.json +++ b/test/json/wall-atlas-02_groups.json @@ -26,13 +26,11 @@ "w": { "pass-mode": "shoot-through", "wall": { - "default-tint": false, "offset": 0, "count": 1 }, "side": { - "pixel-size": "42 x 192", - "default-tint": true + "pixel-size": "42 x 192" }, "top": { "pixel-size": "192 x 42", @@ -43,7 +41,6 @@ "pixel-size": "42 x 192", "tint-mult": [ 0.125, 0.25, 0.5, 1 ], "tint-add": [ 1, 2, 3 ], - "default-tint": false, "mirrored": true }, "corner-L": { "from-rotation": "n" } diff --git a/test/wall-atlas.cpp b/test/wall-atlas.cpp index 2683c1dc..53c8b2de 100644 --- a/test/wall-atlas.cpp +++ b/test/wall-atlas.cpp @@ -61,17 +61,17 @@ void test_read_groups(StringView filename) const auto dir = read_direction_metadata(jroot, Direction_::W); fm_assert(is_direction_defined(dir)); - fm_assert(dir.passability == pass_mode::shoot_through); - fm_assert(dir.wall.pixel_size == Vector2ui{} ); - fm_assert(dir.wall.default_tint == false ); - fm_assert(dir.wall.mirrored == group_defaults.mirrored ); - fm_assert(dir.wall.from_rotation == (uint8_t)-1 ); - fm_assert(dir.side.pixel_size == Vector2ui{42, 192} ); - fm_assert(dir.side.default_tint == true ); - fm_assert(dir.top.default_tint == group_defaults.default_tint ); - fm_assert(dir.overlay.tint_mult == Vector4{0.125f, 0.25f, 0.5f, 1.f } ); - fm_assert(dir.overlay.tint_add == Vector3{1, 2, 3} ); - fm_assert(dir.overlay.mirrored == true ); + fm_assert(dir.passability == pass_mode::shoot_through); + fm_assert(dir.wall.pixel_size == Vector2ui{} ); + fm_assert(dir.overlay.default_tint == false ); + fm_assert(dir.wall.mirrored == false ); + fm_assert(dir.wall.from_rotation == (uint8_t)-1 ); + fm_assert(dir.side.pixel_size == Vector2ui{42, 192} ); + fm_assert(dir.side.default_tint == true ); + fm_assert(dir.top.default_tint == true ); + fm_assert(dir.overlay.tint_mult == Vector4{0.125f, 0.25f, 0.5f, 1.f } ); + fm_assert(dir.overlay.tint_add == Vector3{1, 2, 3} ); + fm_assert(dir.overlay.mirrored == true ); const auto atlas2 = wall_atlas_def::deserialize(path); fm_assert(atlas2.header == info); diff --git a/wall-tileset-tool/main.cpp b/wall-tileset-tool/main.cpp index 4736157a..8fc907ae 100644 --- a/wall-tileset-tool/main.cpp +++ b/wall-tileset-tool/main.cpp @@ -122,7 +122,7 @@ bool do_group(state st, size_t i, size_t j, Group& new_group) return false; } - cv::Mat mat = cv::imread(cv::String{filename.data(), filename.size()}), mat2; + cv::Mat mat = cv::imread(cv::String{filename.data(), filename.size()}, cv::IMREAD_ANYCOLOR), mat2; if ((Group_)j == Group_::top) { cv::rotate(mat, mat2, cv::ROTATE_90_COUNTERCLOCKWISE); @@ -130,7 +130,7 @@ bool do_group(state st, size_t i, size_t j, Group& new_group) swap(mat, mat2); } - if (Vector2ui((unsigned)mat.cols, (unsigned)mat.rows) != expected_size) [[unlikely]] + if (Vector2ui{(unsigned)mat.cols, (unsigned)mat.rows} != expected_size) [[unlikely]] { ERR << "fatal: wrong image size, expected size" << resolution{expected_size} << colon(',') |