NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
sanimation.hpp
Go to the documentation of this file.
1
16#pragma once
17
18#include <array>
19#define GLM_ENABLE_EXPERIMENTAL
20#include <glm/glm.hpp>
21#include <glm/gtx/quaternion.hpp>
22#include <map>
23#include <string>
24#include <vector>
25
28
29namespace nnl {
30
37
50template <typename T>
51struct SKeyFrame {
52 u16 time = 0;
53 T value{};
54};
55
67enum class SInterpolationMode { kLinear, kConstant };
68
82 std::vector<SKeyFrame<glm::vec3>> scale_keys;
83 std::vector<SKeyFrame<glm::quat>> rotation_keys;
84 std::vector<SKeyFrame<glm::vec3>> translation_keys;
85};
86
97struct SAnimation {
98 std::string name;
99
102
103 std::vector<SBoneChannel> bone_channels;
108
117 void Unbake(float tolerance = 1.0e-4f);
124 void Bake();
125};
126
131using SVisibilityChannel = std::vector<SKeyFrame<bool>>;
132
150 std::string name;
151 std::array<SVisibilityChannel, 16> visibility_channels;
152};
153
160 std::vector<SKeyFrame<glm::vec2>> keys;
161};
162
175 std::string name;
176
177 std::map<std::size_t, SUVChannel> translation_channels;
182};
183
184} // namespace nnl
Contains macros and definitions for fixed-width types.
std::uint16_t u16
16-bit unsigned integer
Definition fixed_type.hpp:62
std::vector< SKeyFrame< glm::quat > > rotation_keys
Rotation transformations.
Definition sanimation.hpp:83
std::vector< SKeyFrame< glm::vec3 > > translation_keys
Translation transformations.
Definition sanimation.hpp:84
std::array< SVisibilityChannel, 16 > visibility_channels
Channels for 16 mesh groups.
Definition sanimation.hpp:151
T value
The new value at the specified time.
Definition sanimation.hpp:53
std::string name
An optional name of the animation.
Definition sanimation.hpp:98
void Bake()
Bakes the animation.
u16 duration
Definition sanimation.hpp:100
std::vector< SKeyFrame< glm::vec2 > > keys
The keyframes.
Definition sanimation.hpp:160
std::string name
An optional name for the animation.
Definition sanimation.hpp:150
u16 time
The timestamp in ticks (1 tick ~ 1 frame).
Definition sanimation.hpp:52
void Unbake(float tolerance=1.0e-4f)
Removes redundant keyframes.
std::string name
An optional name for the animation.
Definition sanimation.hpp:175
std::map< std::size_t, SUVChannel > translation_channels
Definition sanimation.hpp:177
SValue extras
Any additional data for custom use.
Definition sanimation.hpp:107
SValue extras
Any additional data for custom use.
Definition sanimation.hpp:181
SInterpolationMode interpolation
The method used to interpolate between keyframes.
Definition sanimation.hpp:159
std::vector< SBoneChannel > bone_channels
Definition sanimation.hpp:103
std::vector< SKeyFrame< glm::vec3 > > scale_keys
Scale transformations.
Definition sanimation.hpp:82
A single animation track for UV coordinates.
Definition sanimation.hpp:158
Represents a texture coordinate animation.
Definition sanimation.hpp:174
Represents a visibility animation of mesh groups.
Definition sanimation.hpp:149
Represents a single keyframe in an animation.
Definition sanimation.hpp:51
Represents the animation tracks for a single bone.
Definition sanimation.hpp:81
Represents a skeletal animation.
Definition sanimation.hpp:97
std::vector< SKeyFrame< bool > > SVisibilityChannel
A single animation track for visibility of a mesh group.
Definition sanimation.hpp:131
SInterpolationMode
Enumeration of interpolation modes for animations.
Definition sanimation.hpp:67
A class representing JSON-like values (null, bool, numbers, strings, arrays, or objects)
Definition svalue.hpp:41
Definition exception.hpp:56
Provides a class for representing "extras" fields for custom metadata.