NGL  6.5
The NCCA Graphics Library
ngl::Transformation Class Reference

Transformation describes a transformation (translate, scale, rotation) modifed by j macey and included into NGL. More...

#include <Transformation.h>

+ Collaboration diagram for ngl::Transformation:

Public Member Functions

 Transformation () noexcept
 Constructor. More...
 
 Transformation (const Transformation &_t) noexcept
 Copy Constructor. More...
 
Transformationoperator= (const Transformation &_t) noexcept
 assignment operator More...
 
void setScale (const Vec3 &_scale) noexcept
 method to set the scale value in the transform More...
 
void setScale (const Vec4 &_scale) noexcept
 
void setScale (Real _x, Real _y, Real _z) noexcept
 method to set the scale value in the transform More...
 
void addScale (const Vec3 &_scale) noexcept
 method to add to the existing the scale value in the transform More...
 
void addScale (Real _x, Real _y, Real _z) noexcept
 method to add to the existing the scale value in the transform More...
 
void setPosition (const Vec4 &_position) noexcept
 method to set the position More...
 
void setPosition (const Vec3 &_position) noexcept
 method to set the position More...
 
void setPosition (Real _x, Real _y, Real _z) noexcept
 method to set the position value in the transform More...
 
void addPosition (const Vec4 &_position) noexcept
 method add to the existing set the position More...
 
void addPosition (const Vec3 &_position) noexcept
 method add to the existing set the position More...
 
void addPosition (Real _x, Real _y, Real _z) noexcept
 method to add to the existing position value in the transform More...
 
void setMatrix (const Mat4 &_m) noexcept
 
void setRotation (const Vec3 &_rotation) noexcept
 method to set the rotation More...
 
void setRotation (const Vec4 &_rotation) noexcept
 
void setRotation (Real _x, Real _y, Real _z) noexcept
 method to set the rotation value in the transform More...
 
void addRotation (const Vec3 &_rotation) noexcept
 method to add to the existing rotation More...
 
void addRotation (Real _x, Real _y, Real _z) noexcept
 method to add to the existing rotation value in the transform More...
 
void reset () noexcept
 a method to set all the transforms to the identity More...
 
Vec3 getScale () const noexcept
 function to get the scale More...
 
Vec3 getPosition () const noexcept
 function to get the position More...
 
Vec3 getRotation () const noexcept
 function to get the rotation More...
 
Mat4 getMatrix () noexcept
 function to get the matrix. It computes the matrix if it's dirty More...
 
Mat4 getTransposeMatrix () noexcept
 function to get the transpose matrix. It computes the transpose matrix if it's dirty More...
 
Mat4 getInverseMatrix () noexcept
 function to get the inverse matrix. It computes the inverse matrix if it's dirty More...
 
void operator*= (const Transformation &_m) noexcept
 *= operator More...
 
Transformation operator* (const Transformation &_m) noexcept
 operator for Transform multiplication will do a matrix multiplication on each of the matrices More...
 
void loadMatrixToShader (const std::string &_param, const ActiveMatrix &_which=ActiveMatrix::NORMAL) noexcept
 load the current transform matrix to the shader More...
 
void loadGlobalAndCurrentMatrixToShader (const std::string &_param, Transformation &_global, const ActiveMatrix &_which=ActiveMatrix::NORMAL) noexcept
 load the current * global transform matrix to the shader More...
 

Protected Member Functions

void computeMatrices () noexcept
 method to compute the matrix, transpose and inverse matrix. set the m_bIsMatrixComputed variable to true. More...
 

Protected Attributes

Vec3 m_position
 position More...
 
Vec3 m_scale
 scale More...
 
Vec3 m_rotation
 rotation More...
 
bool m_isMatrixComputed
 boolean defines if the matrix is dirty or not More...
 
Mat4 m_matrix
 matrix transformation More...
 
Mat4 m_transposeMatrix
 transpose matrix transformation More...
 
Mat4 m_inverseMatrix
 inverse matrix transformation More...
 

Friends

class Vec4
 

Detailed Description

Transformation describes a transformation (translate, scale, rotation) modifed by j macey and included into NGL.

