NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
visanimation.hpp
Go to the documentation of this file.
1
15#pragma once
16
17#include <map>
18#include <vector>
19
21#include "NNL/common/io.hpp"
23namespace nnl {
34namespace visanimation {
48struct KeyFrame {
51 u16 flags_enable_groups = 0b0000000000000000;
54};
55
66struct Animation {
67 std::vector<KeyFrame> left_channel;
68 std::vector<KeyFrame> right_channel;
69};
70
105 u16 flags_disable_left_channel = 0b0000000000000000;
108 u16 flags_disable_right_channel = 0b0000000000000000;
111 std::vector<Animation> animations;
114};
115
128AnimationContainer Convert(std::vector<SVisibilityAnimation>&& sanimations);
129
140std::vector<SVisibilityAnimation> Convert(const AnimationContainer& animation_container);
141
153bool IsOfType(BufferView buffer);
154
155bool IsOfType(const std::filesystem::path& path);
156
157bool IsOfType(Reader& f);
158
172
173AnimationContainer Import(const std::filesystem::path& path);
174
185[[nodiscard]] Buffer Export(const AnimationContainer& animation_container);
186
187void Export(const AnimationContainer& animation_container, const std::filesystem::path& path);
188
189void Export(const AnimationContainer& animation_container, Writer& f);
191
197
210
223SVisibilityAnimation Convert(const Animation& animation, u16 flags_disable_left, u16 flags_disable_right);
225
226namespace raw {
232constexpr u16 kMagicBytes = 0;
233
234NNL_PACK(struct RHeader {
235 u16 magic_bytes = kMagicBytes;
236 u16 num_animations = 0;
237 u16 flags_disable_left_channel = 0b0000000000000000;
238 u16 flags_disable_right_channel = 0b0000000000000000;
239});
240
241static_assert(sizeof(RHeader) == 0x8);
242
243NNL_PACK(struct RAnimation {
244 u32 offset_keyframes = 0;
245 u16 num_left_channel_keyframes = 0;
246 u16 num_right_channel_keyframes = 0;
247});
248
249static_assert(sizeof(RAnimation) == 0x8);
250
251NNL_PACK(struct RKeyFrame {
252 u16 time_tick = 0;
253 u16 flags_enable_groups = 0b0000000000000000;
254});
255
256static_assert(sizeof(RKeyFrame) == 0x4);
257
258struct RAnimationContainer {
259 RHeader header;
260 std::vector<RAnimation> animations;
261
262 // Maps of offsets (used in the structures above) to their data:
263 std::map<u32, std::vector<RKeyFrame>> keyframes;
264};
265
266AnimationContainer Convert(const RAnimationContainer& rsubanim);
267
268RAnimationContainer Parse(Reader& f);
270} // namespace raw
271} // namespace visanimation
272
273} // namespace nnl
Contains macros and definitions for fixed-width types.
std::uint16_t u16
16-bit unsigned integer
Definition fixed_type.hpp:62
std::uint32_t u32
32-bit unsigned integer
Definition fixed_type.hpp:60
#define NNL_PACK(...)
A structure packing directive.
Definition fixed_type.hpp:41
Reader implementation for read-only memory buffers.
Definition io.hpp:598
Abstract class for writing data.
Definition io.hpp:136
Abstract class for reading data.
Definition io.hpp:78
std::vector< u8 > Buffer
A type alias for std::vector<u8> that denotes a raw, contiguous memory region that may be interpreted...
Definition io.hpp:40
Represents a visibility animation of mesh groups.
Definition sanimation.hpp:149
std::vector< Animation > animations
Definition visanimation.hpp:111
u16 flags_disable_left_channel
Definition visanimation.hpp:105
u16 flags_disable_right_channel
Definition visanimation.hpp:108
std::vector< KeyFrame > right_channel
Keyframes for the right channel of the animation.
Definition visanimation.hpp:68
u16 flags_enable_groups
Definition visanimation.hpp:51
u16 time_tick
Definition visanimation.hpp:49
std::vector< KeyFrame > left_channel
Keyframes for the left channel of the animation.
Definition visanimation.hpp:67
Holds a collection of visibility animations.
Definition visanimation.hpp:104
Represents a keyframe in a visibility animation.
Definition visanimation.hpp:48
Represents a single visibility animation.
Definition visanimation.hpp:66
AnimationContainer Convert(std::vector< SVisibilityAnimation > &&sanimations)
Converts multiple simple visibility animations to the in-game format.
Buffer Export(const AnimationContainer &animation_container)
Exports animations to a binary file format.
bool IsOfType(BufferView buffer)
Tests if the provided file is a visibility animation.
AnimationContainer Import(BufferView buffer)
Imports animations from a binary file.
constexpr u16 kMagicBytes
Magic bytes (?)
Definition visanimation.hpp:232
Provides classes for reading and writing binary data to and from various sources.
Contains functions and structures for working with in-game skeletal animations.
Definition animation.hpp:30
Contains functions and structures for working with "sub" animations that control the visibility of me...
Definition visanimation.hpp:34
Definition exception.hpp:56
Provides data structures for representing various animation types and their essential components.