Untitled
Loading...
Searching...
No Matches
animation.h File Reference

Skeletal animation and animation component playback and management. More...

#include "engine_types.h"

Go to the source code of this file.

Functions

void sample_animation (const AnimationSampler *sampler, float t, float *out_value)
 Samples a value for an animation sampler at a certain time value.
void play_animation (Animation *anim, float time, int entity_id)
 Plays an animation at a certain time value.
float animation_length (Animation *anim)
 Finds the length of an animation.
Animation * find_animation (const char *name, int entity_id)
 Finds an animation via name.
void update_animation_components (float dt)
 Updates animation components (not skeletal) once a frame.

Detailed Description

Skeletal animation and animation component playback and management.

Definition in file animation.h.

Function Documentation

◆ sample_animation()

void sample_animation ( const AnimationSampler * sampler,
float t,
float * out_value )

Samples a value for an animation sampler at a certain time value.

Parameters
sampleThe animation sampler to sample.
tThe time to sample at.
out_valuePointer to the float that recieves the value.
Precondition
out_value must not be NULL.

Definition at line 23 of file animation.c.

References AnimationSampler::count, CUBICSPLINE, AnimationSampler::elem_count, AnimationSampler::interpolation, lerp(), LINEAR, sample_animation(), STEP, AnimationSampler::times, and AnimationSampler::values.

Referenced by play_animation(), and sample_animation().

◆ play_animation()

void play_animation ( Animation * anim,
float time,
int entity_id )

Plays an animation at a certain time value.

Parameters
animThe animation to play.
timeThe time to play the animation at.
entity_idThe entity that plays the animation.

Definition at line 68 of file animation.c.

References ASSET_INSTANCES, CAST_VEC, Animation::channel_count, Animation::channels, GLOBALS, Globals::mesh_nodes, AssetInstance::node_indices, GLTFAnimationChannel::path, play_animation(), MeshNode::rotation, sample_animation(), GLTFAnimationChannel::sampler, Animation::samplers, MeshNode::scale, GLTFAnimationChannel::target_node, TARGET_ROTATION, TARGET_SCALE, TARGET_TRANSLATION, TARGET_WEIGHTS, time, and MeshNode::translation.

Referenced by play_animation(), and render().

◆ animation_length()

float animation_length ( Animation * anim)

Finds the length of an animation.

Parameters
animThe animation to use.

Definition at line 10 of file animation.c.

References animation_length(), AnimationSampler::count, Animation::sampler_count, Animation::samplers, and AnimationSampler::times.

Referenced by animation_length(), and render().

◆ find_animation()

Animation * find_animation ( const char * name,
int entity_id )

Finds an animation via name.

Parameters
nameThe name of the animation.
entity_idThe entity to query.

Definition at line 91 of file animation.c.

References GLTFSkin::animation_indices, GLTFSkin::animation_indices_count, Asset::animations, AssetInstance::asset_id, ASSET_INSTANCES, Globals::assets, CAST_VEC, find_animation(), GLOBALS, Animation::name, AssetInstance::skin_count, AssetInstance::skin_indices, and Globals::skins.

Referenced by find_animation(), and render().

◆ update_animation_components()