Tramway SDK
animation.h
Go to the documentation of this file.
1// Tramway Drifting and Dungeon Exploration Simulator SDK Runtime
2
3#ifndef TRAM_SDK_COMPONENTS_ARMATURECOMPONENT_H
4#define TRAM_SDK_COMPONENTS_ARMATURECOMPONENT_H
5
6#include <framework/core.h>
8#include <render/render.h>
9#include <render/model.h>
10
11namespace tram {
12
14public:
15 void Start();
16 void SetModel(Render::Model* model) { this->model = model; }
17 void SetModel(name_t model) { this->model = Render::Model::Find(model); }
18 Render::Model* GetModel() { return model.get(); }
19 Render::Pose* GetPose() { return pose; }
20
21 void SetKeyframe(name_t bone_name, const Render::Keyframe& keyframe);
23
24 void Play(name_t animation_name, uint32_t repeats, float weight, float speed, bool interpolate = true, bool pause_on_last_frame = false);
25 bool IsPlaying(name_t animation_name);
26 void Stop(name_t animation_name);
27 void Pause(name_t animation_name);
28 void Continue(name_t animation_name);
29
30 void SetWeight(name_t animation_name, float weight);
31 void SetSpeed(name_t animation_name, float speed);
32 void SetRepeats(name_t animation_name, uint32_t repeats);
33
34 void FadeIn(name_t animation_name, float length);
35 void FadeOut(name_t animation_name, float length);
36
37 void SetPause(name_t animation_name, bool pause);
38 void SetFade(name_t animation_name, bool fade_in, float fade_length);
39 void SetFrame(name_t animation_name, float frame);
40
41 void Reparent(name_t bone_name, name_t new_parent);
42
43 void Refresh();
44 void EventHandler(Event &event) { return; }
45 static bool IsDebugInfoDraw();
46 static void SetDebugInfoDraw(bool draw);
47 static void Update();
48protected:
49 static const size_t ANIM_COUNT = 8;
51 uint32_t repeats;
52 float weight;
53 float speed;
54 float frame;
58 bool fade_in;
60 bool pause;
64 };
65
66 void FindKeyframePointers(Render::Animation* animation, size_t animation_index);
67
69
70 Render::Pose* pose = nullptr;
72
74
75 const Render::Bone* armature_bones = nullptr;
78
81
84 template <typename> friend class Pool;
85};
86
87}
88
89#endif // TRAM_SDK_COMPONENTS_ARMATURECOMPONENT_H
Plays back Animations.
Definition: animation.h:13
ResourceProxy< Render::Model > model
Definition: animation.h:71
Render::Pose * GetPose()
Definition: animation.h:19
Render::Model * GetModel()
Definition: animation.h:18
bool IsPlaying(name_t animation_name)
Returns true if an animation is playing.
Definition: animation.cpp:244
void Stop(name_t animation_name)
Stops an animation if its playing.
Definition: animation.cpp:153
void SetFade(name_t animation_name, bool fade_in, float fade_length)
Fades in or fades out an animation.
Definition: animation.cpp:263
AnimationPlaybackInfo anim_info[ANIM_COUNT]
Definition: animation.h:80
size_t armature_bone_count
Definition: animation.h:76
void SetKeyframe(name_t bone_name, const Render::Keyframe &keyframe)
Sets procedural animation keyframe.
Definition: animation.cpp:70
int32_t armature_bone_parents[Render::BONE_COUNT]
Definition: animation.h:77
static bool IsDebugInfoDraw()
Checks whether the debug text is drawn.
Definition: animation.cpp:466
void SetWeight(name_t animation_name, float weight)
Sets the weight of an animation.
Definition: animation.cpp:214
static void Update()
Updates all of the armatures.
Definition: animation.cpp:299
void Start()
Definition: animation.cpp:52
void SetPause(name_t animation_name, bool pause)
Sets animation's pause state.
Definition: animation.cpp:177
void Pause(name_t animation_name)
Pauses an animation.
Definition: animation.cpp:191
void SetOnAnimationFinishCallback(void(*callback)(AnimationComponent *, name_t))
Definition: animation.h:22
const Render::Bone * armature_bones
Definition: animation.h:75
void SetModel(Render::Model *model)
Definition: animation.h:16
Render::Pose * pose
Definition: animation.h:70
name_t anim_playing[ANIM_COUNT]
Definition: animation.h:79
void SetFrame(name_t animation_name, float frame)
Sets an animation to a specific frame.
Definition: animation.cpp:306
static void SetDebugInfoDraw(bool draw)
Sets the drawing of debug info.
Definition: animation.cpp:473
void FindKeyframePointers(Render::Animation *animation, size_t animation_index)
Extracts pointers to keyframes from animation data.
Definition: animation.cpp:142
void Reparent(name_t bone_name, name_t new_parent)
Reparents a bone.
Definition: animation.cpp:280
void FadeIn(name_t animation_name, float length)
Fades in an animation.
Definition: animation.cpp:204
void SetRepeats(name_t animation_name, uint32_t repeats)
Sets the repeats of an animation.
Definition: animation.cpp:234
void(* anim_finish_callback)(AnimationComponent *, name_t)
Definition: animation.h:73
~AnimationComponent()
Definition: animation.cpp:45
void SetSpeed(name_t animation_name, float speed)
Sets the speed of an animation.
Definition: animation.cpp:224
void Continue(name_t animation_name)
Continues an animation.
Definition: animation.cpp:198
void EventHandler(Event &event)
Definition: animation.h:44
void SetModel(name_t model)
Definition: animation.h:17
static const size_t ANIM_COUNT
Definition: animation.h:49
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.
Definition: animation.cpp:92
void FadeOut(name_t animation_name, float length)
Fades out an animation.
Definition: animation.cpp:209
AnimationComponent()
Definition: animation.cpp:36
Render::Keyframe base_pose[Render::BONE_COUNT]
Definition: animation.h:68
void Refresh()
Updates an armature.
Definition: animation.cpp:317
Component base class.
Definition: entitycomponent.h:16
Definition: pool.h:21
Skeletal animation for a 3D model.
Definition: animation.h:45
Definition: model.h:27
static Model * Find(name_t name)
Definition: model.cpp:56
Definition: resource.h:46
const size_t BONE_COUNT
Definition: animation.h:17
Serialization, i.e.
UID name_t
Definition: uid.h:43
bool fade_out
Definition: animation.h:59
float fade_speed
Definition: animation.h:55
bool fade_in
Definition: animation.h:58
Render::Keyframe * keyframes[Render::BONE_COUNT]
Definition: animation.h:62
bool pause_on_last_frame
Definition: animation.h:61
float speed
Definition: animation.h:53
uint32_t keyframe_count[Render::BONE_COUNT]
Definition: animation.h:63
bool interpolate
Definition: animation.h:57
bool pause
Definition: animation.h:60
uint32_t repeats
Definition: animation.h:51
float weight
Definition: animation.h:52
float frame
Definition: animation.h:54
float fade_ammount
Definition: animation.h:56
Event data.
Definition: event.h:24
Bone for a 3D models skeleton.
Definition: animation.h:19
Keyframe for a skeletal animation.
Definition: animation.h:27
Definition: animation.h:35
Interned string type.
Definition: uid.h:10