VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
vex::TransformComponent Struct Reference

Struct containing transform data and methods. More...

#include <BasicComponents.hpp>

Public Member Functions

 TransformComponent (const TransformComponent &other)
 Copy Constructor. Copies all data members and maintains the reference to the same registry.
TransformComponentoperator= (const TransformComponent &other)
 Copy Assignment Operator. Copies all data members and maintains the reference to the same registry.
 TransformComponent (vex::Registry &registry)
 Constructor 1: Registry only.
 TransformComponent (vex::Registry &registry, glm::vec3 pos, vex::Entity p=vex::NULL_ENTITY)
 Constructor 2: Registry, Position, (optional Parent).
 TransformComponent (vex::Registry &registry, glm::vec3 pos, glm::vec3 rot, vex::Entity p=vex::NULL_ENTITY)
 Constructor 3: Registry, Position, Rotation (Euler degrees), (optional Parent).
 TransformComponent (vex::Registry &registry, glm::vec3 pos, glm::vec3 rot, glm::vec3 s, vex::Entity p=vex::NULL_ENTITY)
 Constructor 4: Registry, Position, Rotation (Euler degrees), Scale, (optional Parent).
 TransformComponent (vex::Registry &registry, vex::Entity p)
 Constructor 5: Registry, Parent only (useful for empty child objects).
 TransformComponent ()=default
 Default constructor is deleted since registry is required.
bool isDirty ()
void setRegistry (vex::Registry &reg)
bool isReady () const
void setParent (vex::Entity newParent)
 Set the parent entity.
vex::Entity getParent () const
 Get the parent entity.
glm::vec3 getLocalPosition () const
 Get the local position.
glm::vec3 getLocalRotation () const
 Get the local rotation (as Euler angles in degrees).
glm::vec3 getLocalScale () const
 Get the local scale.
void setLocalPosition (glm::vec3 newPosition)
 Set the local position.
void setLocalRotation (glm::vec3 newRotation)
 Set the local rotation (using Euler angles in degrees).
void setLocalScale (glm::vec3 newScale)
 Set the local scale.
glm::quat getWorldQuaternion () const
 Method to get the world rotation as a quaternion.
void setWorldQuaternion (glm::quat targetWorldQuat)
 Method to set world rotation using a quaternion (for physics systems).
void setWorldQuaternionPhys (glm::quat targetWorldQuat)
 Method to set world rotation using a quaternion (for physics systems).
glm::quat getLocalQuaternion () const
 Get the local rotation as a quaternion directly.
void setLocalQuaternion (glm::quat newRotation)
 Set the local rotation using a quaternion directly.
void addLocalQuaternion (glm::quat deltaRotation)
 Multiply a delta quaternion into the current local rotation.
glm::mat4 recalculateMatrix ()
glm::mat4 matrix (bool forceRecalculate=false)
 Method used by renderer to calculate the transformation matrix.
glm::vec3 getWorldPosition ()
 Method to get world position, needed when object is parented as position parameter stores local position.
glm::vec3 getWorldRotation ()
 Method to get world rotation, needed when object is parented as rotation parameter stores local rotation.
glm::vec3 getWorldScale ()
 Method to get world scale, needed when object is parented as scale parameter stores local scale.
void setWorldPosition (glm::vec3 newPosition)
 Method to set world position, needed when object is parented as position parameter stores local position.
void setWorldPositionPhys (glm::vec3 newPosition)
 Method to set world position by physics component.
void setWorldRotation (glm::vec3 newRotation)
 Method to set world rotation, needed when object is parented as rotation parameter stores local rotation.
void setWorldScale (glm::vec3 newScale)
 Method to set world scale, needed when object is parented as rotation parameter stores local rotation.
void addLocalPosition (glm::vec3 newPosition)
 Method to add local position.
void addLocalRotation (glm::vec3 newRotation)
 Method to add local rotation (Euler angles in degrees).
void addLocalScale (glm::vec3 newScale)
 Method to add local scale.
void addPitch (float deltaPitch)
 Method to add to the local pitch (rotation around X-axis).
void addYaw (float deltaYaw)
 Method to add to the local yaw (rotation around Y-axis).