Author
Vincent Bonnet
Version
1.5
Date
14/03/10 Last Revision 14/03/10

Definition at line 43 of file Transformation.h.

Constructor & Destructor Documentation

ngl::Transformation::Transformation ( )
noexcept

Constructor.

Definition at line 27 of file Transformation.cpp.

References computeMatrices(), m_inverseMatrix, m_isMatrixComputed, m_matrix, m_position, m_rotation, m_scale, and m_transposeMatrix.

+ Here is the call graph for this function:

ngl::Transformation::Transformation ( const Transformation _t)
noexcept

Copy Constructor.

Definition at line 40 of file Transformation.cpp.

References m_inverseMatrix, m_isMatrixComputed, m_matrix, m_position, m_rotation, m_scale, and m_transposeMatrix.

Member Function Documentation

void ngl::Transformation::addPosition ( const Vec4 _position)
noexcept

method add to the existing set the position

Parameters
[in]_positionposition
void ngl::Transformation::addPosition ( const Vec3 _position)
noexcept

method add to the existing set the position

Parameters
[in]_positionposition

Definition at line 132 of file Transformation.cpp.

References m_isMatrixComputed, and m_position.

void ngl::Transformation::addPosition ( Real  _x,
Real  _y,
Real  _z 
)
noexcept

method to add to the existing position value in the transform

Parameters
[in]_xx position value
[in]_yy position value
[in]_zz position value

Definition at line 137 of file Transformation.cpp.

References m_isMatrixComputed, m_position, ngl::Vec3::m_x, ngl::Vec3::m_y, and ngl::Vec3::m_z.

void ngl::Transformation::addRotation ( const Vec3 _rotation)
noexcept

method to add to the existing rotation

Parameters
[in]_rotationrotation
Note
each value is an axis rotation as the values are calculated mRotationX * mRotationY * mRotationZ;

Definition at line 169 of file Transformation.cpp.

References m_isMatrixComputed, and m_rotation.

void ngl::Transformation::addRotation ( Real  _x,
Real  _y,
Real  _z 
)
noexcept

method to add to the existing rotation value in the transform

Note
each value is an axis rotation as the values are calculated mRotationX * mRotationY * mRotationZ;
Parameters
[in]_xx rotation value
[in]_yy rotation value
[in]_zz rotation value

Definition at line 174 of file Transformation.cpp.

References m_isMatrixComputed, m_rotation, ngl::Vec3::m_x, ngl::Vec3::m_y, and ngl::Vec3::m_z.

void ngl::Transformation::addScale ( const Vec3 _scale)
noexcept

method to add to the existing the scale value in the transform

Parameters
[in]_scalethe scale value to set for the transform

Definition at line 98 of file Transformation.cpp.

References m_isMatrixComputed, and m_scale.

void ngl::Transformation::addScale ( Real  _x,
Real  _y,
Real  _z 
)
noexcept

method to add to the existing the scale value in the transform

Parameters
[in]_xx scale value
[in]_yy scale value
[in]_zz scale value

Definition at line 105 of file Transformation.cpp.

References m_isMatrixComputed, m_scale, ngl::Vec3::m_x, ngl::Vec3::m_y, and ngl::Vec3::m_z.

void ngl::Transformation::computeMatrices ( )
protectednoexcept

method to compute the matrix, transpose and inverse matrix. set the m_bIsMatrixComputed variable to true.

Definition at line 194 of file Transformation.cpp.

References m_inverseMatrix, m_isMatrixComputed, ngl::Mat4::m_m, m_matrix, m_position, m_rotation, m_scale, m_transposeMatrix, ngl::Vec3::m_x, ngl::Vec3::m_y, ngl::Vec3::m_z, ngl::Mat4::rotateX(), ngl::Mat4::rotateY(), ngl::Mat4::rotateZ(), ngl::Mat4::scale(), ngl::Mat4::translate(), and ngl::Mat4::transpose().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Mat4 ngl::Transformation::getInverseMatrix ( )
inlinenoexcept

function to get the inverse matrix. It computes the inverse matrix if it's dirty

Returns
the inverse matrix

Definition at line 192 of file Transformation.h.

References ngl::NORMAL, and ngl::operator*().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Mat4 ngl::Transformation::getMatrix ( )
inlinenoexcept

function to get the matrix. It computes the matrix if it's dirty

Returns
the matrix

Definition at line 182 of file Transformation.h.

+ Here is the caller graph for this function:

Vec3 ngl::Transformation::getPosition ( ) const
inlinenoexcept

function to get the position

Returns
the position

Definition at line 172 of file Transformation.h.

+ Here is the caller graph for this function:

Vec3 ngl::Transformation::getRotation ( ) const
inlinenoexcept

function to get the rotation

Returns
the rotation

Definition at line 177 of file Transformation.h.

+ Here is the caller graph for this function:

Vec3 ngl::Transformation::getScale ( ) const
inlinenoexcept

function to get the scale

Returns
the scale

Definition at line 167 of file Transformation.h.

+ Here is the caller graph for this function:

Mat4 ngl::Transformation::getTransposeMatrix ( )
inlinenoexcept

function to get the transpose matrix. It computes the transpose matrix if it's dirty

Returns
the transpose matrix

Definition at line 187 of file Transformation.h.

+ Here is the caller graph for this function:

void ngl::Transformation::loadGlobalAndCurrentMatrixToShader ( const std::string _param,
Transformation _global,
const ActiveMatrix _which = ActiveMatrix::NORMAL 
)
noexcept

load the current * global transform matrix to the shader

Parameters
[in]_paramthe name of the parameter to set (varying mat4)
[in]_whichwhich matrix mode to use

Definition at line 294 of file Transformation.cpp.

References computeMatrices(), getInverseMatrix(), getMatrix(), getTransposeMatrix(), ngl::Singleton< ShaderLib >::instance(), ngl::INVERSE, ngl::NORMAL, ngl::ShaderLib::setShaderParamFromMat4(), and ngl::TRANSPOSE.

+ Here is the call graph for this function:

void ngl::Transformation::loadMatrixToShader ( const std::string _param,
const ActiveMatrix _which = ActiveMatrix::NORMAL 
)
noexcept

load the current transform matrix to the shader

Parameters
[in]_paramthe name of the parameter to set (varying mat4)
[in]_whichwhich matrix mode to use

Definition at line 267 of file Transformation.cpp.

References computeMatrices(), ngl::Singleton< ShaderLib >::instance(), ngl::INVERSE, m_inverseMatrix, m_matrix, m_transposeMatrix, ngl::NORMAL, ngl::ShaderLib::setShaderParamFromMat4(), and ngl::TRANSPOSE.

+ Here is the call graph for this function:

Transformation ngl::Transformation::operator* ( const Transformation _m)
noexcept

operator for Transform multiplication will do a matrix multiplication on each of the matrices

Note
this is not const as we need to check that the members are calculated before we do the multiplication. This is deliberate
Parameters
[in]_mthe Transform to multiply the current one by
Returns
all the transform matrix members * my _m members

Definition at line 256 of file Transformation.cpp.

References computeMatrices(), m_inverseMatrix, m_isMatrixComputed, m_matrix, and m_transposeMatrix.

+ Here is the call graph for this function:

void ngl::Transformation::operator*= ( const Transformation _m)
noexcept

*= operator

Parameters
_mthe transformation to combine

transpose matrix transformation

inverse matrix transformation

Definition at line 242 of file Transformation.cpp.

References computeMatrices(), m_inverseMatrix, m_isMatrixComputed, m_matrix, and m_transposeMatrix.

+ Here is the call graph for this function:

Transformation & ngl::Transformation::operator= ( const Transformation _t)
noexcept

assignment operator

Definition at line 53 of file Transformation.cpp.

References m_inverseMatrix, m_isMatrixComputed, m_matrix, m_position, m_rotation, m_scale, and m_transposeMatrix.

void ngl::Transformation::reset ( )
noexcept

a method to set all the transforms to the identity

Definition at line 184 of file Transformation.cpp.

References computeMatrices(), m_isMatrixComputed, m_position, m_rotation, and m_scale.

+ Here is the call graph for this function:

void ngl::Transformation::setMatrix ( const Mat4 _m)
noexcept

method to set the matrix directly

Parameters
[in]_mthe matrix to set the m_transform to need to also re-compute the others

Definition at line 70 of file Transformation.cpp.

References m_isMatrixComputed, m_matrix, m_transposeMatrix, and ngl::Mat4::transpose().

+ Here is the call graph for this function:

void ngl::Transformation::setPosition ( const Vec4 _position)
noexcept

method to set the position

Parameters
[in]_positionposition

Definition at line 115 of file Transformation.cpp.

References m_isMatrixComputed, and m_position.

void ngl::Transformation::setPosition ( const Vec3 _position)
noexcept

method to set the position

Parameters
[in]_positionposition

Definition at line 120 of file Transformation.cpp.

References m_isMatrixComputed, and m_position.

void ngl::Transformation::setPosition ( Real  _x,
Real  _y,
Real  _z 
)
noexcept

method to set the position value in the transform

Parameters
[in]_xx position value
[in]_yy position value
[in]_zz position value

Definition at line 125 of file Transformation.cpp.

References m_isMatrixComputed, m_position, and ngl::Vec3::set().

+ Here is the call graph for this function:

void ngl::Transformation::setRotation ( const Vec3 _rotation)
noexcept

method to set the rotation

Parameters
[in]_rotationrotation
Note
each value is an axis rotation as the values are calculated mRotationX * mRotationY * mRotationZ;

Definition at line 148 of file Transformation.cpp.

References m_isMatrixComputed, and m_rotation.

void ngl::Transformation::setRotation ( const Vec4 _rotation)
noexcept

Definition at line 153 of file Transformation.cpp.

References m_isMatrixComputed, and m_rotation.

void ngl::Transformation::setRotation ( Real  _x,
Real  _y,
Real  _z 
)
noexcept

method to set the rotation value in the transform

Note
each value is an axis rotation as the values are calculated mRotationX * mRotationY * mRotationZ;
Parameters
[in]_xx rotation value
[in]_yy rotation value
[in]_zz rotation value

Definition at line 160 of file Transformation.cpp.

References m_isMatrixComputed, m_rotation, and ngl::Vec3::set().

+ Here is the call graph for this function:

void ngl::Transformation::setScale ( const Vec3 _scale)
noexcept

method to set the scale value in the transform

Parameters
[in]_scalethe scale value to set for the transform

Definition at line 79 of file Transformation.cpp.

References m_isMatrixComputed, and m_scale.

void ngl::Transformation::setScale ( const Vec4 _scale)
noexcept

Definition at line 85 of file Transformation.cpp.

References m_isMatrixComputed, and m_scale.

void ngl::Transformation::setScale ( Real  _x,
Real  _y,
Real  _z 
)
noexcept

method to set the scale value in the transform

Parameters
[in]_xx scale value
[in]_yy scale value
[in]_zz scale value

Definition at line 91 of file Transformation.cpp.

References m_isMatrixComputed, m_scale, and ngl::Vec3::set().

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend class Vec4
friend

Definition at line 45 of file Transformation.h.

Member Data Documentation

Mat4 ngl::Transformation::m_inverseMatrix
protected

inverse matrix transformation

Definition at line 249 of file Transformation.h.

bool ngl::Transformation::m_isMatrixComputed
protected

boolean defines if the matrix is dirty or not

Definition at line 237 of file Transformation.h.

Mat4 ngl::Transformation::m_matrix
protected

matrix transformation

Definition at line 241 of file Transformation.h.

Vec3 ngl::Transformation::m_position
protected

position

Definition at line 225 of file Transformation.h.

Vec3 ngl::Transformation::m_rotation
protected

rotation

Definition at line 233 of file Transformation.h.

Vec3 ngl::Transformation::m_scale
protected

scale

Definition at line 229 of file Transformation.h.

Mat4 ngl::Transformation::m_transposeMatrix
protected

transpose matrix transformation

Definition at line 245 of file Transformation.h.


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