1#ifndef NNGN_ANIMATION_H
2#define NNGN_ANIMATION_H
13#include "utils/flags.h"
24class AnimationFunction {
26 enum class Type : uint8_t {
31 struct linear_t {
float v = 0,
step_s = 0,
end = 0; };
34 std::uniform_real_distribution<float>
rnd_f;
35 std::array<std::uniform_real_distribution<float>, 3>
rnd_3f;
48class SpriteAnimation :
public Animation {
51 std::array<vec2, 2>
uv;
54 using Track = std::vector<Frame>;
55 using Group = std::vector<Track>;
57 std::shared_ptr<const Group>
m_group = {};
59 std::chrono::microseconds
timer = {};
72 std::chrono::milliseconds
rate = {},
timer = {};
73 AnimationFunction
f = {};
78 float *
a,
bool *updated);
84 std::vector<SpriteAnimation>
sprite = {};
85 std::vector<LightAnimation>
light = {};
89 size_t max_sprite()
const {
return this->sprite.capacity(); }
90 size_t max_light()
const {
return this->light.capacity(); }
92 size_t n_sprite()
const {
return this->sprite.size(); }
93 size_t n_light()
const {
return this->light.size(); }
Type type
Definition: animation.h:30
linear_t linear
Definition: animation.h:33
std::uniform_real_distribution< float > rnd_f
Definition: animation.h:34
void load(nngn::lua::table_view t)
vec3 update(const Timing &t, Math::rnd_generator_t *rnd)
AnimationFunction() noexcept
Definition: animation.h:38
Type
Definition: animation.h:26
std::array< std::uniform_real_distribution< float >, 3 > rnd_3f
Definition: animation.h:35
Definition: animation.h:82
size_t max_sprite() const
Definition: animation.h:89
size_t n_sprite() const
Definition: animation.h:92
void init(Math *m)
Definition: animation.h:87
Animation * load(nngn::lua::table_view t)
size_t n() const
Definition: animation.h:91
Math * math
Definition: animation.h:83
std::vector< LightAnimation > light
Definition: animation.h:85
void remove(Animation *p)
size_t max() const
Definition: animation.h:88
size_t max_light() const
Definition: animation.h:90
std::vector< SpriteAnimation > sprite
Definition: animation.h:84
size_t n_light() const
Definition: animation.h:93
void update(const Timing &t)
Definition: animation.h:71
void update(const Timing &t, Math::rnd_generator_t *rnd)
void load(nngn::lua::table_view t)
std::chrono::milliseconds timer
Definition: animation.h:72
void update(const Timing &t, Math::rnd_generator_t *rnd, float *a, bool *updated)
AnimationFunction f
Definition: animation.h:73
std::chrono::milliseconds rate
Definition: animation.h:72
Definition: animation.h:48
std::shared_ptr< const Group > m_group
Definition: animation.h:57
size_t m_cur_track
Definition: animation.h:58
void set_track(size_t index)
void load(SpriteAnimation *o)
std::vector< Frame > Track
Definition: animation.h:54
auto cur_track() const
Definition: animation.h:64
bool updated
Definition: animation.h:60
size_t cur_frame
Definition: animation.h:58
std::chrono::microseconds timer
Definition: animation.h:59
void update(const Timing &t)
void load(nngn::lua::table_view t)
const Frame * cur() const
std::vector< Track > Group
Definition: animation.h:55
auto track_count() const
Definition: animation.h:65
rnd
Definition: players.lua:9
float end
Definition: animation.h:31
float step_s
Definition: animation.h:31
float v
Definition: animation.h:31
Definition: animation.h:44
Entity * entity
Definition: animation.h:45
Type
Supported parameter types for kernel execution.
Definition: compute.h:133
Definition: animation.h:50
std::array< vec2, 2 > uv
Definition: animation.h:51
std::chrono::milliseconds duration
Definition: animation.h:52
Non-owning reference to a table on the stack.
Definition: table.h:166