The Joe Engine
Joe's engine programming playground
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
JoeEngine::TransformComponent Class Reference

The Transform Component class. More...

#include <TransformComponent.h>

Public Member Functions

 TransformComponent ()
 Default constructor. More...
 
 ~TransformComponent ()=default
 Destructor (default). More...
 
void RecomputeTransform ()
 Recompute cached transform. More...
 
const glm::mat4 & GetTransform () const
 Get cached transform. More...
 
const glm::vec3 & GetTranslation () const
 Get translation. More...
 
const glm::quat & GetRotation () const
 Get rotation. More...
 
const glm::vec3 & GetScale () const
 Get scale. More...
 
void SetTranslation (const glm::vec3 &newTranslation)
 Set translation. More...
 
void SetRotation (const glm::quat &newRotation)
 Set rotation. More...
 
void SetRotation (const float angle, const glm::vec3 &axis)
 Set rotation. More...
 
void SetScale (const glm::vec3 &newScale)
 Set scale. More...
 
void SetTransform (const glm::mat4 &newTransform)
 Set cached transform. More...
 

Detailed Description

The Transform Component class.

Contains the necessary transformation info to be attached to a particular entity. This consists of one each of a translation, rotation, and scale. A cached transform matrix is also stored to prevent excessively computing the overall transformation matrix from the stored translation, rotation, and scale data.

See also
JETransformComponentManager, JEVulkanRenderer

Constructor & Destructor Documentation

◆ TransformComponent()

JoeEngine::TransformComponent::TransformComponent ( )
inline

Default constructor.

Initializes all members to an appropriate transformation. Translation - 0, 0, 0 Rotation - 0 Scale - 1, 1, 1 Cached transform - identity matrix

◆ ~TransformComponent()

JoeEngine::TransformComponent::~TransformComponent ( )
default

Destructor (default).

Member Function Documentation

◆ GetRotation()

const glm::quat& JoeEngine::TransformComponent::GetRotation ( ) const
inline

Get rotation.

Returns the rotation data of this component.

Returns
the rotation data

◆ GetScale()

const glm::vec3& JoeEngine::TransformComponent::GetScale ( ) const
inline

Get scale.

Returns the scale data of this component.

Returns
the scale data

◆ GetTransform()

const glm::mat4& JoeEngine::TransformComponent::GetTransform ( ) const
inline

Get cached transform.

Returns the overall (cached) transform of this component.

Returns
the cached transform

◆ GetTranslation()

const glm::vec3& JoeEngine::TransformComponent::GetTranslation ( ) const
inline

Get translation.

Returns the translation data of this component.

Returns
the translation data

◆ RecomputeTransform()

void JoeEngine::TransformComponent::RecomputeTransform ( )
inline

Recompute cached transform.

Updates the cached transform to reflect the stored translation, rotation, and scale data. If the cached transform has any changes (e.g. via SetTransform()) that are not reflected in the stored translation, rotation, and scale data, they will be lost. This function is automatically called from SetTranslation(), SetRotation(), and SetScale().

See also
SetTranslation(), SetRotation, SetScale(), SetTransform()

◆ SetRotation() [1/2]

void JoeEngine::TransformComponent::SetRotation ( const float  angle,
const glm::vec3 &  axis 
)
inline

Set rotation.

Sets the rotation data of this component to the specified rotation angle and axis. Automatically calls RecomputeTransform().

Parameters
anglethe new rotation angle
axisthe new rotation axis
See also
RecomputeTransform()

◆ SetRotation() [2/2]

void JoeEngine::TransformComponent::SetRotation ( const glm::quat &  newRotation)
inline

Set rotation.

Sets the rotation data of this component to the specified rotation quaternion. Automatically calls RecomputeTransform().

Parameters
newRotationthe new rotation quaternion data
See also
RecomputeTransform()

◆ SetScale()

void JoeEngine::TransformComponent::SetScale ( const glm::vec3 &  newScale)
inline

Set scale.

Sets the scale data of this component to the specified scale vector. Automatically calls RecomputeTransform().

Parameters
newScalethe new scale data
See also
RecomputeTransform()

◆ SetTransform()

void JoeEngine::TransformComponent::SetTransform ( const glm::mat4 &  newTransform)
inline

Set cached transform.

Sets the overall (cached) transform data of this component to the specified transformation matrix. Does NOT automatically call RecomputeTransform(). Changes made to the overall transformation via this function will stick until RecomputeTransform() is called.

Parameters
newTransformthe new transformation data
See also
RecomputeTransform()

◆ SetTranslation()

void JoeEngine::TransformComponent::SetTranslation ( const glm::vec3 &  newTranslation)
inline

Set translation.

Sets the translation data of this component to the specified translation vector. Automatically calls RecomputeTransform().

Parameters
newTranslationthe new translation data
See also
RecomputeTransform()

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