MAGE  v0.171.0
Matthias Advanced Game Engine
mage::SpriteTransform2D Class Reference

#include <sprite_transform.hpp>

Public Member Functions

 SpriteTransform2D (F32x2 translation={ 0.0f, 0.0f }, F32 depth=0.0f, F32 rotation=0.0f, F32x2 rotation_origin={ 0.0f, 0.0f }, F32x2 scale={ 1.0f, 1.0f }) noexcept
 
 SpriteTransform2D (FXMVECTOR translation, F32 depth, F32 rotation, FXMVECTOR rotation_origin, FXMVECTOR scale) noexcept
 
 SpriteTransform2D (const SpriteTransform2D &transform) noexcept=default
 
 SpriteTransform2D (SpriteTransform2D &&transform) noexcept=default
 
 ~SpriteTransform2D ()=default
 
SpriteTransform2Doperator= (const SpriteTransform2D &transform) noexcept=default
 
SpriteTransform2Doperator= (SpriteTransform2D &&transform) noexcept=default
 
void SetTranslationX (F32 x) noexcept
 
void SetTranslationY (F32 y) noexcept
 
void SetTranslation (F32 x, F32 y) noexcept
 
void SetTranslation (F32x2 translation) noexcept
 
void XM_CALLCONV SetTranslation (FXMVECTOR translation) noexcept
 
void AddTranslationX (F32 x) noexcept
 
void AddTranslationY (F32 y) noexcept
 
void AddTranslation (F32 x, F32 y) noexcept
 
void AddTranslation (const F32x2 &translation) noexcept
 
void XM_CALLCONV AddTranslation (FXMVECTOR translation) noexcept
 
F32 GetTranslationX () const noexcept
 
F32 GetTranslationY () const noexcept
 
const F32x2 GetTranslationView () const noexcept
 
const XMVECTOR XM_CALLCONV GetTranslation () const noexcept
 
void SetDepth (F32 depth) noexcept
 
void AddDepth (F32 depth) noexcept
 
F32 GetDepth () const noexcept
 
void SetRotation (F32 rotation) noexcept
 
void AddRotation (F32 rotation) noexcept
 
void AddRotation (F32 rotation, F32 min_angle, F32 max_angle) noexcept
 
F32 GetRotation () const noexcept
 
void SetRotationOriginX (F32 x) noexcept
 
void SetRotationOriginY (F32 y) noexcept
 
void SetRotationOrigin (F32 x, F32 y) noexcept
 
void SetRotationOrigin (F32x2 rotation_origin) noexcept
 
void XM_CALLCONV SetRotationOrigin (FXMVECTOR rotation_origin) noexcept
 
void AddRotationOriginX (F32 x) noexcept
 
void AddRotationOriginY (F32 y) noexcept
 
void AddRotationOrigin (F32 x, F32 y) noexcept
 
void AddRotationOrigin (const F32x2 &offset) noexcept
 
void XM_CALLCONV AddRotationOrigin (FXMVECTOR offset) noexcept
 
F32 GetRotationOriginX () const noexcept
 
F32 GetRotationOriginY () const noexcept
 
const F32x2 GetRotationOriginView () const noexcept
 
const XMVECTOR XM_CALLCONV GetRotationOrigin () const noexcept
 
void SetScaleX (F32 x) noexcept
 
void SetScaleY (F32 y) noexcept
 
void SetScale (F32 s) noexcept
 
void SetScale (F32 x, F32 y) noexcept
 
void SetScale (F32x2 scale) noexcept
 
void XM_CALLCONV SetScale (FXMVECTOR scale) noexcept
 
void AddScaleX (F32 x) noexcept
 
void AddScaleY (F32 y) noexcept
 
void AddScale (F32 s) noexcept
 
void AddScale (F32 x, F32 y) noexcept
 
void AddScale (const F32x2 &scale) noexcept
 
void XM_CALLCONV AddScale (FXMVECTOR scale) noexcept
 
F32 GetScaleX () const noexcept
 
F32 GetScaleY () const noexcept
 
const F32x2 GetScaleView () const noexcept
 
const XMVECTOR XM_CALLCONV GetScale () const noexcept
 
const XMMATRIX XM_CALLCONV GetTransformMatrix () const noexcept
 

Private Attributes

F32x2 m_translation
 
F32 m_depth
 
F32 m_rotation
 
F32x2 m_rotation_origin
 
F32x2 m_scale
 

Detailed Description

A class of 2D sprite transforms supporting non-uniform scaling, rotation and translation (incl. depth).

Constructor & Destructor Documentation

◆ SpriteTransform2D() [1/4]

mage::SpriteTransform2D::SpriteTransform2D ( F32x2  translation = { 0.0f, 0.0f },
F32  depth = 0.0f,
F32  rotation = 0.0f,
F32x2  rotation_origin = { 0.0f, 0.0f },
F32x2  scale = { 1.0f, 1.0f } 
)
explicitnoexcept

Constructs a sprite transform from the given translation, depth, rotation, rotation origin and scale component.

Parameters
[in]translationThe translation component.
[in]depthThe depth component.
[in]rotationThe rotation component.
[in]rotation_originThe rotation component.
[in]scaleThe scale component.

◆ SpriteTransform2D() [2/4]

mage::SpriteTransform2D::SpriteTransform2D ( FXMVECTOR  translation,
F32  depth,
F32  rotation,
FXMVECTOR  rotation_origin,
FXMVECTOR  scale 
)
explicitnoexcept

Constructs a sprite transform from the given translation, depth, rotation, rotation origin and scale component.

Parameters
[in]translationThe translation component.
[in]depthThe depth component.
[in]rotationThe rotation component.
[in]rotation_originThe rotation component.
[in]scaleThe scale component.

◆ SpriteTransform2D() [3/4]

mage::SpriteTransform2D::SpriteTransform2D ( const SpriteTransform2D transform)
defaultnoexcept

Constructs a sprite transform from the given sprite transform.

Parameters
[in]transformA reference to the sprite transform to copy.

◆ SpriteTransform2D() [4/4]

mage::SpriteTransform2D::SpriteTransform2D ( SpriteTransform2D &&  transform)
defaultnoexcept

Constructs a sprite transform by moving the given sprite transform.

Parameters
[in]transformA reference to the sprite transform to move.

◆ ~SpriteTransform2D()

mage::SpriteTransform2D::~SpriteTransform2D ( )
default

Destructs this sprite transform.

Member Function Documentation

◆ AddDepth()

void mage::SpriteTransform2D::AddDepth ( F32  depth)
noexcept

Adds the given depth component to the depth component of this sprite transform.

Parameters
[in]depthThe depth component to add.

◆ AddRotation() [1/2]

void mage::SpriteTransform2D::AddRotation ( F32  rotation)
noexcept

Adds the given rotation component to the rotation component of this sprite transform.

Parameters
[in]rotationThe rotation component to add.

◆ AddRotation() [2/2]

void mage::SpriteTransform2D::AddRotation ( F32  rotation,
F32  min_angle,
F32  max_angle 
)
noexcept

Adds the given rotation component to the rotation component of this sprite transform and clamps the resulting rotation component of this sprite transform between the given values.

Precondition
min_angle lies in [-pi, pi].
max_angle lies in [-pi, pi].
min_angle is not greater than max_angle.
Parameters
[in]rotationThe rotation component to add.
[in]min_angleThe minimum angle (in radians).
[in]max_angleThe maximum angle (in radians).

◆ AddRotationOrigin() [1/3]

void mage::SpriteTransform2D::AddRotationOrigin ( F32  x,
F32  y 
)
noexcept

Adds the given offsets to the rotation origin of this sprite transform.

Parameters
[in]xThe x-value of the offset to add.
[in]yThe y-value of the offset to add.

◆ AddRotationOrigin() [2/3]

void mage::SpriteTransform2D::AddRotationOrigin ( const F32x2 offset)
noexcept

Adds the given offset to the rotation origin of this sprite transform.

Parameters
[in]offsetThe offset to add.

◆ AddRotationOrigin() [3/3]

void XM_CALLCONV mage::SpriteTransform2D::AddRotationOrigin ( FXMVECTOR  offset)
noexcept

Adds the given offset to the rotation origin of this sprite transform.

