Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
oe::scene::Transform Class Reference

Manage local Translation / Rotation / Scale of an entity in the world. More...

#include <OxygenEngine/scene/transform.h>

Inheritance diagram for oe::scene::Transform:
[legend]

Public Member Functions

 Transform (const glm::vec3 &translation=glm::vec3(0.f), const glm::quat &rotation=glm::quat(1.f, 0.f, 0.f, 0.f), const glm::vec3 &scale=glm::vec3(1.f), const glm::vec3 &skew=glm::vec3(0.f), const glm::vec4 &perspective=glm::vec4(glm::vec3(0.f), 1.f))
 Generate Transform from its translation, rotation, scale values.
 
 Transform (const glm::mat4 &model)
 Generate Transform from a model matrix.
 
const glm::vec3 & getTranslation () const
 Get Translation component value of the transform.
 
const glm::vec3 & getPosition () const
 Get Translation component value of the transform.
 
const glm::quat & getRotation () const
 Get Rotation component value of the transform.
 
const glm::vec3 & getScale () const
 Get Scaling component value of the transform.
 
const glm::vec3 & getSkew () const
 Get Skew component value of the transform.
 
const glm::vec4 & getPerspective () const
 get Perspective component value of the transform
 
void setTranslation (const float x, const float y, const float z)
 Translate to the specified position, filled component wise.
 
void setPosition (const glm::vec3 &position)
 Translate to the specified position.
 
void setPosition (const float x, const float y, const float z)
 Translate to the specified position.
 
void setRotation (const float x, const float y, const float z)
 Set rotation from Euler angles.
 
void setRotation (const lit::Angle &x, const lit::Angle &y, const lit::Angle &z)
 Relatively rotate the transform using a lit::Angle triad.
 
void setScale (const float x, const float y, const float z)
 Set scaling.
 
void relativeTranslate (const glm::vec3 &translation)
 Translate the transform from current position.
 
void relativeTranslate (const float x, const float y, const float z)
 Translate the transform from current position, component wise.
 
void loadFromModel (const glm::mat4 &model)
 Fill the transform from a model matrix.
 
void relativeMove (const glm::vec3 &translation)
 Move the transform relative to current translation.
 
void relativeRotate (const glm::quat &quaternion)
 Rotate the transform relative to current rotation.
 
void relativeRotate (const float x, const float y, const float z)
 Rotate the transform from Euler angles (component wise)
 
void relativeRotate (const lit::Angle &x, const lit::Angle &y, const lit::Angle &z)
 Relatively rotate the transform using a lit::Angle triad.
 
void relativeScale (const glm::vec3 &scale)
 Multiply current scale by the new one.
 
void setSkew (const glm::vec3 &skew)
 Set skew of the transform.
 
void setPerspective (const glm::vec4 &perspective)
 Set perspective effect of the transform.
 
void interpolateWith (const float ratio, const Transform &target)
 Interpolate this transform with another one.
 
void fillFrom (const Transform &transform)
 Fill current values from another transform.
 
template<TranslationType T>
void setTranslation (const T &translation)
 Translate to the specified position.
 
template<RotationType R>
void setRotation (const R &rotation)
 Get rotation quaternion from a generic type.
 
template<ScaleType S>
void setScale (const S &scale)
 Set scale vector from a generic type.
 
template<TranslationType T>
void getTranslationAs (T &result) const
 Get translation vector and fill in generic type.
 
template<RotationType R>
void getRotationAs (R &result) const
 Get rotation quaternion and fill in generic type.
 
template<ScaleType S>
void getScaleAs (S &result) const
 Get scale vector and fill in generic type.
 
glm::mat4 getModelMatrix () const
 Generate a Model matrix from the transform.
 
bool isDirty () const
 Check if something modified this transform.
 

Protected Member Functions

void forceDirty (const bool is_dirty) const
 Set custom dirty status.
 

Detailed Description

Manage local Translation / Rotation / Scale of an entity in the world.

