12 float max_time = 0.0f;
17 if (last_time > max_time) max_time = last_time;
24 if (sampler->
count == 0)
return;
26 float duration = sampler->
times[sampler->
count - 1];
27 if (duration <= 0.0f) {
31 t = fmodf(t, duration);
34 while (i < sampler->count - 1 && t >= sampler->
times[i + 1]) {
38 if (i == sampler->
count - 1) {
44 float t0 = sampler->
times[i];
45 float t1 = sampler->
times[i + 1];
46 float alpha = (t - t0) / (t1 - t0);
53 memcpy(out_value, v0,
sizeof(
float) * sampler->
elem_count);
57 for (
int j = 0; j < sampler->
elem_count; j++) {
58 out_value[j] =
lerp(v0[j], v1[j], alpha);
64 memcpy(out_value, v0,
sizeof(
float) * sampler->
elem_count);
120 if (ac->
free)
continue;
156 for (
int k = 0; k < t->
kf_count; k++)
162 float start_time = k > 0 ? kf->
time : 0;
164 float current_end = kf2->
time - start_time;
165 float current_time = current_norm / current_end;
166 if (t->
data == NULL)
break;
176 *((
int*)t->
data) = (int)
lerp(kf->
val.i, kf2->
val.i, current_time);
179 *((
int*)t->
data) = (int)
lerp(kf->
val.i, kf2->
val.i, current_time);
void play_animation(Animation *anim, float time, int asset_instance)
Plays an animation at a certain time value.
Animation * find_animation(const char *name, int asset_instance)
Finds an animation via name.
void update_animation_components(float dt)
Updates animation components (not skeletal) once a frame.
void sample_animation(const AnimationSampler *sampler, float t, float *out_value)
Samples a value for an animation sampler at a certain time value.
float animation_length(Animation *anim)
Finds the length of an animation.
Engine specific types and defines.
Vector mesh_nodes
MeshNodes.
AnimationInterpolation interpolation
AnimationKeyframe kf[64]
The AnimationKeyframes for this track.
bool loop
If the animation loops.
size_t skin_count
The amount of GLTFSkins in this instance.
int animation_indices_count
The amount of Animation indices.
int animation_indices[256]
Animation indices into Asset.
AnimationSampler * samplers
AnimationTrack tracks[64]
The AnimationTracks with individual values that occur simultaneously.
int asset_id
The Asset ID in Globals.assets.
int kf_count
The amount of AnimationKeyframes.
Globals GLOBALS
Engine Globals.
size_t * node_indices
The indices of MeshNodes spawned from this instance inside of Globals.mesh_nodes.
bool free
If the component is empty.
AnimationTargetType completion_type
Type of data that is modified on completion.
float duration
The duration of all of the AnimationKeyframes.
void * data
Stored pointer to data to change during animation.
int track_count
The amount of AnimationTracks.
GLTFAnimationChannel * channels
union AnimationKeyframe::@243377164052067242366020157201307241363031166101 val
void * completion_data
Pointer to the data that is modified on completion.
AnimationTargetType type
The type of the data stored on AnimationKeyframe.
bool active
If this animation is currently running.
float current_time
How long the animation has been running.
size_t * skin_indices
The indices of GLTFSkins spawned from this instance inside of Globals.skins.
The structure of an Skeletatal Animation loaded in from GLTFAnimation.
The animation component for interpolation between AnimationKeyframes.
Tagged union for the value stored in a keyframe.
Engine-side sampler version of GLTFAnimationSampler with the field allocated.
Tagged union for the value stored in a keyframe.
An Asset after it is loaded in from file into Globals.assets.
A instance of an Asset that retains its node structure but can be duplicated into multiple instances ...
The channels of an Animation.
The structure of an Skeletatal Animation loaded in from GLTFAnimation.
MeshNodes that describe the position of Meshes, GLTF nodes for GLTFAnimations, or hold references to ...
Important globals for the entire engine and initialization functions that are mainly called on engine...
#define MAX_ANIMATION_COMPONENTS
AnimationComponent ANIMATION_COMPONENTS[MAX_ANIMATION_COMPONENTS]
float dt
The 1.0f/60 simulation timestep.
float time
The frame time but wrapping at 1.0.
AssetInstance ASSET_INSTANCES[MAX_ASSET_INSTANCES]
vec3 vec3_lerp(vec3 a, vec3 b, float t)
float lerp(float a, float b, float t)
#define CAST_VEC(vec, type)