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

Public Member Functions

 COMPONENT_DEFINE_CONSTRUCTOR (TransformComponent)
 
void Init () override
 
void Tick (float elapsedTime) override
 
void Exterminate () override
 
SComponentClone (SGameObject *object) override
 
mat4 GetMatrix () const
 
vec3GetPosition ()
 
vec3 GetScale () const
 
Quaternion GetRotation () const
 
void SetMatrix (const mat4 &matrix)
 
void SetValue (std::string name_str, Arguments value) override
 
std::string PrintValue () const override
 
- Public Member Functions inherited from CSE::SComponent
 SComponent (std::string classType, SGameObject *gameObject)
 
 SComponent (const SComponent &src)
 
void Start () override
 
virtual void CopyReference (SComponent *src, std::map< SGameObject *, SGameObject * > lists_obj, std::map< SComponent *, SComponent * > lists_comp)
 
virtual auto GetComponent () -> SObject *
 
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

- Public Attributes inherited from CSE::TransformInterface
vec3 m_position
 
Quaternion m_rotation
 
vec3 m_scale
 
- 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 TransformComponent.h.

Member Function Documentation

◆ Clone()

SComponent * TransformComponent::Clone ( SGameObject object)
overridevirtual

Reimplemented from CSE::SComponent.

Definition at line 79 of file TransformComponent.cpp.

79 {
80 INIT_COMPONENT_CLONE(TransformComponent, clone);
81
82 clone->m_position = vec3(m_position);
83 clone->m_scale = vec3(m_scale);
84 clone->m_rotation = Quaternion(m_rotation);
85
86 return clone;
87}

◆ Exterminate()

void TransformComponent::Exterminate ( )
overridevirtual

Implements CSE::SObject.

Definition at line 28 of file TransformComponent.cpp.

28 {
29}

◆ GetMatrix()

mat4 TransformComponent::GetMatrix ( ) const

Definition at line 31 of file TransformComponent.cpp.

31 {
32 return m_f_matrix;
33}

◆ GetPosition()

vec3 * TransformComponent::GetPosition ( )

Definition at line 35 of file TransformComponent.cpp.

35 {
36 return &m_f_position;
37}

◆ GetRotation()

Quaternion TransformComponent::GetRotation ( ) const

Definition at line 43 of file TransformComponent.cpp.

43 {
44
45 Quaternion parent = Quaternion();
46 if (gameObject->GetParent() != nullptr) {
47 parent = static_cast<TransformComponent*>(gameObject->GetParent()->GetTransform())->GetRotation();
48 }
49
50
51 return m_rotation.Multiplied(parent);
52}

◆ GetScale()

vec3 TransformComponent::GetScale ( ) const

Definition at line 39 of file TransformComponent.cpp.

39 {
40 return m_f_scale;
41}

◆ Init()

void TransformComponent::Init ( )
overridevirtual

Implements CSE::SISComponent.

Definition at line 15 of file TransformComponent.cpp.

15 {
16}

◆ PrintValue()

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

Reimplemented from CSE::SComponent.

Definition at line 99 of file TransformComponent.cpp.

99 {
100 PRINT_START("component");
101
102 PRINT_VALUE(m_position, m_position.x, ' ', m_position.y, ' ', m_position.z);
103 PRINT_VALUE(m_scale, m_scale.x, ' ', m_scale.y, ' ', m_scale.z);
104 PRINT_VALUE(m_rotation, m_rotation.x, ' ', m_rotation.y, ' ', m_rotation.z, ' ', m_rotation.w);
105
106 PRINT_END("component");
107}

◆ SetMatrix()

void TransformComponent::SetMatrix ( const mat4 matrix)

Definition at line 54 of file TransformComponent.cpp.

54 {
55 m_position = vec3{ matrix.w.x, matrix.w.y, matrix.w.z };
56 m_scale = vec3{ matrix.x.x, matrix.y.y, matrix.z.z };
57 m_rotation = Quaternion::ToQuaternion(matrix);
58
59}

◆ SetValue()

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

Reimplemented from CSE::SComponent.

Definition at line 89 of file TransformComponent.cpp.

89 {
90 if (name_str == "m_position") {
91 m_position = vec3(std::stof(value[0]), std::stof(value[1]), std::stof(value[2]));
92 } else if (name_str == "m_scale") {
93 m_scale = vec3(std::stof(value[0]), std::stof(value[1]), std::stof(value[2]));
94 } else if (name_str == "m_rotation") {
95 m_rotation = Quaternion(std::stof(value[0]), std::stof(value[1]), std::stof(value[2]), std::stof(value[3]));
96 }
97}

◆ Tick()

void TransformComponent::Tick ( float  elapsedTime)
overridevirtual

Implements CSE::SISComponent.

Definition at line 19 of file TransformComponent.cpp.

19 {
20
21 m_f_matrix = GetFinalMatrix();
22 m_f_position = vec3{ m_f_matrix.w.x, m_f_matrix.w.y, m_f_matrix.w.z };
23 m_f_scale = vec3{ m_f_matrix.x.x, m_f_matrix.y.y, m_f_matrix.z.z };
24
25}

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