Parameters
[in]offsetThe offset to add.

◆ AddRotationOriginX()

void mage::SpriteTransform2D::AddRotationOriginX ( F32  x)
noexcept

Adds the given x-value to the rotation origin of this sprite transform.

Parameters
[in]xThe x-value of the offset to add.

◆ AddRotationOriginY()

void mage::SpriteTransform2D::AddRotationOriginY ( F32  y)
noexcept

Adds the given y-value to the rotation origin of this sprite transform.

Parameters
[in]yThe y-value of the offset to add.

◆ AddScale() [1/4]

void mage::SpriteTransform2D::AddScale ( F32  s)
noexcept

Adds the given scale component to the scale component of this sprite transform.

Parameters
[in]sThe scale component to add.

◆ AddScale() [2/4]

void mage::SpriteTransform2D::AddScale ( F32  x,
F32  y 
)
noexcept

Adds the given scale component to the scale component of this sprite transform.

Parameters
[in]xThe x-value of the scale component to add.
[in]yThe y-value of the scale component to add.

◆ AddScale() [3/4]

void mage::SpriteTransform2D::AddScale ( const F32x2 scale)
noexcept

Adds the given scale component to the scale component of this sprite transform.

Parameters
[in]scaleA reference to the scale component to add.

◆ AddScale() [4/4]

void XM_CALLCONV mage::SpriteTransform2D::AddScale ( FXMVECTOR  scale)
noexcept

Adds the given scale component to the scale component of this sprite transform.

Parameters
[in]scaleThe scale component to add.

◆ AddScaleX()

void mage::SpriteTransform2D::AddScaleX ( F32  x)
noexcept

Adds the given x-value to the scale component of this sprite transform.

Parameters
[in]xThe x-value of the scale component to add.

◆ AddScaleY()

void mage::SpriteTransform2D::AddScaleY ( F32  y)
noexcept

Adds the given y-value to the scale component of this sprite transform.

Parameters
[in]yThe y-value of the scale component to add.

◆ AddTranslation() [1/3]

void mage::SpriteTransform2D::AddTranslation ( F32  x,
F32  y 
)
noexcept

Adds the given translation component to the translation component of this sprite transform.

Parameters
[in]xThe x-value of the translation component to add.
[in]yThe y-value of the translation component to add.

◆ AddTranslation() [2/3]

void mage::SpriteTransform2D::AddTranslation ( const F32x2 translation)
noexcept

Adds the given translation component to the translation component of this sprite transform.

Parameters
[in]translationA reference to the translation component to add.

◆ AddTranslation() [3/3]

void XM_CALLCONV mage::SpriteTransform2D::AddTranslation ( FXMVECTOR  translation)
noexcept

Adds the given translation component to the translation component of this sprite transform.

Parameters
[in]translationThe translation component to add.

◆ AddTranslationX()

void mage::SpriteTransform2D::AddTranslationX ( F32  x)
noexcept

Adds the given x-value to the translation component of this sprite transform.

Parameters
[in]xThe x-value of the translation component to add.

◆ AddTranslationY()

void mage::SpriteTransform2D::AddTranslationY ( F32  y)
noexcept

Adds the given y-value to the translation component of this sprite transform.

Parameters
[in]yThe y-value of the translation component to add.

◆ GetDepth()

F32 mage::SpriteTransform2D::GetDepth ( ) const
noexcept

Returns the depth component of this sprite transform.

Returns
The depth component of this sprite transform.

◆ GetRotation()

F32 mage::SpriteTransform2D::GetRotation ( ) const
noexcept

Returns the rotation component of this sprite transform.

Returns
The rotation component of this sprite transform.

◆ GetRotationOrigin()

const XMVECTOR XM_CALLCONV mage::SpriteTransform2D::GetRotationOrigin ( ) const
noexcept

Returns the rotation origin of this sprite transform.

Returns
The rotation origin of this sprite transform.

◆ GetRotationOriginView()

const F32x2 mage::SpriteTransform2D::GetRotationOriginView ( ) const
noexcept

Returns the rotation origin of this sprite transform.

Returns
The rotation origin of this sprite transform.

◆ GetRotationOriginX()

