Voltray Engine Docs
Loading...
Searching...
No Matches
Transform Class Reference

Represents a 3D transformation with position, rotation, and scale. More...

#include <Transform.h>

Public Member Functions

 Transform ()
 Default constructor - creates identity transform.
 
 Transform (const Vec3 &position)
 Constructor with position.
 
 Transform (const Vec3 &position, const Vec3 &rotation, const Vec3 &scale)
 Constructor with position, rotation, and scale.
 
const Vec3GetPosition () const
 
const Vec3GetRotation () const
 
const Vec3GetScale () const
 
const Vec3GetPivot () const
 
void SetPosition (const Vec3 &position)
 
void SetRotation (const Vec3 &rotation)
 
void SetScale (const Vec3 &scale)
 
void SetScale (float uniformScale)
 
void SetPivot (const Vec3 &pivot)
 
void SetMeshCenter (const Vec3 &meshCenter)
 
void SetRelativePivot (const Vec3 &meshCenter, const Vec3 &relativePivot=Vec3(0.0f, 0.0f, 0.0f))
 Sets the pivot based on mesh bounds, where (0,0,0) represents the mesh center.
 
void Translate (const Vec3 &translation)
 
void Rotate (const Vec3 &rotation)
 
void Scale (const Vec3 &scale)
 
void Scale (float uniformScale)
 
void TranslateLocal (const Vec3 &localTranslation)
 Translates the object along its local axes.
 
void TranslateLocalX (float distance)
 Translates the object along its local X axis.
 
void TranslateLocalY (float distance)
 Translates the object along its local Y axis.
 
void TranslateLocalZ (float distance)
 Translates the object along its local Z axis.
 
Vec3 GetLocalRight () const
 Gets the local X axis (right vector) of the object.
 
Vec3 GetLocalUp () const
 Gets the local Y axis (up vector) of the object.
 
Vec3 GetLocalForward () const
 Gets the local Z axis (forward vector) of the object.
 
Mat4 GetMatrix () const
 Gets the transformation matrix.
 
Mat4 GetInverseMatrix () const
 Gets the inverse transformation matrix.
 
void Reset ()
 Resets transform to identity.
 

Detailed Description

Represents a 3D transformation with position, rotation, and scale.

The Transform class encapsulates 3D transformations including translation, rotation (using Euler angles), and uniform/non-uniform scaling. It provides methods to compute transformation matrices and manipulate the transform.

Constructor & Destructor Documentation

◆ Transform() [1/3]

Transform::Transform ( )

Default constructor - creates identity transform.

◆ Transform() [2/3]

Transform::Transform ( const Vec3 position)

Constructor with position.

Parameters
positionInitial position.

◆ Transform() [3/3]

Transform::Transform ( const Vec3 position,
const Vec3 rotation,
const Vec3 scale 
)

Constructor with position, rotation, and scale.

Parameters
positionInitial position.
rotationInitial rotation in degrees (Euler angles).
scaleInitial scale.

Member Function Documentation

◆ GetInverseMatrix()

Mat4 Transform::GetInverseMatrix ( ) const

Gets the inverse transformation matrix.

Returns
The inverse transformation matrix.

◆ GetLocalForward()

Vec3 Transform::GetLocalForward ( ) const

Gets the local Z axis (forward vector) of the object.

Returns
Normalized vector representing the object's local Z axis.

◆ GetLocalRight()

Vec3 Transform::GetLocalRight ( ) const

Gets the local X axis (right vector) of the object.

Returns
Normalized vector representing the object's local X axis.

◆ GetLocalUp()

Vec3 Transform::GetLocalUp ( ) const

Gets the local Y axis (up vector) of the object.

Returns
Normalized vector representing the object's local Y axis.

◆ GetMatrix()

Mat4 Transform::GetMatrix ( ) const

Gets the transformation matrix.

Returns
The 4x4 transformation matrix (Translation * Rotation * Scale).

◆ GetPivot()

const Vec3 & Transform::GetPivot ( ) const
inline

◆ GetPosition()

const Vec3 & Transform::GetPosition ( ) const
inline

◆ GetRotation()

const Vec3 & Transform::GetRotation ( ) const
inline

◆ GetScale()

const Vec3 & Transform::GetScale ( ) const
inline

◆ Reset()

void Transform::Reset ( )

Resets transform to identity.

◆ Rotate()

void Transform::Rotate ( const Vec3 rotation)

◆ Scale() [1/2]

void Transform::Scale ( const Vec3 scale)

◆ Scale() [2/2]

void Transform::Scale ( float  uniformScale)

◆ SetMeshCenter()

void Transform::SetMeshCenter ( const Vec3 meshCenter)

◆ SetPivot()

void Transform::SetPivot ( const Vec3 pivot)

◆ SetPosition()

void Transform::SetPosition ( const Vec3 position)

◆ SetRelativePivot()

void Transform::SetRelativePivot ( const Vec3 meshCenter,
const Vec3 relativePivot = Vec3(0.0f, 0.0f, 0.0f) 
)

Sets the pivot based on mesh bounds, where (0,0,0) represents the mesh center.

Parameters
meshCenterThe center point of the mesh.
relativePivotThe relative pivot offset from center (0,0,0 = center).

◆ SetRotation()

void Transform::SetRotation ( const Vec3 rotation)

◆ SetScale() [1/2]

void Transform::SetScale ( const Vec3 scale)

◆ SetScale() [2/2]

void Transform::SetScale ( float  uniformScale)

◆ Translate()

void Transform::Translate ( const Vec3 translation)

◆ TranslateLocal()

void Transform::TranslateLocal ( const Vec3 localTranslation)

Translates the object along its local axes.

Parameters
localTranslationTranslation vector in local space (relative to object's rotation).

◆ TranslateLocalX()

void Transform::TranslateLocalX ( float  distance)

Translates the object along its local X axis.

Parameters
distanceDistance to move along local X axis.

◆ TranslateLocalY()

void Transform::TranslateLocalY ( float  distance)

Translates the object along its local Y axis.

Parameters
distanceDistance to move along local Y axis.

◆ TranslateLocalZ()

void Transform::TranslateLocalZ ( float  distance)

Translates the object along its local Z axis.

Parameters
distanceDistance to move along local Z axis.

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