Constructor & Destructor Documentation

◆ Transform() [1/2]

oe::scene::Transform::Transform ( const glm::vec3 &  translation = glm::vec3(0.f),
const glm::quat &  rotation = glm::quat(1.f, 0.f, 0.f, 0.f),
const glm::vec3 &  scale = glm::vec3(1.f),
const glm::vec3 &  skew = glm::vec3(0.f),
const glm::vec4 &  perspective = glm::vec4(glm::vec3(0.f), 1.f) 
)

Generate Transform from its translation, rotation, scale values.

Parameters
translation
rotation
scale
skew
perspective

◆ Transform() [2/2]

oe::scene::Transform::Transform ( const glm::mat4 &  model)

Generate Transform from a model matrix.

Parameters
model

Member Function Documentation

◆ fillFrom()

void oe::scene::Transform::fillFrom ( const Transform transform)

Fill current values from another transform.

Parameters
transformContaining source data to copy

◆ forceDirty()

void oe::scene::Transform::forceDirty ( const bool  is_dirty) const
inlineprotected

Set custom dirty status.

Parameters
is_dirtydoes the transform should react as dirty

◆ getModelMatrix()

glm::mat4 oe::scene::Transform::getModelMatrix ( ) const

Generate a Model matrix from the transform.

Returns
Standard TRS matrix (first apply scale then rotation and finally translation)

◆ getPerspective()

const glm::vec4 & oe::scene::Transform::getPerspective ( ) const
inline

get Perspective component value of the transform

Returns
local perspective vector

◆ getPosition()

const glm::vec3 & oe::scene::Transform::getPosition ( ) const
inline

Get Translation component value of the transform.

Returns
local translation vector

◆ getRotation()

const glm::quat & oe::scene::Transform::getRotation ( ) const
inline

Get Rotation component value of the transform.

Returns
local rotation quaternion

◆ getRotationAs()

template<RotationType R>
void oe::scene::Transform::getRotationAs ( R &  result) const
inline

Get rotation quaternion and fill in generic type.

Note
Reference is used instead of a return to let the user deal with constructor of Q
Parameters
resultobject to fill rotation data

◆ getScale()

const glm::vec3 & oe::scene::Transform::getScale ( ) const
inline

Get Scaling component value of the transform.

Returns
local scale vector

◆ getScaleAs()

template<ScaleType S>
void oe::scene::Transform::getScaleAs ( S &  result) const
inline

Get scale vector and fill in generic type.

Note
Reference is used instead of a return to let the user deal with constructor of S
Parameters
resultobject to fill rotation data

◆ getSkew()

const glm::vec3 & oe::scene::Transform::getSkew ( ) const
inline

Get Skew component value of the transform.

Returns
local skew vector

◆ getTranslation()

const glm::vec3 & oe::scene::Transform::getTranslation ( ) const
inline

Get Translation component value of the transform.

Returns
local translation vector

◆ getTranslationAs()

template<TranslationType T>
void oe::scene::Transform::getTranslationAs ( T &  result) const
inline

Get translation vector and fill in generic type.

Note
Reference is used instead of a return to let the user deal with constructor of P
Parameters
resultobject to fill translation data

◆ interpolateWith()

void oe::scene::Transform::interpolateWith ( const float  ratio,
const Transform target 
)

Interpolate this transform with another one.

Parameters
ratioRatio of interpolation between 0.0 (No target contribution) and 1.0 (only target contribution)
targetSecond operand of the interpolation

◆ isDirty()

bool oe::scene::Transform::isDirty ( ) const
inline

Check if something modified this transform.

Returns
true if this transform have any of its field modified and forceDirty(false) was not called

◆ loadFromModel()

void oe::scene::Transform::loadFromModel ( const glm::mat4 &  model)

Fill the transform from a model matrix.

Parameters
modelComponents of the Transform will be extracted from this matrix

◆ relativeMove()

void oe::scene::Transform::relativeMove ( const glm::vec3 &  translation)

