Tramway SDK
|
Plays back Animations. More...
#include <components/animation.h>
Classes | |
struct | AnimationPlaybackInfo |
Public Member Functions | |
void | Start () |
void | SetModel (Render::Model *model) |
void | SetModel (name_t model) |
Render::Model * | GetModel () |
Render::Pose * | GetPose () |
void | SetKeyframe (name_t bone_name, const Render::Keyframe &keyframe) |
Sets procedural animation keyframe. More... | |
void | SetOnAnimationFinishCallback (void(*callback)(AnimationComponent *, name_t)) |
void | Play (name_t animation_name, uint32_t repeats, float weight, float speed, bool interpolate=true, bool pause_on_last_frame=false) |
Plays an animation. More... | |
bool | IsPlaying (name_t animation_name) |
Returns true if an animation is playing. More... | |
void | Stop (name_t animation_name) |
Stops an animation if its playing. More... | |
void | Pause (name_t animation_name) |
Pauses an animation. More... | |
void | Continue (name_t animation_name) |
Continues an animation. More... | |
void | SetWeight (name_t animation_name, float weight) |
Sets the weight of an animation. More... | |
void | SetSpeed (name_t animation_name, float speed) |
Sets the speed of an animation. More... | |
void | SetRepeats (name_t animation_name, uint32_t repeats) |
Sets the repeats of an animation. More... | |
void | FadeIn (name_t animation_name, float length) |
Fades in an animation. More... | |
void | FadeOut (name_t animation_name, float length) |
Fades out an animation. More... | |
void | SetPause (name_t animation_name, bool pause) |
Sets animation's pause state. More... | |
void | SetFade (name_t animation_name, bool fade_in, float fade_length) |
Fades in or fades out an animation. More... | |
void | SetFrame (name_t animation_name, float frame) |
Sets an animation to a specific frame. More... | |
void | Reparent (name_t bone_name, name_t new_parent) |
Reparents a bone. More... | |
void | Refresh () |
Updates an armature. More... | |
void | EventHandler (Event &event) |
![]() | |
EntityComponent ()=default | |
virtual | ~EntityComponent ()=default |
virtual void | Init () |
Initializes an entity component. More... | |
bool | IsReady () |
Returns the component's readiness. More... | |
bool | IsInit () |
Returns the component's init status. More... | |
Entity * | GetParent () |
void | SetParent (Entity *parent) |
Static Public Member Functions | |
static bool | IsDebugInfoDraw () |
Checks whether the debug text is drawn. More... | |
static void | SetDebugInfoDraw (bool draw) |
Sets the drawing of debug info. More... | |
static void | Update () |
Updates all of the armatures. More... | |
Protected Member Functions | |
void | FindKeyframePointers (Render::Animation *animation, size_t animation_index) |
Extracts pointers to keyframes from animation data. More... | |
AnimationComponent () | |
~AnimationComponent () | |
![]() | |
void | ResourceReady () |
Notifies the component of a streamed-in resource. More... | |
Protected Attributes | |
Render::Keyframe | base_pose [Render::BONE_COUNT] |
Render::Pose * | pose = nullptr |
ResourceProxy< Render::Model > | model |
void(* | anim_finish_callback )(AnimationComponent *, name_t) = nullptr |
const Render::Bone * | armature_bones = nullptr |
size_t | armature_bone_count = 0 |
int32_t | armature_bone_parents [Render::BONE_COUNT] = {-1} |
name_t | anim_playing [ANIM_COUNT] |
AnimationPlaybackInfo | anim_info [ANIM_COUNT] |
![]() | |
size_t | resources_waiting = 0 |
bool | is_ready = false |
bool | is_init = false |
Entity * | parent = nullptr |
Static Protected Attributes | |
static const size_t | ANIM_COUNT = 8 |
Friends | |
template<typename > | |
class | Pool |
Plays back Animations.
|
protected |
|
protected |
void tram::AnimationComponent::Continue | ( | name_t | animation_name | ) |
Continues an animation.
If an animation is paused, it will continue playback. Otherwise this method will do nothing.
|
inlinevirtual |
Implements tram::EntityComponent.
void tram::AnimationComponent::FadeIn | ( | name_t | animation_name, |
float | speed | ||
) |
Fades in an animation.
Before fading in an animation, it must be started with Play().
void tram::AnimationComponent::FadeOut | ( | name_t | animation_name, |
float | length | ||
) |
Fades out an animation.
|
protected |
Extracts pointers to keyframes from animation data.
|
inline |
|
inline |
|
static |
Checks whether the debug text is drawn.
Check SetDebugInfoDraw() for more info.
bool tram::AnimationComponent::IsPlaying | ( | name_t | animation_name | ) |
Returns true if an animation is playing.
void tram::AnimationComponent::Pause | ( | name_t | animation_name | ) |
Pauses an animation.
If the animation is being played, it will be paused. Otherwise this method will do nothing. Use Continue() method to continue playing the animation.
void tram::AnimationComponent::Play | ( | name_t | animation_name, |
uint32_t | repeats, | ||
float | weight, | ||
float | speed, | ||
bool | interpolate = true , |
||
bool | pause_on_last_frame = false |
||
) |
Plays an animation.
Animation must be already loaded before playing.
animation_name | Name of the animation to be played. |
repeats | How many times the animation will be looped before stopping. |
weight | Weight of the animation. Set to 1.0 for normal weight. Should be in range from 0.0 to 1.0, if set outside of range, then the animation might look really weird. |
speed | Speed of the animation. Value of 1.0 will play the animation at regular speed, 0.5 will play it half speed, 2.0 double speed. |
interpolate | If set to true, then animation will be interpolated, if set to false, then it will use only the latest keyframe. |
pause_on_last | If set to true, then the animation will pause on the last keyframe. |
void tram::AnimationComponent::Refresh | ( | ) |
Updates an armature.
Pushes animations forward and regenerates matrices.
Reparents a bone.
Make sure to not create cycles in the bone hierarchy.
bone_name | Name of the bone for which a new parent will be set. |
new_parent | Name of the bone which will be the new parent. Can be set to "none" to clear the bone's parent. |
|
static |
Sets the drawing of debug info.
If set to true, each frame some debug text will be drawn for each animation component. This is useful for debugging.
void tram::AnimationComponent::SetFade | ( | name_t | animation_name, |
bool | fade_in, | ||
float | fade_length | ||
) |
Fades in or fades out an animation.
This will gradually increase or decrease the weight of an animation until it is fully faded in or faded out. The animation must already be started with Play() for it to be faded, otherwise this method will do nothing. If an animation is fully faded out, it will automatically be stopped.
animation_name | Name of the animation to be faded. |
fade_in | Set to true, if animation is to be faded in, false if faded out. |
fade_length | How long, in seconds, will it take for the animation to finish fading in/out. |
void tram::AnimationComponent::SetFrame | ( | name_t | animation_name, |
float | frame | ||
) |
Sets an animation to a specific frame.
If the animation is not already started with Play(), then this method will do nothing.
void tram::AnimationComponent::SetKeyframe | ( | name_t | bone_name, |
const Render::Keyframe & | keyframe | ||
) |
Sets procedural animation keyframe.
|
inline |
|
inline |
|
inline |
void tram::AnimationComponent::SetPause | ( | name_t | animation_name, |
bool | pause | ||
) |
Sets animation's pause state.
This will do nothing, if the animation is not playing. Pausing an already paused or continuing an already playing animation will do nothing.
animation_name | Name of the animation to pause. |
pause | Set to true to pause the animation, set to false to continue. |
void tram::AnimationComponent::SetRepeats | ( | name_t | animation_name, |
uint32_t | repeats | ||
) |
Sets the repeats of an animation.
void tram::AnimationComponent::SetSpeed | ( | name_t | animation_name, |
float | speed | ||
) |
Sets the speed of an animation.
void tram::AnimationComponent::SetWeight | ( | name_t | animation_name, |
float | weight | ||
) |
Sets the weight of an animation.
|
virtual |
Implements tram::EntityComponent.
void tram::AnimationComponent::Stop | ( | name_t | animation_name | ) |
Stops an animation if its playing.
Will do nothing if the animation is not playing.
|
static |
Updates all of the armatures.
This static function calls the Refresh() method on all of the ArmatureComponents.
|
friend |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |