CSEngine
Loading...
Searching...
No Matches
CSE::AnimatorComponent Class Reference
Inheritance diagram for CSE::AnimatorComponent:
CSE::SComponent CSE::SObject CSE::SISComponent CSE::VariableBinder

Public Member Functions

 COMPONENT_DEFINE_CONSTRUCTOR (AnimatorComponent)
 
void Init () override
 
void Tick (float elapsedTime) override
 
void Exterminate () override
 
SComponentClone (SGameObject *object) override
 
void CopyReference (SComponent *src, std::map< SGameObject *, SGameObject * > lists_obj, std::map< SComponent *, SComponent * > lists_comp) override
 
void SetValue (std::string name_str, Arguments value) override
 
std::string PrintValue () const override
 
void SetRootJoint (JointComponent *mesh)
 
void PlayAnimation (Animation *animation)
 
- Public Member Functions inherited from CSE::SComponent
 SComponent (std::string classType, SGameObject *gameObject)
 
 SComponent (const SComponent &src)
 
void Start () override
 
virtual auto GetComponent () -> SObject *
 
void SetValue (std::string name_str, Arguments value) override
 
std::string PrintValue () const override
 
void SetGameObject (SGameObject *object)
 
virtual SGameObjectGetGameObject () const
 
virtual bool GetIsEnable () const
 
virtual void SetIsEnable (bool is_enable)
 
std::string GetClassType () const
 
void SetClassType (std::string type)
 
- Public Member Functions inherited from CSE::SObject
 SObject (bool isRegister)
 
virtual void SetUndestroyable (bool enable)
 
virtual void Destroy ()
 
virtual void __FORCE_DESTROY__ ()
 
virtual std::string GenerateMeta ()
 
std::string GetHash () const
 
virtual void SetHash (std::string &hash)
 
- Public Member Functions inherited from CSE::SISComponent
 SISComponent (const SISComponent &src)=default
 

Additional Inherited Members

- Protected Types inherited from CSE::VariableBinder
typedef std::vector< std::string > Arguments
 
- Protected Attributes inherited from CSE::SComponent
SGameObjectgameObject = nullptr
 
bool isEnable = true
 
std::string m_classType
 
- Protected Attributes inherited from CSE::SObject
std::string m_hash
 

Detailed Description

Definition at line 10 of file AnimatorComponent.h.

Member Function Documentation

◆ Clone()

SComponent * AnimatorComponent::Clone ( SGameObject object)
overridevirtual

Reimplemented from CSE::SComponent.

Definition at line 124 of file AnimatorComponent.cpp.

124 {
125 INIT_COMPONENT_CLONE(AnimatorComponent, clone);
126
127 clone->m_animationTime = m_animationTime;
128 clone->m_startTime = m_startTime;
129 clone->m_currentAnimation = m_currentAnimation;
130
131 return clone;
132}

◆ CopyReference()

void AnimatorComponent::CopyReference ( SComponent src,
std::map< SGameObject *, SGameObject * >  lists_obj,
std::map< SComponent *, SComponent * >  lists_comp 
)
overridevirtual

Reimplemented from CSE::SComponent.

Definition at line 134 of file AnimatorComponent.cpp.

135 {
136 if (src == nullptr) return;
137 auto convert = static_cast<AnimatorComponent*>(src);
138
139 //Copy Components
140 FIND_COMP_REFERENCE(m_rootJoint, convert, JointComponent);
141
142}

◆ Exterminate()

void AnimatorComponent::Exterminate ( )
overridevirtual

Implements CSE::SObject.

Definition at line 31 of file AnimatorComponent.cpp.

31 {
32}

◆ Init()

void AnimatorComponent::Init ( )
overridevirtual

Implements CSE::SISComponent.

Definition at line 13 of file AnimatorComponent.cpp.

13 {
14}

◆ PlayAnimation()

void AnimatorComponent::PlayAnimation ( Animation animation)

Definition at line 42 of file AnimatorComponent.cpp.

42 {
43 m_currentAnimation = animation;
44 m_animationTime = m_startTime = 0;
45}

◆ PrintValue()

std::string AnimatorComponent::PrintValue ( ) const
overridevirtual

Implements CSE::VariableBinder.

Definition at line 156 of file AnimatorComponent.cpp.

156 {
157
158 PRINT_START("component");
159
160 PRINT_VALUE(m_animationTime, m_animationTime);
161 PRINT_VALUE(m_startTime, m_startTime);
162 PRINT_VALUE(m_currentAnimation, ConvertSpaceStr(m_currentAnimation->GetHash()));
163 PRINT_VALUE_SPREFAB_REF(m_rootJoint);
164
165
166 PRINT_END("component");
167}

◆ SetRootJoint()

void AnimatorComponent::SetRootJoint ( JointComponent mesh)

Definition at line 34 of file AnimatorComponent.cpp.

34 {
35 m_rootJoint = mesh;
36}

◆ SetValue()

void AnimatorComponent::SetValue ( std::string  name_str,
Arguments  value 
)
overridevirtual

Implements CSE::VariableBinder.

Definition at line 144 of file AnimatorComponent.cpp.

144 {
145 if (name_str == "m_animationTime") {
146 m_animationTime = std::stof(value[0]);
147 } else if (name_str == "m_startTime") {
148 m_startTime = std::stof(value[0]);
149 } else if (name_str == "m_currentAnimation") {
150 m_currentAnimation = SResource::Create<Animation>(value[0]);
151 } else if (name_str == "m_rootJoint") {
152 SET_SPREFAB_REF(m_rootJoint, JointComponent);
153 }
154}

◆ Tick()

void AnimatorComponent::Tick ( float  elapsedTime)
overridevirtual

Implements CSE::SISComponent.

Definition at line 17 of file AnimatorComponent.cpp.

17 {
18 if (m_currentAnimation == nullptr) return;
19
20 if (m_startTime == 0) {
21 m_startTime = elapsedTime;
22 }
23 UpdateAnimationTime(elapsedTime);
24
25 std::vector<mat4> currentPose = calculateCurrentAnimationPose();
26 applyPoseToJoints(currentPose, m_rootJoint, mat4::Identity());
27
28}

The documentation for this class was generated from the following files: