diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-03 01:13:59 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-03 01:13:59 +0100 |
commit | ec1df0878b2f2b37055f0fce388cf9a027046c94 (patch) | |
tree | 8534555efacbb58f21d88aadc93072fc9bb66ceb /src/wall-atlas.hpp | |
parent | 6c7821f538d59db2059fb83fcc7f81b28b580036 (diff) |
wip
Diffstat (limited to 'src/wall-atlas.hpp')
-rw-r--r-- | src/wall-atlas.hpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/wall-atlas.hpp b/src/wall-atlas.hpp new file mode 100644 index 00000000..02d0ce91 --- /dev/null +++ b/src/wall-atlas.hpp @@ -0,0 +1,65 @@ +#pragma once +#include "src/rotation.hpp" +#include <array> +#include <Corrade/Containers/Array.h> +#include <Corrade/Containers/String.h> +#include <Magnum/Math/Vector2.h> +#include <Magnum/Math/Color.h> +#include <Magnum/GL/Texture.h> + +namespace floormat { + +struct wall_atlas; + +struct wall_frame +{ + Vector2ui offset = { (unsigned)-1, (unsigned)-1 }; +}; + +struct wall_frames +{ + uint32_t index = (uint32_t)-1, count = (uint32_t)-1; + Vector2ui pixel_size; + Color4 tint_mult{1,1,1,1}; + Color3 tint_add; + uint8_t from_rotation = (uint8_t)-1; + bool mirrored : 1 = false; + ArrayView<const wall_frame> items(const wall_atlas& a) const; +}; + +struct wall_frame_set +{ + wall_frames wall, overlay, side, top; + wall_frames corner_L, corner_R; +}; + +struct wall_info +{ + String name = "(unnamed)"_s; + float depth = 1; +}; + +struct wall_atlas final +{ + wall_atlas(); + wall_atlas(wall_info info, + const ImageView2D& image, + ArrayView<const wall_frame_set> rotations, + ArrayView<const wall_frame> frames); + ~wall_atlas() noexcept; + static size_t enum_to_index(enum rotation x); + const wall_frame_set& frameset(size_t i) const; + const wall_frame_set& frameset(enum rotation r) const; + const ArrayView<const wall_frame> array() const; + StringView name() const; + +private: + String _name; + std::array<wall_frame_set, 4> _rotations; + Array<wall_frame> _array; + GL::Texture2D _texture; + wall_info _info; + uint8_t _rotation_count = 0; +}; + +} // namespace floormat |