Move the transform relative to current translation.

Parameters
translationTranslation vector

◆ relativeRotate() [1/3]

void oe::scene::Transform::relativeRotate ( const float  x,
const float  y,
const float  z 
)

Rotate the transform from Euler angles (component wise)

Deprecated:
you should prefer relativeRotate(const lit::Angle& x, const lit::Angle& y, const lit::Angle& z)
Parameters
xPitch (degrees)
yYaw (degrees)
zRoll (degrees)

◆ relativeRotate() [2/3]

void oe::scene::Transform::relativeRotate ( const glm::quat &  quaternion)

Rotate the transform relative to current rotation.

Parameters
quaternionRotation quaternion

◆ relativeRotate() [3/3]

void oe::scene::Transform::relativeRotate ( const lit::Angle x,
const lit::Angle y,
const lit::Angle z 
)

Relatively rotate the transform using a lit::Angle triad.

Parameters
xPitch
yYaw
zRoll

◆ relativeScale()

void oe::scene::Transform::relativeScale ( const glm::vec3 &  scale)

Multiply current scale by the new one.

Parameters
scaleScale factor along each axis

◆ relativeTranslate() [1/2]

void oe::scene::Transform::relativeTranslate ( const float  x,
const float  y,
const float  z 
)

Translate the transform from current position, component wise.

Parameters
x
y
z

◆ relativeTranslate() [2/2]

void oe::scene::Transform::relativeTranslate ( const glm::vec3 &  translation)

Translate the transform from current position.

Parameters
translationTranslation vector

◆ setPerspective()

void oe::scene::Transform::setPerspective ( const glm::vec4 &  perspective)

Set perspective effect of the transform.

Parameters
perspective

◆ setPosition() [1/2]

void oe::scene::Transform::setPosition ( const float  x,
const float  y,
const float  z 
)
inline

Translate to the specified position.

Note
Alias for setTranslation
Parameters
x
y
z

◆ setPosition() [2/2]

void oe::scene::Transform::setPosition ( const glm::vec3 &  position)
inline

Translate to the specified position.

Note
Alias for setTranslation
Parameters
position

◆ setRotation() [1/3]

void oe::scene::Transform::setRotation ( const float  x,
const float  y,
const float  z 
)

Set rotation from Euler angles.

Deprecated:
you should prefer setRotation(const lit::Angle& x, const lit::Angle& y, const lit::Angle& z)
Parameters
xPitch (degrees)
yYaw (degrees)
zRoll (degrees)

◆ setRotation() [2/3]

void oe::scene::Transform::setRotation ( const lit::Angle x,
const lit::Angle y,
const lit::Angle z 
)

Relatively rotate the transform using a lit::Angle triad.

Parameters
xPitch
yYaw
zRoll

◆ setRotation() [3/3]

template<RotationType R>
void oe::scene::Transform::setRotation ( const R &  rotation)
inline

Get rotation quaternion from a generic type.

Parameters
rotationObject containing rotation data

◆ setScale() [1/2]

void oe::scene::Transform::setScale ( const float  x,
const float  y,
const float  z 
)

Set scaling.

Parameters
xScaling along the X axis
yScaling along the Y axis
zScaling along the Z axis

◆ setScale() [2/2]

template<ScaleType S>
void oe::scene::Transform::setScale ( const S &  scale)
inline

Set scale vector from a generic type.

Parameters
scaleObject containing scale data

◆ setSkew()

void oe::scene::Transform::setSkew ( const glm::vec3 &  skew)

Set skew of the transform.

Parameters
skewSkew factor along each axis

◆ setTranslation() [1/2]

void oe::scene::Transform::setTranslation ( const float  x,
const float  y,
const float  z 
)

Translate to the specified position, filled component wise.

Parameters
x
y
z

◆ setTranslation() [2/2]

template<TranslationType T>
void oe::scene::Transform::setTranslation ( const T &  translation)
inline

Translate to the specified position.

Parameters
translationObject containing translation data

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