void addRoll (float deltaRoll)
 Method to add to the local roll (rotation around Z-axis).
glm::vec3 getForwardVector ()
glm::vec3 getRightVector ()
 Method to get normalized right vector.
glm::vec3 getUpVector ()
 Method to get normalized up vector.

Private Attributes

glm::vec3 position = {0.0f, 0.0f, 0.0f}
glm::quat m_rotationQuat = glm::quat(1.0f, 0.0f, 0.0f, 0.0f)
glm::vec3 scale = {1.0f, 1.0f, 1.0f}
vex::Entity parent = vex::NULL_ENTITY
bool lastTransformed = true
vex::Registrym_registry = nullptr
bool physicsAffected = false
glm::mat4 cachedMatrix = glm::mat4(1.0f)
bool dirty = true

Detailed Description

Struct containing transform data and methods.

Definition at line 33 of file BasicComponents.hpp.

Constructor & Destructor Documentation

◆ TransformComponent() [1/6]

vex::TransformComponent::TransformComponent ( const TransformComponent & other)
inline

Copy Constructor. Copies all data members and maintains the reference to the same registry.

Definition at line 58 of file BasicComponents.hpp.

◆ TransformComponent() [2/6]

vex::TransformComponent::TransformComponent ( vex::Registry & registry)
inline

Constructor 1: Registry only.

Definition at line 78 of file BasicComponents.hpp.

◆ TransformComponent() [3/6]

vex::TransformComponent::TransformComponent ( vex::Registry & registry,
glm::vec3 pos,
vex::Entity p = vex::NULL_ENTITY )
inline

Constructor 2: Registry, Position, (optional Parent).

Definition at line 82 of file BasicComponents.hpp.

◆ TransformComponent() [4/6]

vex::TransformComponent::TransformComponent ( vex::Registry & registry,
glm::vec3 pos,
glm::vec3 rot,
vex::Entity p = vex::NULL_ENTITY )
inline

Constructor 3: Registry, Position, Rotation (Euler degrees), (optional Parent).

Definition at line 86 of file BasicComponents.hpp.

◆ TransformComponent() [5/6]

vex::TransformComponent::TransformComponent ( vex::Registry & registry,
glm::vec3 pos,
glm::vec3 rot,
glm::vec3 s,
vex::Entity p = vex::NULL_ENTITY )
inline

Constructor 4: Registry, Position, Rotation (Euler degrees), Scale, (optional Parent).

Definition at line 90 of file BasicComponents.hpp.

◆ TransformComponent() [6/6]

vex::TransformComponent::TransformComponent ( vex::Registry & registry,
vex::Entity p )
inline

Constructor 5: Registry, Parent only (useful for empty child objects).

Definition at line 94 of file BasicComponents.hpp.

Member Function Documentation

◆ addLocalPosition()

void vex::TransformComponent::addLocalPosition ( glm::vec3 newPosition)
inline

Method to add local position.

Parameters
newPositionglm::vec3

Definition at line 328 of file BasicComponents.hpp.

◆ addLocalQuaternion()

void vex::TransformComponent::addLocalQuaternion ( glm::quat deltaRotation)
inline

Multiply a delta quaternion into the current local rotation.

Definition at line 223 of file BasicComponents.hpp.

◆ addLocalRotation()

void vex::TransformComponent::addLocalRotation ( glm::vec3 newRotation)
inline

Method to add local rotation (Euler angles in degrees).

Parameters
newRotationglm::vec3

Definition at line 335 of file BasicComponents.hpp.

◆ addLocalScale()

void vex::TransformComponent::addLocalScale ( glm::vec3 newScale)
inline

Method to add local scale.

Parameters
newScaleglm::vec3

Definition at line 344 of file BasicComponents.hpp.

◆ addPitch()

void vex::TransformComponent::addPitch ( float deltaPitch)
inline

Method to add to the local pitch (rotation around X-axis).

Parameters
deltaPitchfloat The amount to add in degrees.

Definition at line 351 of file BasicComponents.hpp.

◆ addRoll()

void vex::TransformComponent::addRoll ( float deltaRoll)
inline

Method to add to the local roll (rotation around Z-axis).

Parameters
deltaRollfloat The amount to add in degrees.

Definition at line 369 of file BasicComponents.hpp.

◆ addYaw()

void vex::TransformComponent::addYaw ( float deltaYaw)
inline

Method to add to the local yaw (rotation around Y-axis).

Parameters
deltaYawfloat The amount to add in degrees.

Definition at line 360 of file BasicComponents.hpp.

◆ getForwardVector()

glm::vec3 vex::TransformComponent::getForwardVector ( )
inline

Definition at line 377 of file BasicComponents.hpp.

◆ getLocalPosition()

glm::vec3 vex::TransformComponent::getLocalPosition ( ) const
inline

Get the local position.

Definition at line 141 of file BasicComponents.hpp.

◆ getLocalQuaternion()

glm::quat vex::TransformComponent::getLocalQuaternion ( ) const
inline

Get the local rotation as a quaternion directly.

Definition at line 212 of file BasicComponents.hpp.

◆ getLocalRotation()

glm::vec3 vex::TransformComponent::getLocalRotation ( ) const
inline

Get the local rotation (as Euler angles in degrees).

Definition at line 146 of file BasicComponents.hpp.

◆ getLocalScale()

glm::vec3 vex::TransformComponent::getLocalScale ( ) const
inline

Get the local scale.

Definition at line 151 of file BasicComponents.hpp.

◆ getParent()

vex::Entity vex::TransformComponent::getParent ( ) const
inline

Get the parent entity.

Definition at line 136 of file BasicComponents.hpp.

◆ getRightVector()

glm::vec3 vex::TransformComponent::getRightVector ( )
inline

Method to get normalized right vector.

Returns
glm::vec3

Definition at line 383 of file BasicComponents.hpp.

◆ getUpVector()

glm::vec3 vex::TransformComponent::getUpVector ( )
inline

Method to get normalized up vector.

Returns
glm::vec3

Definition at line 389 of file BasicComponents.hpp.

◆ getWorldPosition()

glm::vec3 vex::TransformComponent::getWorldPosition ( )
inline

Method to get world position, needed when object is parented as position parameter stores local position.

Returns
glm::vec3

Definition at line 257 of file BasicComponents.hpp.

◆ getWorldQuaternion()

glm::quat vex::TransformComponent::getWorldQuaternion ( ) const
inline

Method to get the world rotation as a quaternion.

Definition at line 176 of file BasicComponents.hpp.

◆ getWorldRotation()

glm::vec3 vex::TransformComponent::getWorldRotation ( )
inline

Method to get world rotation, needed when object is parented as rotation parameter stores local rotation.

Returns
glm::vec3

Definition at line 263 of file BasicComponents.hpp.

◆ getWorldScale()

glm::vec3 vex::TransformComponent::getWorldScale ( )
inline

Method to get world scale, needed when object is parented as scale parameter stores local scale.

Returns
glm::vec3

Definition at line 269 of file BasicComponents.hpp.

◆ isDirty()

bool vex::TransformComponent::isDirty ( )
inline

Definition at line 100 of file BasicComponents.hpp.

◆ isReady()

bool vex::TransformComponent::isReady ( ) const
inline

Definition at line 119 of file BasicComponents.hpp.

◆ matrix()

glm::mat4 vex::TransformComponent::matrix ( bool forceRecalculate = false)
inline

Method used by renderer to calculate the transformation matrix.

Parameters
boolforceRecalculate if force recalculate

Definition at line 247 of file BasicComponents.hpp.

◆ operator=()

TransformComponent & vex::TransformComponent::operator= ( const TransformComponent & other)
inline

Copy Assignment Operator. Copies all data members and maintains the reference to the same registry.

Definition at line 67 of file BasicComponents.hpp.

◆ recalculateMatrix()

glm::mat4 vex::TransformComponent::recalculateMatrix ( )
inline

Definition at line 230 of file BasicComponents.hpp.

◆ setLocalPosition()

void vex::TransformComponent::setLocalPosition ( glm::vec3 newPosition)
inline

Set the local position.

Definition at line 156 of file BasicComponents.hpp.

◆ setLocalQuaternion()

void vex::TransformComponent::setLocalQuaternion ( glm::quat newRotation)
inline

