![]() |
ezEngine Release 26.3
|
Represents position, rotation and scaling using separate components for efficient hierarchical transformations. More...
#include <Transform.h>
Public Member Functions | |
| EZ_DECLARE_POD_TYPE () | |
| ezTransformTemplate ()=default | |
| Default constructor: Does not do any initialization. | |
| ezTransformTemplate (const ezVec3Template< Type > &vPosition, const ezQuatTemplate< Type > &qRotation=ezQuatTemplate< Type >::MakeIdentity(), const ezVec3Template< Type > &vScale=ezVec3Template< Type >(1)) | |
| Initializes the transform from the given position, rotation and scale. | |
| void | SetIdentity () |
| Sets the position to be zero and the rotation to identity. | |
| Type | GetMaxScale () const |
| Returns the scale component with maximum magnitude. | |
| bool | HasMirrorScaling () const |
| Returns whether this transform contains negative scaling aka mirroring. | |
| bool | HasOnlyUniformScaling () const |
| Returns whether this transform contains only uniform scaling (including scale == 1). | |
| bool | IsValid () const |
| Checks that all components are valid (no NaN, only finite numbers). | |
| bool | IsIdentical (const ezTransformTemplate &rhs) const |
| Equality Check (bitwise) | |
| bool | IsEqual (const ezTransformTemplate &rhs, Type fEpsilon) const |
| Equality Check with epsilon. | |
| void | Invert () |
| Inverts this transform. | |
| const ezTransformTemplate | GetInverse () const |
| Returns the inverse of this transform. | |
| ezVec3Template< Type > | TransformPosition (const ezVec3Template< Type > &v) const |
| Transforms a position vector by this transform (applies scale, rotation, and translation). | |
| ezVec3Template< Type > | TransformDirection (const ezVec3Template< Type > &v) const |
| Transforms a direction vector by this transform (applies scale and rotation, but not translation). | |
| void | operator+= (const ezVec3Template< Type > &v) |
| Translates the transform by the given vector in global space. | |
| void | operator-= (const ezVec3Template< Type > &v) |
| Translates the transform by the negative of the given vector in global space. | |
| const ezMat4Template< Type > | GetAsMat4 () const |
| Returns the transformation as a matrix. | |
Static Public Member Functions | |
| static ezTransformTemplate< Type > | Make (const ezVec3Template< Type > &vPosition, const ezQuatTemplate< Type > &qRotation=ezQuatTemplate< Type >::MakeIdentity(), const ezVec3Template< Type > &vScale=ezVec3Template< Type >(1)) |
| Creates a transform from the given position, rotation and scale. | |
| static ezTransformTemplate< Type > | MakeIdentity () |
| Creates an identity transform. | |
| static ezTransformTemplate< Type > | MakeFromMat4 (const ezMat4Template< Type > &mMat) |
| Creates a transform from the given matrix using decomposition. | |
| static ezTransformTemplate< Type > | MakeLocalTransform (const ezTransformTemplate &globalTransformParent, const ezTransformTemplate &globalTransformChild) |
| Creates a transform that is the local transformation needed to get from the parent's transform to the child's. | |
| static ezTransformTemplate< Type > | MakeGlobalTransform (const ezTransformTemplate &globalTransformParent, const ezTransformTemplate &localTransformChild) |
| Creates a transform that is the global transform, that is reached by applying the child's local transform to the parent's global one. | |
Public Attributes | |
| ezVec3Template< Type > | m_vPosition |
| ezQuatTemplate< Type > | m_qRotation |
| ezVec3Template< Type > | m_vScale |
Represents position, rotation and scaling using separate components for efficient hierarchical transformations.
Transform operations follow the order: Scale → Rotation → Translation (SRT). This ensures that scale and rotation are applied in local space, while translation occurs in global space. This makes the translation component represent the global center position around which objects rotate.
Hierarchical transformation support:
Limitations:
Performance characteristics:
| EZ_ALWAYS_INLINE bool ezTransformTemplate< Type >::HasMirrorScaling | ( | ) | const |
Returns whether this transform contains negative scaling aka mirroring.
Checks if any scale component is negative, which indicates mirroring along that axis. Important for correct normal vector transformations and culling operations.
| EZ_ALWAYS_INLINE bool ezTransformTemplate< Type >::HasOnlyUniformScaling | ( | ) | const |
Returns whether this transform contains only uniform scaling (including scale == 1).
Returns true if all three scale components have the same absolute value.
|
static |
Creates a transform from the given matrix using decomposition.
Attempts to decompose the matrix into separate translation, rotation, and scale components. The operation always succeeds but may produce unexpected results with invalid matrices.
|
static |
Creates a transform that is the global transform, that is reached by applying the child's local transform to the parent's global one.
Computes: globalTransform = globalTransformParent * localTransformChild
|
static |
Creates a transform that is the local transformation needed to get from the parent's transform to the child's.
Computes: localTransform = inverse(globalTransformParent) * globalTransformChild