Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
foray_animation.hpp
Go to the documentation of this file.
1#pragma once
2#include "../base/foray_framerenderinfo.hpp"
3#include "../foray_basics.hpp"
4#include "../foray_glm.hpp"
6#include <vector>
7
8namespace foray::scene {
11 {
12 Linear,
13 Step,
15 };
16
19 {
22 Scale
23 };
24
27 {
28 public:
30 inline AnimationKeyframe(float time, const glm::vec4& value) : Time(time), Value(value) {}
31 inline AnimationKeyframe(float time, const glm::vec4& value, const glm::vec4& intangent, const glm::vec4& outtangent)
32 : Time(time), Value(value), InTangent(intangent), OutTangent(outtangent)
33 {
34 }
35
36 float Time = 0.f;
37 glm::vec4 Value;
38 glm::vec4 InTangent;
39 glm::vec4 OutTangent;
40 };
41
44 {
45 public:
49 glm::vec3 SampleVec(float time) const;
53 glm::quat SampleQuat(float time) const;
54
55 static glm::vec4 InterpolateStep(float time, const AnimationKeyframe* lower, const AnimationKeyframe* upper);
56 static glm::vec4 InterpolateLinear(float time, const AnimationKeyframe* lower, const AnimationKeyframe* upper);
57 static glm::quat InterpolateLinearQuat(float time, const AnimationKeyframe* lower, const AnimationKeyframe* upper);
58 static glm::vec4 InterpolateCubicSpline(float time, const AnimationKeyframe* lower, const AnimationKeyframe* upper);
59 static glm::quat ReinterpreteAsQuat(glm::vec4);
60
62 std::vector<AnimationKeyframe> Keyframes = {};
63
64 protected:
65 void SelectKeyframe(float time, const AnimationKeyframe*& lower, const AnimationKeyframe*& upper) const;
66 };
67
70 {
71 public:
72 int32_t SamplerIndex = {-1};
73 Node* Target = {nullptr};
75 };
76
78 {
79 public:
81 bool Enable = true;
83 bool Loop = true;
85 float PlaybackSpeed = 1.f;
87 float ConstantDelta = 0.0f;
89 float Cursor = 0.f;
90 };
91
94 {
95 public:
97 FORAY_PROPERTY_R(Samplers)
98 FORAY_PROPERTY_R(Channels)
99 FORAY_PROPERTY_V(Start)
102
103
104 void Update(const base::FrameRenderInfo&);
105
106 protected:
108 std::string mName;
114 float mStart = {};
116 float mEnd = {};
119 };
120
121} // namespace foray::scene
Represents an animation, defined by atleast one channel affecting one node property each.
Definition foray_animation.hpp:94
std::vector< AnimationChannel > mChannels
Collection of channels. These bind keyframe values from samplers to node properties.
Definition foray_animation.hpp:112
float mEnd
The highest keyframe time value.
Definition foray_animation.hpp:116
void Update(const base::FrameRenderInfo &)
Applies current playback state.
float mStart
The lowest keyframe time value.
Definition foray_animation.hpp:114
std::vector< AnimationSampler > mSamplers
Collection of samplers. These contain raw keyframe values.
Definition foray_animation.hpp:110
PlaybackConfig mPlaybackConfig
Configuration representing current playback state.
Definition foray_animation.hpp:118
std::string mName
Animation name.
Definition foray_animation.hpp:108
A scene node. Extends the registry with hierarchical information.
Definition foray_node.hpp:8
#define FORAY_PROPERTY_V(member)
Getter+Setter shorthand for value types.
Definition foray_basics.hpp:81
#define FORAY_PROPERTY_R(member)
Getter+Setter shorthand for reference types.
Definition foray_basics.hpp:86
Definition foray_animation.hpp:8
EAnimationTargetPath
Target path defines which aspect of a nodes transforms the animation channel targets.
Definition foray_animation.hpp:19
EAnimationInterpolation
Interpolation mode defines how values are interpolated between keyframes.
Definition foray_animation.hpp:11
Definition foray_env.hpp:92
A channel is the animation of a single node property.
Definition foray_animation.hpp:70
int32_t SamplerIndex
Definition foray_animation.hpp:72
EAnimationTargetPath TargetPath
Definition foray_animation.hpp:74
Node * Target
Definition foray_animation.hpp:73
A set of values at a time point.
Definition foray_animation.hpp:27
AnimationKeyframe(float time, const glm::vec4 &value, const glm::vec4 &intangent, const glm::vec4 &outtangent)
Definition foray_animation.hpp:31
float Time
Definition foray_animation.hpp:36
glm::vec4 OutTangent
Definition foray_animation.hpp:39
glm::vec4 Value
Definition foray_animation.hpp:37
AnimationKeyframe(float time, const glm::vec4 &value)
Definition foray_animation.hpp:30
AnimationKeyframe()
Definition foray_animation.hpp:29
glm::vec4 InTangent
Definition foray_animation.hpp:38
A collection of keyframes.
Definition foray_animation.hpp:44
EAnimationInterpolation Interpolation
Definition foray_animation.hpp:61
glm::quat SampleQuat(float time) const
Get an interpolated sample.
static glm::vec4 InterpolateCubicSpline(float time, const AnimationKeyframe *lower, const AnimationKeyframe *upper)
static glm::quat ReinterpreteAsQuat(glm::vec4)
static glm::vec4 InterpolateStep(float time, const AnimationKeyframe *lower, const AnimationKeyframe *upper)
static glm::quat InterpolateLinearQuat(float time, const AnimationKeyframe *lower, const AnimationKeyframe *upper)
std::vector< AnimationKeyframe > Keyframes
Definition foray_animation.hpp:62
static glm::vec4 InterpolateLinear(float time, const AnimationKeyframe *lower, const AnimationKeyframe *upper)
glm::vec3 SampleVec(float time) const
Get an interpolated sample.
void SelectKeyframe(float time, const AnimationKeyframe *&lower, const AnimationKeyframe *&upper) const
Definition foray_animation.hpp:78
bool Enable
If false, playback is paused.
Definition foray_animation.hpp:81
float ConstantDelta
If non zero, will advance each frame with a constant delta time as opposed to the render engines fram...
Definition foray_animation.hpp:87
float Cursor
Current playback position used for interpolation.
Definition foray_animation.hpp:89
float PlaybackSpeed
Speed multiplier.
Definition foray_animation.hpp:85
bool Loop
The animation is looped if set to true.
Definition foray_animation.hpp:83