SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::TransformComponent Class Reference

Represents the position, rotation, and scale of an entity in 3D space. More...

#include <TransformComponent.hpp>

Inheritance diagram for Sleak::TransformComponent:

Classes

struct  TransformMatrix
 Cached translation/rotation/scale matrices combined into the final transform matrix. More...

Public Member Functions

 TransformComponent (GameObject *object, const Vector3D &position)
 TransformComponent (GameObject *object, const Vector3D &position, const Quaternion &rotation)
 TransformComponent (GameObject *object, const Vector3D &position, const Quaternion &rotation, const Vector3D &scale)
 ~TransformComponent () override
Vector3D Forward () const
Matrix4 GetTransformMatrix ()
Vector3D GetWorldPosition () const
Quaternion GetWorldRotation () const
Vector3D GetWorldScale () const
bool Initialize () override
 Allocates the transform's GPU constant buffer.
void LookAt (const Vector3D &target)
 Orients the transform to face target, using world up as reference.
Vector3D Right () const
void Rotate (const Quaternion &rotation)
 Composes rotation onto the current orientation.
void RotateAround (const Vector3D &axis, float angle)
 Rotates by angle around axis in world space.
void RotateAroundLocal (const Vector3D &axis, float angle)
 Rotates by angle around axis expressed in the object's local space.
void Scale (const Vector3D &scale)
 Multiplies the current scale componentwise by scale.
void Scale (float amount)
 Uniformly scales by amount along all axes.
void SetPosition (const Vector3D &position)
void SetRotation (const Quaternion &rotation)
void SetScale (const Vector3D &scale)
void Translate (const Vector3D &translation)
 Adds translation to position and refreshes the cached matrix.
void Translate (float x, float y, float z)
Vector3D Up () const
void Update (float DeltaTime) override
 Refreshes and rebinds the transform constant buffer for this frame.
Public Member Functions inherited from Sleak::Component
 Component (GameObject *object)
virtual ~Component ()=default
virtual void FixedUpdate (float fixedDeltaTime)
GameObjectGetOwner ()
virtual void LateUpdate (float deltaTime)
virtual void OnDestroy ()
 Called when the component is detached or the owner is destroyed.
virtual void OnDisable ()
virtual void OnEnable ()
Public Member Functions inherited from Sleak::Object
 Object (const std::string &name="Object")
virtual ~Object ()=default
const std::string & GetName () const
uint64_t GetUniqueID () const
void SetName (const std::string &value)

Protected Attributes

Vector3D position = Vector3D(0.0f, 0.0f, 0.0f)
Quaternion rotation = Quaternion()
Vector3D scale = Vector3D(1.0f, 1.0f, 1.0f)
TransformMatrixTransform
Protected Attributes inherited from Sleak::Component
bool bIsInitialized
GameObjectowner

Detailed Description

Represents the position, rotation, and scale of an entity in 3D space.

This component is essential for positioning and orienting entities within the game world. It provides functionalities for setting and retrieving the transform properties, as well as calculating transformation matrices for rendering and physics calculations.

Definition at line 26 of file TransformComponent.hpp.

Constructor & Destructor Documentation

◆ TransformComponent() [1/3]

Sleak::TransformComponent::TransformComponent ( GameObject * object,
const Vector3D & position )

Definition at line 12 of file TransformComponent.cpp.

◆ TransformComponent() [2/3]

Sleak::TransformComponent::TransformComponent ( GameObject * object,
const Vector3D & position,
const Quaternion & rotation )

Definition at line 14 of file TransformComponent.cpp.

◆ TransformComponent() [3/3]

Sleak::TransformComponent::TransformComponent ( GameObject * object,
const Vector3D & position,
const Quaternion & rotation,
const Vector3D & scale )

Definition at line 19 of file TransformComponent.cpp.

◆ ~TransformComponent()

Sleak::TransformComponent::~TransformComponent ( )
override

Definition at line 29 of file TransformComponent.cpp.

Member Function Documentation

◆ Forward()

Vector3D Sleak::TransformComponent::Forward ( ) const

Definition at line 101 of file TransformComponent.cpp.

◆ GetTransformMatrix()

