From 3e3066111dd80ea7944f7897025952881b704352 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 12 Nov 2022 11:55:26 +0100 Subject: add z component to anim_group world offset --- anim/door_close.json | 24 ++++++++++++++++++---- anim/npc_walk.json | 48 +++++++++++++++++++++++++++++++++++-------- doc/atlas.json.example | 16 +++++++-------- serialize/anim.cpp | 1 + serialize/magnum-vector.hpp | 1 + serialize/magnum-vector2i.hpp | 1 + src/anim-atlas.cpp | 13 ++++++------ src/anim.cpp | 0 src/anim.hpp | 3 ++- 9 files changed, 79 insertions(+), 28 deletions(-) delete mode 100644 src/anim.cpp diff --git a/anim/door_close.json b/anim/door_close.json index de578210..0d666de7 100644 --- a/anim/door_close.json +++ b/anim/door_close.json @@ -283,7 +283,11 @@ ], "ground": "959 x 540", "name": "n", - "offset": "0 x -32" + "offset": [ + 0, + -32, + 0 + ] }, { "frames": [ @@ -565,7 +569,11 @@ ], "ground": "959 x 540", "name": "e", - "offset": "32 x 0" + "offset": [ + 32, + 0, + 0 + ] }, { "frames": [ @@ -847,7 +855,11 @@ ], "ground": "959 x 540", "name": "s", - "offset": "0 x 32" + "offset": [ + 0, + 32, + 0 + ] }, { "frames": [ @@ -1129,7 +1141,11 @@ ], "ground": "959 x 540", "name": "w", - "offset": "-32 x 0" + "offset": [ + -32, + 0, + 0 + ] } ], "height": 0, diff --git a/anim/npc_walk.json b/anim/npc_walk.json index f3d0add1..5cc7672a 100644 --- a/anim/npc_walk.json +++ b/anim/npc_walk.json @@ -248,7 +248,11 @@ ], "ground": "479 x 494", "name": "n", - "offset": "0 x 0" + "offset": [ + 0, + 0, + 0 + ] }, { "frames": [ @@ -495,7 +499,11 @@ ], "ground": "479 x 494", "name": "ne", - "offset": "0 x 0" + "offset": [ + 0, + 0, + 0 + ] }, { "frames": [ @@ -742,7 +750,11 @@ ], "ground": "479 x 494", "name": "e", - "offset": "0 x 0" + "offset": [ + 0, + 0, + 0 + ] }, { "frames": [ @@ -989,7 +1001,11 @@ ], "ground": "479 x 494", "name": "se", - "offset": "0 x 0" + "offset": [ + 0, + 0, + 0 + ] }, { "frames": [ @@ -1236,7 +1252,11 @@ ], "ground": "479 x 494", "name": "s", - "offset": "0 x 0" + "offset": [ + 0, + 0, + 0 + ] }, { "frames": [ @@ -1483,7 +1503,11 @@ ], "ground": "479 x 494", "name": "sw", - "offset": "0 x 0" + "offset": [ + 0, + 0, + 0 + ] }, { "frames": [ @@ -1730,7 +1754,11 @@ ], "ground": "479 x 494", "name": "w", - "offset": "0 x 0" + "offset": [ + 0, + 0, + 0 + ] }, { "frames": [ @@ -1977,7 +2005,11 @@ ], "ground": "479 x 494", "name": "nw", - "offset": "0 x 0" + "offset": [ + 0, + 0, + 0 + ] } ], "height": 0, diff --git a/doc/atlas.json.example b/doc/atlas.json.example index ee13dc67..56f16510 100644 --- a/doc/atlas.json.example +++ b/doc/atlas.json.example @@ -7,14 +7,14 @@ "pixel_size": "0 x 0", "groups": [ - { "frames": [], "ground": "0 x 0", "name": "n", "offset": "0 x 0" }, - { "frames": [], "ground": "0 x 0", "name": "ne", "offset": "0 x 0" }, - { "frames": [], "ground": "0 x 0", "name": "e", "offset": "0 x 0" }, - { "frames": [], "ground": "0 x 0", "name": "se", "offset": "0 x 0" }, - { "frames": [], "ground": "0 x 0", "name": "s", "offset": "0 x 0" }, - { "frames": [], "ground": "0 x 0", "name": "sw", "offset": "0 x 0" }, - { "frames": [], "ground": "0 x 0", "name": "w", "offset": "0 x 0" }, - { "frames": [], "ground": "0 x 0", "name": "nw", "offset": "0 x 0" } + { "frames": [], "ground": "0 x 0", "name": "n", "offset": [0, 0, 0] }, + { "frames": [], "ground": "0 x 0", "name": "ne", "offset": [0, 0, 0] }, + { "frames": [], "ground": "0 x 0", "name": "e", "offset": [0, 0, 0] }, + { "frames": [], "ground": "0 x 0", "name": "se", "offset": [0, 0, 0] }, + { "frames": [], "ground": "0 x 0", "name": "s", "offset": [0, 0, 0] }, + { "frames": [], "ground": "0 x 0", "name": "sw", "offset": [0, 0, 0] }, + { "frames": [], "ground": "0 x 0", "name": "w", "offset": [0, 0, 0] }, + { "frames": [], "ground": "0 x 0", "name": "nw", "offset": [0, 0, 0] } ] } // vim: ft=javascript diff --git a/serialize/anim.cpp b/serialize/anim.cpp index d59c7194..8080bb02 100644 --- a/serialize/anim.cpp +++ b/serialize/anim.cpp @@ -1,3 +1,4 @@ +#include "serialize/magnum-vector.hpp" #include "serialize/magnum-vector2i.hpp" #include "serialize/corrade-string.hpp" #include "serialize/anim.hpp" diff --git a/serialize/magnum-vector.hpp b/serialize/magnum-vector.hpp index f747fca7..08997b90 100644 --- a/serialize/magnum-vector.hpp +++ b/serialize/magnum-vector.hpp @@ -1,4 +1,5 @@ #pragma once +#include "magnum-vector2i.hpp" #include #include diff --git a/serialize/magnum-vector2i.hpp b/serialize/magnum-vector2i.hpp index d1074b55..a57429dc 100644 --- a/serialize/magnum-vector2i.hpp +++ b/serialize/magnum-vector2i.hpp @@ -1,3 +1,4 @@ +#pragma once #include "compat/assert.hpp" #include #include diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp index c874150e..cbcaac78 100644 --- a/src/anim-atlas.cpp +++ b/src/anim-atlas.cpp @@ -82,21 +82,20 @@ auto anim_atlas::texcoords_for_frame(rotation r, std::size_t i) const noexcept - auto anim_atlas::frame_quad(const Vector3& center, rotation r, std::size_t i) const noexcept -> quad { enum : std::size_t { x, y, z }; - const auto g = group(r); const auto f = frame(r, i); - const auto size = Vector2d(f.size); const auto gx = (float)f.ground[x]*.5f, gy = (float)f.ground[y]*.5f; + const auto size = Vector2d(f.size); const auto sx = (float)size[x]*.5f, sy = (float)size[y]*.5f; const auto bottom_right = tile_shader::unproject({ sx - gx, sy - gy }), top_right = tile_shader::unproject({ sx - gx, - gy }), bottom_left = tile_shader::unproject({ - gx, sy - gy }), top_left = tile_shader::unproject({ - gx, - gy }); - const auto cx = center[x] + g.offset[x], cy = center[y] + g.offset[y], cz = center[z]; + const auto c = center + Vector3(group(r).offset); return {{ - { cx + bottom_right[x], cy + bottom_right[y], cz }, - { cx + top_right[x], cy + top_right[y], cz }, - { cx + bottom_left[x], cy + bottom_left[y], cz }, - { cx + top_left[x], cy + top_left[y], cz }, + { c[x] + bottom_right[x], c[y] + bottom_right[y], c[z] }, + { c[x] + top_right[x], c[y] + top_right[y], c[z] }, + { c[x] + bottom_left[x], c[y] + bottom_left[y], c[z] }, + { c[x] + top_left[x], c[y] + top_left[y], c[z] }, }}; } diff --git a/src/anim.cpp b/src/anim.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/anim.hpp b/src/anim.hpp index 771df5d7..447c0410 100644 --- a/src/anim.hpp +++ b/src/anim.hpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace floormat { @@ -25,7 +26,7 @@ struct anim_group final String name; std::vector frames; Vector2ui ground; - Vector2b offset; + Vector3b offset; }; struct anim_def final -- cgit v1.2.3