F32 mage::SpriteTransform2D::GetRotationOriginX ( ) const
noexcept

Returns the x-value of the rotation origin of this sprite transform.

Returns
The x-value of the rotation origin of this sprite transform.

◆ GetRotationOriginY()

F32 mage::SpriteTransform2D::GetRotationOriginY ( ) const
noexcept

Returns the y-value of the rotation origin of this sprite transform.

Returns
The y-value of the rotation origin of this sprite transform.

◆ GetScale()

const XMVECTOR XM_CALLCONV mage::SpriteTransform2D::GetScale ( ) const
noexcept

Returns the scale component of this sprite transform.

Returns
The scale component of this sprite transform.

◆ GetScaleView()

const F32x2 mage::SpriteTransform2D::GetScaleView ( ) const
noexcept

Returns the scale component of this sprite transform.

Returns
The scale component of this sprite transform.

◆ GetScaleX()

F32 mage::SpriteTransform2D::GetScaleX ( ) const
noexcept

Returns the x-value of the scale component of this sprite transform.

Returns
The x-value of the scale component of this sprite transform.

◆ GetScaleY()

F32 mage::SpriteTransform2D::GetScaleY ( ) const
noexcept

Returns the y-value of the scale component of this sprite transform.

Returns
The y-value of the scale component of this sprite transform.

◆ GetTransformMatrix()

const XMMATRIX XM_CALLCONV mage::SpriteTransform2D::GetTransformMatrix ( ) const
noexcept

Returns the transformation matrix of this sprite transform.

Returns
The transformation matrix of this sprite transform.

◆ GetTranslation()

const XMVECTOR XM_CALLCONV mage::SpriteTransform2D::GetTranslation ( ) const
noexcept

Returns the translation component of this sprite transform.

Returns
The translation component of this sprite transform.

◆ GetTranslationView()

const F32x2 mage::SpriteTransform2D::GetTranslationView ( ) const
noexcept

Returns the translation component of this sprite transform.

Returns
The translation component of this sprite transform.

◆ GetTranslationX()

F32 mage::SpriteTransform2D::GetTranslationX ( ) const
noexcept

Returns the x-value of the translation component of this sprite transform.

Returns
The x-value of the translation component of this sprite transform.

◆ GetTranslationY()

F32 mage::SpriteTransform2D::GetTranslationY ( ) const
noexcept

Returns the y-value of the translation component of this sprite transform.

Returns
The y-value of the translation component of this sprite transform.

◆ operator=() [1/2]

SpriteTransform2D& mage::SpriteTransform2D::operator= ( const SpriteTransform2D transform)
defaultnoexcept

Copies the given sprite transform to this sprite transform.

Parameters
[in]transformThe sprite transform to move.
Returns
A reference to the copy of the given sprite transform (i.e. this sprite transform).

◆ operator=() [2/2]

SpriteTransform2D& mage::SpriteTransform2D::operator= ( SpriteTransform2D &&  transform)
defaultnoexcept

Moves the given sprite transform to this sprite transform.

Parameters
[in]transformThe sprite transform to copy.
Returns
A reference to the moved sprite transform (i.e. this sprite transform).

◆ SetDepth()

void mage::SpriteTransform2D::SetDepth ( F32  depth)
noexcept

Sets the depth component of this sprite transform to the given depth component.

Parameters
[in]depthThe depth component.

◆ SetRotation()

void mage::SpriteTransform2D::SetRotation ( F32  rotation)
noexcept

Sets the rotation component of this sprite transform to the given r otation component.

Parameters
[in]rotationThe rotation component.

◆ SetRotationOrigin() [1/3]

void mage::SpriteTransform2D::SetRotationOrigin ( F32  x,
F32  y 
)
noexcept

Sets the rotation origin of this sprite transform to the given rotation origin.

Parameters
[in]xThe x-value of the rotation origin.
[in]yThe y-value of the rotation origin.

◆ SetRotationOrigin() [2/3]

void mage::SpriteTransform2D::SetRotationOrigin ( F32x2  rotation_origin)
noexcept

Sets the rotation origin of this sprite transform to the given rotation origin.

Parameters
[in]rotation_originThe rotation origin.

◆ SetRotationOrigin() [3/3]

void XM_CALLCONV mage::SpriteTransform2D::SetRotationOrigin ( FXMVECTOR  rotation_origin)
noexcept

Sets the rotation origin of this sprite transform to the given rotation origin.

Parameters
[in]rotation_originThe rotation origin.

◆ SetRotationOriginX()

void mage::SpriteTransform2D::SetRotationOriginX ( F32  x)
noexcept

Sets the x-value of the rotation origin of this sprite transform to the given value.

Parameters
[in]xThe x-value of the rotation origin.

◆ SetRotationOriginY()

void mage::SpriteTransform2D::SetRotationOriginY ( F32  y)
noexcept

Sets the y-value of the rotation origin of this sprite transform to the given value.

Parameters
[in]yThe y-value of the rotation origin.

◆ SetScale() [1/4]

void mage::SpriteTransform2D::SetScale ( F32  s)
noexcept

Sets the scale component of this sprite transform to the given scale component.

Parameters
[in]sThe scale component.

◆ SetScale() [2/4]

void mage::SpriteTransform2D::SetScale ( F32  x,
F32  y 
)
noexcept

Sets the scale component of this sprite transform to the given scale component.

Parameters
[in]xThe x-value of the scale component.
[in]yThe y-value of the scale component.

◆ SetScale() [3/4]

void mage::SpriteTransform2D::SetScale ( F32x2  scale)
noexcept

Sets the scale component of this sprite transform to the given scale component.

Parameters
[in]scaleThe scale component.

◆ SetScale() [4/4]

void XM_CALLCONV mage::SpriteTransform2D::SetScale ( FXMVECTOR  scale)
noexcept

Sets the scale component of this sprite transform to the given scale component.

Parameters
[in]scaleThe scale component.

◆ SetScaleX()

void mage::SpriteTransform2D::SetScaleX ( F32  x)
noexcept

Sets the x-value of the scale component of this sprite transform to the given value.

Parameters
[in]xThe x-value of the scale component.

◆ SetScaleY()

void mage::SpriteTransform2D::SetScaleY ( F32  y)
noexcept

Sets the y-value of the scale component of this sprite transform to the given value.

Parameters
[in]yThe y-value of the scale component.

◆ SetTranslation() [1/3]

void mage::SpriteTransform2D::SetTranslation ( F32  x,
F32  y 
)
noexcept

Sets the translation component of this sprite transform to the given translation component.

Parameters
[in]xThe x-value of the translation component.
[in]yThe y-value of the translation component.

◆ SetTranslation() [2/3]

void mage::SpriteTransform2D::SetTranslation ( F32x2  translation)
noexcept

Sets the translation component of this sprite transform to the given translation component.

Parameters
[in]translationThe translation component.

◆ SetTranslation() [3/3]

void XM_CALLCONV mage::SpriteTransform2D::SetTranslation ( FXMVECTOR  translation)
noexcept

Sets the translation component of this sprite transform to the given translation component.

Parameters
[in]translationThe translation component.

◆ SetTranslationX()

void mage::SpriteTransform2D::SetTranslationX ( F32  x)
noexcept

Sets the x-value of the translation component of this sprite transform to the given value.

Parameters
[in]xThe x-value of the translation component.

◆ SetTranslationY()

void mage::SpriteTransform2D::SetTranslationY ( F32  y)
noexcept

Sets the y-value of the translation component of this sprite transform to the given value.

Parameters
[in]yThe y-value of the translation component.

Member Data Documentation

◆ m_depth

F32 mage::SpriteTransform2D::m_depth
private

The depth component of this sprite transform.

◆ m_rotation

F32 mage::SpriteTransform2D::m_rotation
private

The rotation component (in radians) of this sprite transform.

◆ m_rotation_origin

F32x2 mage::SpriteTransform2D::m_rotation_origin
private

The rotation origin (in texels) of this sprite transform.

◆ m_scale

F32x2 mage::SpriteTransform2D::m_scale
private

The scale component of this sprite transform.

◆ m_translation

F32x2 mage::SpriteTransform2D::m_translation
private

The translation component (in pixels) of this sprite transform.