Unravel Engine C++ Reference
Loading...
Searching...
No Matches
animation.h
Go to the documentation of this file.
1#pragma once
2#include <engine/engine_export.h>
3
4#include <math/math.h>
5
6#include <chrono>
7#include <string>
8#include <vector>
9
10namespace unravel
11{
12
19{
20 using seconds_t = std::chrono::duration<float>;
21
27 template<typename T>
28 struct key
29 {
30 friend auto operator==(const key& lhs, const key& rhs) -> bool = default;
31
34
36 T value = {};
37 };
38
39 friend auto operator==(const animation_channel& lhs, const animation_channel& rhs) -> bool = default;
40
41
42 auto get_position_keys_count() const -> size_t
43 {
44 return position_keys.size();
45 }
46
47 auto get_rotation_keys_count() const -> size_t
48 {
49 return rotation_keys.size();
50 }
51
52 auto get_scaling_keys_count() const -> size_t
53 {
54 return scaling_keys.size();
55 }
56
58 std::string node_name;
59
60 size_t node_index{};
61
63 std::vector<key<math::vec3>> position_keys;
64
66 std::vector<key<math::quat>> rotation_keys;
67
69 std::vector<key<math::vec3>> scaling_keys;
70};
71
72
74{
75
76 auto get_apply_root_motion() const -> bool
77 {
79 }
80
84
86
87 std::string position_node_name;
89
90 std::string rotation_node_name;
92};
99{
101
103 std::string name;
104
107
109 std::vector<animation_channel> channels;
110
112};
113
114} // namespace unravel
Struct representing a keyframe for animation.
Definition animation.h:29
seconds_t time
The time of the keyframe.
Definition animation.h:33
friend auto operator==(const key &lhs, const key &rhs) -> bool=default
T value
The value of the keyframe.
Definition animation.h:36
Struct representing a node animation.
Definition animation.h:19
std::vector< key< math::vec3 > > position_keys
The position keys of this animation channel. Positions are specified as 3D vector.
Definition animation.h:63
auto get_rotation_keys_count() const -> size_t
Definition animation.h:47
std::chrono::duration< float > seconds_t
Definition animation.h:20
auto get_scaling_keys_count() const -> size_t
Definition animation.h:52
auto get_position_keys_count() const -> size_t
Definition animation.h:42
friend auto operator==(const animation_channel &lhs, const animation_channel &rhs) -> bool=default
std::string node_name
The name of the node affected by this animation. The node must exist and it must be unique.
Definition animation.h:58
std::vector< key< math::vec3 > > scaling_keys
The scaling keys of this animation channel. Scalings are specified as 3D vector.
Definition animation.h:69
std::vector< key< math::quat > > rotation_keys
The rotation keys of this animation channel. Rotations are given as quaternions.
Definition animation.h:66
Struct representing an animation.
Definition animation.h:99
seconds_t duration
Duration of the animation_clip in seconds.
Definition animation.h:106
std::string name
The name of the animation_clip. Usually empty if the modeling package supports only a single animatio...
Definition animation.h:103
root_motion_params root_motion
Definition animation.h:111
animation_channel::seconds_t seconds_t
Definition animation.h:100
std::vector< animation_channel > channels
The node animation_clip channels. Each channel affects a single node.
Definition animation.h:109
std::string rotation_node_name
Definition animation.h:90
std::string position_node_name
Definition animation.h:87
auto get_apply_root_motion() const -> bool
Definition animation.h:76