summaryrefslogtreecommitdiffhomepage
path: root/src/anim-atlas.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-05 19:32:03 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-05 19:32:03 +0100
commit141ecedcacda8fa094a22da067fe24423f0d6f38 (patch)
tree67a8241c1bcd4d9788e93d472859ee15b496300b /src/anim-atlas.hpp
parent11f27ee84b255ee5a3f9d72832f5bfef261d2378 (diff)
wip
Diffstat (limited to 'src/anim-atlas.hpp')
-rw-r--r--src/anim-atlas.hpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/anim-atlas.hpp b/src/anim-atlas.hpp
index 186715ab..4c7140d9 100644
--- a/src/anim-atlas.hpp
+++ b/src/anim-atlas.hpp
@@ -1,30 +1,50 @@
#pragma once
#include "compat/defs.hpp"
+#include "scenery.hpp"
#include "serialize/anim.hpp"
+#include <array>
#include <Corrade/Containers/String.h>
+#include <Magnum/Math/Vector2.h>
#include <Magnum/GL/Texture.h>
-
namespace floormat {
struct anim_atlas final
{
- anim_atlas();
- anim_atlas(StringView name, GL::Texture2D&& tex, Serialize::anim metadata) noexcept;
+ using anim_info = Serialize::anim;
+ using anim_group = Serialize::anim_group;
+ using anim_frame = Serialize::anim_frame;
+ using texcoords = std::array<Vector2, 4>;
+
+ anim_atlas() noexcept;
+ anim_atlas(StringView name, GL::Texture2D&& tex, Vector2ui pixel_size, anim_info info) noexcept;
~anim_atlas() noexcept;
anim_atlas(anim_atlas&&) noexcept;
anim_atlas& operator=(anim_atlas&&) noexcept;
StringView name() const noexcept;
- GL::Texture2D texture() noexcept;
+ GL::Texture2D& texture() noexcept;
+ const anim_info& info() const noexcept;
+
+ const anim_group& group(rotation r) const noexcept;
+ const anim_frame& frame(rotation r, std::size_t frame) const noexcept;
+ texcoords frame_texcoords(rotation r, std::size_t frame) const noexcept;
+ texcoords frame_texcoords(const anim_frame& frame) const noexcept;
fm_DECLARE_DELETED_COPY_ASSIGNMENT(anim_atlas);
private:
GL::Texture2D _tex;
String _name;
- Serialize::anim _anim;
+ Vector2ui _pixel_size;
+ anim_info _info;
+ std::array<std::uint8_t, (std::size_t)rotation::COUNT> _group_indices = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+
+ static decltype(_group_indices) make_group_indices(const Serialize::anim& anim) noexcept;
+ static std::uint8_t rotation_to_index(const anim_info& a, rotation r) noexcept;
};
} // namespace floormat