vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
animation.h
1#pragma once
2
3#include <algorithm>
4
5#include <glm/glm.hpp>
6#include <glm/gtc/quaternion.hpp>
7
8#include "ecs/component/animation/animation_track.h"
9
10namespace Vkm::Engine {
11
17struct Animation {
18 AnimationTrack<glm::vec3> positionTrack;
19 AnimationTrack<glm::quat> rotationTrack;
21
22 float length = 0.0f;
23 float time = 0.0f;
24 float speed = 1.0f;
25 bool looping = true;
26
33 bool playOnStart = true;
34
36 bool playing = false;
37
39 bool started = false;
40
47 static float computeDuration(const Animation& animation) {
48 return std::max({
49 animation.positionTrack.getDuration(),
50 animation.rotationTrack.getDuration(),
51 animation.scaleTrack.getDuration(),
52 animation.length
53 });
54 }
55};
56
57} // namespace Vkm::Engine
Keyframes of type T sorted by time, sampled through an easing curve.
Definition animation_track.h:22
float getDuration() const
The track's length.
Definition animation_track.h:183
Component representing an animation that can be applied to an entity.
Definition animation.h:17
float time
Playback head in seconds; session state, unserialized.
Definition animation.h:23
bool started
Whether playOnStart has been honoured this session. Session state.
Definition animation.h:39
float length
Minimum length in seconds (0 = last keyframe)
Definition animation.h:22
bool playing
Session state.
Definition animation.h:36
static float computeDuration(const Animation &animation)
The effective length: the latest keyframe of the three tracks, or length if greater.
Definition animation.h:47
bool playOnStart
Start playing on the first frame the simulation runs.
Definition animation.h:33
float speed
Playback speed multiplier.
Definition animation.h:24