Matrix4 Sleak::TransformComponent::GetTransformMatrix ( )

Definition at line 57 of file TransformComponent.cpp.

◆ GetWorldPosition()

Vector3D Sleak::TransformComponent::GetWorldPosition ( ) const

Definition at line 129 of file TransformComponent.cpp.

◆ GetWorldRotation()

Quaternion Sleak::TransformComponent::GetWorldRotation ( ) const

Definition at line 133 of file TransformComponent.cpp.

◆ GetWorldScale()

Vector3D Sleak::TransformComponent::GetWorldScale ( ) const

Definition at line 137 of file TransformComponent.cpp.

◆ Initialize()

bool Sleak::TransformComponent::Initialize ( )
overridevirtual

Allocates the transform's GPU constant buffer.

Implements Sleak::Component.

Definition at line 34 of file TransformComponent.cpp.

◆ LookAt()

void Sleak::TransformComponent::LookAt ( const Vector3D & target)

Orients the transform to face target, using world up as reference.

Definition at line 122 of file TransformComponent.cpp.

◆ Right()

Vector3D Sleak::TransformComponent::Right ( ) const

Definition at line 105 of file TransformComponent.cpp.

◆ Rotate()

void Sleak::TransformComponent::Rotate ( const Quaternion & rotation)

Composes rotation onto the current orientation.

Definition at line 73 of file TransformComponent.cpp.

◆ RotateAround()

void Sleak::TransformComponent::RotateAround ( const Vector3D & axis,
float angle )

Rotates by angle around axis in world space.

Definition at line 114 of file TransformComponent.cpp.

◆ RotateAroundLocal()

void Sleak::TransformComponent::RotateAroundLocal ( const Vector3D & axis,
float angle )

Rotates by angle around axis expressed in the object's local space.

Definition at line 118 of file TransformComponent.cpp.

◆ Scale() [1/2]

void Sleak::TransformComponent::Scale ( const Vector3D & scale)

Multiplies the current scale componentwise by scale.

Definition at line 82 of file TransformComponent.cpp.

◆ Scale() [2/2]

void Sleak::TransformComponent::Scale ( float amount)

Uniformly scales by amount along all axes.

Definition at line 78 of file TransformComponent.cpp.

◆ SetPosition()

void Sleak::TransformComponent::SetPosition ( const Vector3D & position)

Definition at line 88 of file TransformComponent.cpp.

◆ SetRotation()

void Sleak::TransformComponent::SetRotation ( const Quaternion & rotation)

Definition at line 92 of file TransformComponent.cpp.

◆ SetScale()

void Sleak::TransformComponent::SetScale ( const Vector3D & scale)

Definition at line 96 of file TransformComponent.cpp.

◆ Translate() [1/2]

void Sleak::TransformComponent::Translate ( const Vector3D & translation)

Adds translation to position and refreshes the cached matrix.

Definition at line 62 of file TransformComponent.cpp.

◆ Translate() [2/2]

void Sleak::TransformComponent::Translate ( float x,
float y,
float z )

Definition at line 69 of file TransformComponent.cpp.

◆ Up()

Vector3D Sleak::TransformComponent::Up ( ) const

Definition at line 109 of file TransformComponent.cpp.

◆ Update()

void Sleak::TransformComponent::Update ( float DeltaTime)
overridevirtual

Refreshes and rebinds the transform constant buffer for this frame.

Implements Sleak::Component.

Definition at line 50 of file TransformComponent.cpp.

Member Data Documentation

◆ position

Vector3D Sleak::TransformComponent::position = Vector3D(0.0f, 0.0f, 0.0f)
protected

Definition at line 94 of file TransformComponent.hpp.

◆ rotation

Quaternion Sleak::TransformComponent::rotation = Quaternion()
protected

Definition at line 95 of file TransformComponent.hpp.

◆ scale

Vector3D Sleak::TransformComponent::scale = Vector3D(1.0f, 1.0f, 1.0f)
protected

Definition at line 96 of file TransformComponent.hpp.

◆ Transform

TransformMatrix* Sleak::TransformComponent::Transform
protected

Definition at line 97 of file TransformComponent.hpp.