ezEngine  Milestone 7
ezTransformTemplate< Type > Class Template Reference

A class that represents a complete position, rotation and scaling through an ezVec3Template<Type> and an ezMat3Template<Type>. More...

#include <Transform.h>

Public Member Functions

void GetAsArray (Type *out_pData, ezMatrixLayout::Enum layout) const
 Copies the 12 values of this matrix into the given array. 'layout' defines whether the data should end up in column-major or row-major format.
 
 ezTransformTemplate ()
 Default constructor: Does not do any initialization.
 
 ezTransformTemplate (const ezVec3Template< Type > &vPosition, const ezMat3Template< Type > &Rotation)
 Sets position and rotation matrix, which might include scale as well.
 
 ezTransformTemplate (const ezVec3Template< Type > &vPosition, const ezQuatTemplate< Type > &qRotation=ezQuatTemplate< Type >::IdentityQuaternion())
 Sets position and rotation.
 
 ezTransformTemplate (const ezVec3Template< Type > &vPosition, const ezQuatTemplate< Type > &qRotation, const ezVec3Template< Type > &vScale)
 Sets position, rotation and scale.
 
void SetIdentity ()
 Sets the position to be zero and the rotation to identity.
 
bool IsIdentical (const ezTransformTemplate &rhs) const
 Equality Check (bitwise)
 
bool IsEqual (const ezTransformTemplate &rhs, Type fEpsilon) const
 Equality Check with epsilon.
 
ezResult Invert (Type fEpsilon=ezMath::BasicType< Type >::SmallEpsilon())
 Inverts this transform. Return value indicates whether it could be Inverted.
 
const ezTransformTemplate GetInverse () const
 Returns the inverse of this transform.
 
void SetLocalTransform (const ezTransformTemplate &GlobalTransformParent, const ezTransformTemplate &GlobalTransformChild)
 Sets this transform to be the local transformation needed to get from the parent's transform to the child's.
 
void SetGlobalTransform (const ezTransformTemplate &GlobalTransformParent, const ezTransformTemplate &LocalTransformChild)
 Sets this transform to the global transform, that is reached by applying the child's local transform to the parent's global one.
 
const ezMat4Template< Type > GetAsMat4 () const
 Returns the transformation as a matrix.
 
void Decompose (ezVec3 &vPos, ezQuat &qRot, ezVec3 &vScale) const
 Extracts the different transformation parts and returns them. More...
 
void operator*= (const ezQuatTemplate< Type > &q)
 Multiplies q into the rotation component, thus rotating the entire transformation.
 

Public Attributes

ezMat3Template< Type > m_Rotation
 
ezVec3Template< Type > m_vPosition
 

Detailed Description

template<typename Type>
class ezTransformTemplate< Type >

A class that represents a complete position, rotation and scaling through an ezVec3Template<Type> and an ezMat3Template<Type>.

The rotation is applied first and then the translation is added. Thus the rotation component is always in 'local space', i.e. applying a rotation to the ezTransformTemplate will rotate objects in place around their local center. Since the translation is added afterwards, the translation component is always the global center position, around which objects also rotate.

The functions SetLocalTransform() and SetGlobalTransform() allow to create transforms that either represent the full global transformation of an object, factoring its parent's transform in, or the local transformation that will get you from the parent's global transformation to the current global transformation of a child (i.e. only the difference). This is particularly useful when editing entities in a hierarchical structure.

Since the 'm_Rotation' member is a full ezMat3Template<Type>, it may also contain scaling, including non-uniform scaling and shearing.

Member Function Documentation

template<typename Type >
void ezTransformTemplate< Type >::Decompose ( ezVec3 vPos,
ezQuat qRot,
ezVec3 vScale 
) const
inline

Extracts the different transformation parts and returns them.

Test:
This is new
Todo:
Can we make this more efficient? E.g. ezQuat::SetFromScaledMat3 ?

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