CSEngine
Loading...
Searching...
No Matches
AnimatorComponent.h
1#pragma once
2
3#include "../SComponent.h"
4#include "../DrawableSkinnedMeshComponent.h"
5#include "../../Util/Animation/AnimationUtil.h"
6#include "../../Util/Animation/Animation.h"
7
8namespace CSE {
9
11 public:
12 COMPONENT_DEFINE_CONSTRUCTOR(AnimatorComponent);
13
14 ~AnimatorComponent() override;
15
16 void Init() override;
17
18 void Tick(float elapsedTime) override;
19
20 void Exterminate() override;
21
22 SComponent* Clone(SGameObject* object) override;
23
24 void CopyReference(SComponent* src, std::map<SGameObject*, SGameObject*> lists_obj,
25 std::map<SComponent*, SComponent*> lists_comp) override;
26
27 void SetValue(std::string name_str, Arguments value) override;
28
29 std::string PrintValue() const override;
30
31 void SetRootJoint(JointComponent* mesh);
32 // void SetAnimation(Animation* animation);
33
34 void PlayAnimation(Animation* animation);
35
36
37 private:
38 void UpdateAnimationTime(float elapsedTime);
39
40 std::vector<mat4> calculateCurrentAnimationPose() const;
41
42 static void applyPoseToJoints(std::vector<mat4>& currentPose, JointComponent* joint, const mat4& parentTransform);
43
44 std::vector<KeyFrame*> getPreviousAndNextFrames() const;
45
46 float CalculateProgression(KeyFrame* previous, KeyFrame* next) const;
47
48 static std::vector<mat4> InterpolatePoses(KeyFrame* previousFrame, KeyFrame* nextFrame, float t);
49
50 private:
51
52 float m_animationTime = -1;
53 float m_startTime = -1;
54
55 JointComponent* m_rootJoint = nullptr;
56 Animation* m_currentAnimation = nullptr;
57 //차후 애니메이션 컨트롤러도 제작
58
59 };
60
61}