Set the local rotation using a quaternion directly.

Definition at line 217 of file BasicComponents.hpp.

◆ setLocalRotation()

void vex::TransformComponent::setLocalRotation ( glm::vec3 newRotation)
inline

Set the local rotation (using Euler angles in degrees).

Definition at line 162 of file BasicComponents.hpp.

◆ setLocalScale()

void vex::TransformComponent::setLocalScale ( glm::vec3 newScale)
inline

Set the local scale.

Definition at line 168 of file BasicComponents.hpp.

◆ setParent()

void vex::TransformComponent::setParent ( vex::Entity newParent)
inline

Set the parent entity.

Definition at line 131 of file BasicComponents.hpp.

◆ setRegistry()

void vex::TransformComponent::setRegistry ( vex::Registry & reg)
inline

Definition at line 114 of file BasicComponents.hpp.

◆ setWorldPosition()

void vex::TransformComponent::setWorldPosition ( glm::vec3 newPosition)
inline

Method to set world position, needed when object is parented as position parameter stores local position.

Parameters
newPositionglm::vec3

Definition at line 281 of file BasicComponents.hpp.

◆ setWorldPositionPhys()

void vex::TransformComponent::setWorldPositionPhys ( glm::vec3 newPosition)
inline

Method to set world position by physics component.

Parameters
newPositionglm::vec3

Definition at line 295 of file BasicComponents.hpp.

◆ setWorldQuaternion()

void vex::TransformComponent::setWorldQuaternion ( glm::quat targetWorldQuat)
inline

Method to set world rotation using a quaternion (for physics systems).

Parameters
targetWorldQuatglm::quat The desired world rotation quaternion.

Definition at line 185 of file BasicComponents.hpp.

◆ setWorldQuaternionPhys()

void vex::TransformComponent::setWorldQuaternionPhys ( glm::quat targetWorldQuat)
inline

Method to set world rotation using a quaternion (for physics systems).

Parameters
targetWorldQuatglm::quat The desired world rotation quaternion.

Definition at line 199 of file BasicComponents.hpp.

◆ setWorldRotation()

void vex::TransformComponent::setWorldRotation ( glm::vec3 newRotation)
inline

Method to set world rotation, needed when object is parented as rotation parameter stores local rotation.

Parameters
newRotationglm::vec3

Definition at line 309 of file BasicComponents.hpp.

◆ setWorldScale()

void vex::TransformComponent::setWorldScale ( glm::vec3 newScale)
inline

Method to set world scale, needed when object is parented as rotation parameter stores local rotation.

Parameters
newScaleglm::vec3

Definition at line 316 of file BasicComponents.hpp.

Member Data Documentation

◆ cachedMatrix

glm::mat4 vex::TransformComponent::cachedMatrix = glm::mat4(1.0f)
private

Definition at line 53 of file BasicComponents.hpp.

◆ dirty

bool vex::TransformComponent::dirty = true
private

Definition at line 54 of file BasicComponents.hpp.

◆ lastTransformed

bool vex::TransformComponent::lastTransformed = true
private

Definition at line 50 of file BasicComponents.hpp.

◆ m_registry

vex::Registry* vex::TransformComponent::m_registry = nullptr
private

Definition at line 51 of file BasicComponents.hpp.

◆ m_rotationQuat

glm::quat vex::TransformComponent::m_rotationQuat = glm::quat(1.0f, 0.0f, 0.0f, 0.0f)
private

Definition at line 47 of file BasicComponents.hpp.

◆ parent

vex::Entity vex::TransformComponent::parent = vex::NULL_ENTITY
private

Definition at line 49 of file BasicComponents.hpp.

◆ physicsAffected

bool vex::TransformComponent::physicsAffected = false
private

Definition at line 52 of file BasicComponents.hpp.

◆ position

glm::vec3 vex::TransformComponent::position = {0.0f, 0.0f, 0.0f}
private

Definition at line 46 of file BasicComponents.hpp.

◆ scale

glm::vec3 vex::TransformComponent::scale = {1.0f, 1.0f, 1.0f}
private

Definition at line 48 of file BasicComponents.hpp.


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