GlistEngine
Loading...
Searching...
No Matches
gModelAnimator.h
Go to the documentation of this file.
1//
2// Created by Metehan Gezer on 10/05/2025.
3//
4
5#ifndef GRAPHICS_GMODELANIMATOR_H
6#define GRAPHICS_GMODELANIMATOR_H
7
8#include "gModel.h"
9
17public:
20
30
38
43 void setModel(gModel* model) {
44 this->model = model;
45 }
46
55 void addAnimation(int id, int startframe, int endframe, float speed, Mode mode, bool isDefault = false);
56
63 void addTransition(TriggerType triggerType, int srcAnimation, int dstAnimation);
64
68 void bake();
69
74 void setGeneralSpeed(float speed) {
75 this->speed = speed;
76 }
77
82 void triggerAnimation(int animationId);
83
84 void update();
85
86
87private:
88 struct TransitionData {
89 int targetanimation;
90 };
91 struct AnimationData {
92 int id;
93 Mode mode;
94 float speed;
95 int startframe;
96 int endframe;
97 std::unordered_map<TriggerType, TransitionData> transitions;
98
99 };
100
101 gModel* model = nullptr;
102 std::unordered_map<int, AnimationData> animations;
103 int defaultanimation = 0;
104 int maxframenum = 0;
105
106 int currentanimation;
107 int nextanimation;
108 float nextframetime = 0;
109 float speed = 1.0f;
110 float currentanimationposition = 0.0f;
111
112private:
113 void prepareAnimation(int animationId);
114};
115
116
117#endif //GRAPHICS_GMODELANIMATOR_H
Handles animation logic for a gModel instance, including switching, playback, and timing.
Definition gModelAnimator.h:16
void addAnimation(int id, int startframe, int endframe, float speed, Mode mode, bool isDefault=false)
Adds a new animation to the animator.
void setGeneralSpeed(float speed)
Sets a global animation speed multiplier.
Definition gModelAnimator.h:74
void bake()
Finalizes the animator setup. Should be called before use and after the animator is fully configured.
void addTransition(TriggerType triggerType, int srcAnimation, int dstAnimation)
Adds a transition to another animation.
void setModel(gModel *model)
Associates a gModel with this animator.
Definition gModelAnimator.h:43
void triggerAnimation(int animationId)
Starts transitioning to a different animation.
TriggerType
Defines triggers for transitioning animations.
Definition gModelAnimator.h:35
@ TRIGGERTYPE_AFTER_COMPLETION
Definition gModelAnimator.h:36
Mode
Defines playback behavior for animations.
Definition gModelAnimator.h:25
@ MODE_HOLD_ON_LAST_FRAME
Definition gModelAnimator.h:26
@ MODE_ONCE
Definition gModelAnimator.h:27
@ MODE_REPEAT
Definition gModelAnimator.h:28
Definition gModel.h:32