Claire's Game Engine
Full C++ Engine using OpenGL
Loading...
Searching...
No Matches
Transform Class Reference

Transform is a component that defines the position, rotation, and scale of an actor in 3D space. It provides direction vectors, transformation matrix computation, and rotation utility functions. More...

#include <Transform.h>

Inheritance diagram for Transform:
Component

Public Member Functions

 Transform (Actor *pOwner, Vector3 pPosition=Vector3::Zero, Vector3 pScale=Vector3::One, Quaternion pRotation=Quaternion::Identity)
 Constructor for Transform.
 
Vector3 Right () const
 Returns the right direction vector of the object (transformed by its current rotation).
 
Vector3 Up () const
 Returns the up direction vector of the object (transformed by its current rotation).
 
Vector3 Forward () const
 Returns the forward direction vector of the object (transformed by its current rotation).
 
void ComputeWorldTransform ()
 Computes the world transformation matrix (position, rotation, scale). This is used to update the object's global transformation matrix.
 
const Matrix4GetWorldTransform () const
 Gets the world transformation matrix for this transform.
 
void LookAt (Vector3 target)
 Makes the object rotate to face a given target position.
 
void RotatePitch (float degrees)
 Rotates the object around the pitch axis (X-axis).
 
void RotateYaw (float degrees)
 Rotates the object around the yaw axis (Y-axis).
 
void RotateRoll (float degrees)
 Rotates the object around the roll axis (Z-axis).
 
- Public Member Functions inherited from Component
 Component (Actor *pOwner, int pUpdateOrder=100)
 Constructor for Component.
 
virtual ~Component ()
 
virtual void OnStart ()
 Called when the component is initialized (during actor start). This can be used to perform any setup operations for the component.
 
virtual void Update ()
 Called every frame to update the component. This can be used to perform actions that need to be updated periodically.
 
virtual void OnEnd ()
 Called when the component is about to be destroyed (during actor destruction). This can be used to clean up or release any resources.
 
virtual void OnUpdateWorldTrandform ()
 Called when the world transform of the actor is updated. This allows the component to react to changes in the actor's world transform.
 
void SetActive (bool isActive)
 Sets the active status of the component.
 
void SetOwner (Actor *pOwner)
 Sets the actor that owns this component.
 
int GetUpdateOrder () const
 Returns the update order of the component. Components with lower update orders are updated first.
 
ActorGetOwner () const
 Returns the actor that owns this component.
 

Public Attributes

Vector3 mPosition = Vector3::Zero
 Position of the object in 3D space.
 
Vector3 mScale = Vector3::One
 Scale of the object in 3D space.
 
Quaternion mRotation = Quaternion::Identity
 Rotation of the object (in quaternion form)
 

Additional Inherited Members

- Protected Attributes inherited from Component
ActormOwner = nullptr
 The actor that owns this component.
 

Detailed Description

Transform is a component that defines the position, rotation, and scale of an actor in 3D space. It provides direction vectors, transformation matrix computation, and rotation utility functions.

Constructor & Destructor Documentation

◆ Transform()

Transform::Transform ( Actor * pOwner,
Vector3 pPosition = Vector3::Zero,
Vector3 pScale = Vector3::One,
Quaternion pRotation = Quaternion::Identity )

Constructor for Transform.

Parameters
pOwnerThe actor that owns this transform component.
pPositionThe initial position of the actor in 3D space (default: Vector3::Zero).
pScaleThe initial scale of the actor (default: Vector3::One).
pRotationThe initial rotation of the actor (default: Quaternion::Identity).

Member Function Documentation

◆ ComputeWorldTransform()

void Transform::ComputeWorldTransform ( )

Computes the world transformation matrix (position, rotation, scale). This is used to update the object's global transformation matrix.

◆ Forward()

Vector3 Transform::Forward ( ) const
inline

Returns the forward direction vector of the object (transformed by its current rotation).

Returns
Vector representing the forward direction in the world space.

◆ GetWorldTransform()

const Matrix4 & Transform::GetWorldTransform ( ) const

Gets the world transformation matrix for this transform.

Returns
Reference to the world transformation matrix.

◆ LookAt()

void Transform::LookAt ( Vector3 target)

Makes the object rotate to face a given target position.

Parameters
targetThe position to look at.

◆ Right()

Vector3 Transform::Right ( ) const
inline

Returns the right direction vector of the object (transformed by its current rotation).

Returns
Vector representing the right direction in the world space.

◆ RotatePitch()

void Transform::RotatePitch ( float degrees)

Rotates the object around the pitch axis (X-axis).

Parameters
Thenumber of degrees to rotate around the pitch axis.

◆ RotateRoll()

void Transform::RotateRoll ( float degrees)

Rotates the object around the roll axis (Z-axis).

Parameters
Thenumber of degrees to rotate around the roll axis.

◆ RotateYaw()

void Transform::RotateYaw ( float degrees)

Rotates the object around the yaw axis (Y-axis).

Parameters
Thenumber of degrees to rotate around the yaw axis.

◆ Up()

Vector3 Transform::Up ( ) const
inline

Returns the up direction vector of the object (transformed by its current rotation).

Returns
Vector representing the up direction in the world space.

Member Data Documentation

◆ mPosition

Vector3 Transform::mPosition = Vector3::Zero

Position of the object in 3D space.

◆ mRotation

Quaternion Transform::mRotation = Quaternion::Identity

Rotation of the object (in quaternion form)

◆ mScale

Vector3 Transform::mScale = Vector3::One

Scale of the object in 3D space.


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