Transform Component
The Transform
class is a component in Tsar engine used to manage an object's position, rotation, and scale in 3D space.
Class Declaration
class Transform : public Component
This class inherits from the Component
class and adds functionality related to transformation in 3D space. It uses Reflexion library for reflection.
Public Methods
Translation
-
glm::vec3 GetTranslation()
Returns the current translation (position) of Entity as a
glm::vec3
in World space. -
void SetTranslation(const glm::vec3& translation)
Sets the Entity translation using the provided
glm::vec3
in World space. -
glm::vec3 GetLocalTranslation();
Returns the current translation (position) of Entity as a
glm::vec3
in Local space. That is relative to parent Entity, when there is no parent you get position in World space. -
void SetLocalTranslation(const glm::vec3& localTranslation);
Sets the Entity translation using the provided
glm::vec3
in Local space. That is relative to parent Entity, when there is no parent you set position in World space.
Rotation
-
glm::vec3 GetRotation()
Returns current rotation of the Entity as a
glm::vec3
angles in radians, World space. -
void SetRotation(const glm::vec3& rotation)
Sets the Entity rotation using the provided
glm::vec3
angles in radians, World space. -
glm::vec3 GetLocalRotation();
Returns current rotation of the Entity as a
glm::vec3
angles in radians, Local space. That is relative to parent Entity, when there is no parent you get rotation in World space. -
void SetLocalRotation(const glm::vec3& localRotation);
Sets the Entity rotation using the provided
glm::vec3
angles in radians, Local space. That is relative to parent Entity, when there is no parent you set rotation in World space.
Scale
-
glm::vec3 GetScale()
Returns the current scale of Entity as a
glm::vec3
in World space. -
void SetScale(const glm::vec3& scale)
Sets the Entity scale using the provided
glm::vec3
in World space. -
glm::vec3 GetLocalScale();
Returns the current scale of Entity as a
glm::vec3
. That is relative to parent Entity, when there is no parent you get scale in World space. -
void SetLocalScale(const glm::vec3& localScale);
Sets the Entity scale using the provided
glm::vec3
in Local space. That is relative to parent Entity, when there is no parent you set scale in World space.
Properties
The Transform
class exposes properties (that can also be accessed via getter and setter functions). These properties allow users to manipulate the position, rotation, and scale of the object in a more intuitive manner:
-
glm::vec3 Translation
Position of Entity in World.- Get:
GetTranslation()
- Set:
SetTranslation()
- Get:
-
glm::vec3 LocalTranslation
Position or Offset of Entity relative to Parent. When parent is absent, position is relative to World.- Get:
GetLocalTranslation()
- Set:
SetLocalTranslation()
- Get:
-
glm::vec3 Rotation
Rotation of Entity in World. Angles in radians.- Get:
GetRotation()
- Set:
SetRotation()
- Get:
-
glm::vec3 LocalRotation
Rotation of Entity relative to Parent. When parent is absent, rotation is relative to World. Angles in radians- Get:
GetLocalRotation()
- Set:
SetLocalRotation()
- Get:
-
glm::vec3 Scale
Scale of Entity relative to World. Final scale is calculated by multiplying world and local scale. 1 is default.- Get:
GetScale()
- Set:
SetScale()
- Get:
-
glm::vec3 LocalScale
Scale of Entity relative to Parent. When there is no Parent, scale is relative to World. Final scale is calculated by multiplying world and local scale. 1 is default.- Get:
GetLocalScale()
- Set:
SetLocalScale()
- Get: