Class Transform3D
3D transform component for scene objects ( Camera ,Light ,Mesh ).More...
#include <Transform.h>
Inherits the following classes: Transform
Inherited by the following classes: Camera, DebugLine, DebugPoints, Empty, Environment, Field, ImagePlane, Light, Mesh, PolygonLight, SDFField
Public Types inherited from Transform
See Transform
| Type | Name |
|---|---|
| enum | TransType Flags for enabling/disabling transform components. |
Public Attributes
| Type | Name |
|---|---|
| glm::mat4 | o_InvTransform = { 1.0f }Cached inverse world transform matrix. |
| glm::mat4 | o_Transform = { 1.0f }Cached world transform matrix. |
| glm::vec3 | o_dir_right = { 1.0f, 0.0f, 0.0f }Right direction vector (X+) |
| glm::vec3 | o_dir_up = { 0.0f, 1.0f, 0.0f }Up direction vector (Y+) |
| glm::vec3 | o_position = { 0.0f }World position. |
| glm::vec3 | o_rot = { 0.0f }Euler rotation angles (radians): pitch, yaw, roll. |
| glm::vec3 | o_scale = { 1.0f }Local scale (non-uniform allowed) |
Public Attributes inherited from Transform
See Transform
| Type | Name |
|---|---|
| bool | is_TransF_changed = trueTransform matrix needs recomputation. |
| bool | is_Uniform_changed = trueUniform (non-scaled) transform needs recomputation. |
| bool | is_invTransF_changed = trueInverse transform needs recomputation. |
| bool | is_invUniform_changed = trueInverse uniform transform needs recomputation. |
| bool | use_position = { true }Enable position component in transform computation. |
| bool | use_rotation = { true }Enable rotation component in transform computation. |
| bool | use_scale = { true }Enable scale component in transform computation. |
Public Functions
| Type | Name |
|---|---|
| virtual bool | ApplyAllTransform () override Recomputes transform and all parent transforms. |
| virtual bool | ApplyTransform (bool _forced=false) override Recomputes transform matrix if dirty. |
| Transform3D * | GetChildTransPtr () Returns pointer to first child transform. |
| virtual bool | GetInvTransform () override const Computes inverse transform matrix. |
| Transform3D * | GetParentTransPtr () Returns pointer to parent transform. |
| Transform3D * | GetTransformPtr () Returns pointer to this transform. |
| void | LookAt (const glm::vec3 & tar, const glm::vec3 & up={0, 0, 1}) Orients transform to look at target position. |
| void | Move (const glm::vec3 & d_pos) Translates position by offset. |
| void | SetParent (Transform3D * _p_trans, bool _keep_offset=true) Sets parent transform for hierarchy. |
| bool | SetPos (const glm::vec3 & pos) Sets world position. |
| bool | SetPos1D (float _1d, GLuint _dim) Sets single axis of position. |
| bool | SetRot (const glm::vec3 & rot) Sets rotation via Euler angles. |
| bool | SetRot1D (float _1d, GLuint _dim) Sets single axis of rotation. |
| bool | SetScale (const glm::vec3 & scale) Sets local scale. |
| bool | SetScale1D (float _1d, GLuint _dim) Sets single axis of scale. |
| bool | SetTrans (const glm::mat4 & _trans, bool pos=true, bool rot=true, bool scl=true) Sets transform from 4x4 matrix. |
| void | Spin (const glm::vec3 & anch, const glm::vec3 & axis, const float & angle) Rotates around arbitrary axis through anchor point. |
| void | Spin (const glm::vec3 & anch, const glm::vec2 & angle, bool global_up=true) Rotates around anchor with pitch/yaw. |
| void | Trans (const glm::mat4 & _trans) Applies transformation matrix to current transform. |
| Transform3D () Constructs a Transform3D with identity values. |
|
| virtual void | UnsetParent (bool _keep_offset=true) override Removes parent transform relationship. |
| virtual int | _debug () override const Debug utility for transform state inspection. |
| ~Transform3D () Destroys the Transform3D . |
Public Functions inherited from Transform
See Transform
| Type | Name |
|---|---|
| virtual bool | ApplyAllTransform () = 0 Recomputes transform and all parent transforms. |
| virtual bool | ApplyTransform (bool _forced=false) = 0 Recomputes transform matrix if dirty. |
| virtual bool | GetInvTransform () const = 0 Computes inverse transform matrix. |
| virtual void | UnsetParent (bool _keep_offset=true) = 0 Removes parent transform relationship. |
| void | UseTranformComp (bool _enable, TransType _type) Enables or disables specific transform components. |
| virtual int | _debug () const = 0 Debug utility for transform state inspection. |
Detailed Description
Transform3D provides position, rotation (Euler angles), and scale in 3D space. Supports hierarchical parent-child relationships for skeletal animation and scene graph organization. Transform matrices are cached and recomputed lazily using dirty flags.
Coordinate System: * Right-handed coordinate system (OpenGL convention) * Rotation order: pitch (X), yaw (Y), roll (Z) * Direction vectors: up (Y+), right (X+), forward (Z-)
Transform Composition: * Local transform = Translate * Rotate * Scale * World transform = Parent * Local
Note:
Mutable members support const correctness while caching computed matrices.
Note:
Parent-child pointers are non-owning (scene graph owns objects).
Public Attributes Documentation
variable o_InvTransform
Cached inverse world transform matrix.
glm::mat4 Transform3D::o_InvTransform;
variable o_Transform
Cached world transform matrix.
glm::mat4 Transform3D::o_Transform;
variable o_dir_right
Right direction vector (X+)
glm::vec3 Transform3D::o_dir_right;
variable o_dir_up
Up direction vector (Y+)
glm::vec3 Transform3D::o_dir_up;
variable o_position
World position.
glm::vec3 Transform3D::o_position;
variable o_rot
Euler rotation angles (radians): pitch, yaw, roll.
glm::vec3 Transform3D::o_rot;
variable o_scale
Local scale (non-uniform allowed)
glm::vec3 Transform3D::o_scale;
Public Functions Documentation
function ApplyAllTransform
Recomputes transform and all parent transforms.
virtual bool Transform3D::ApplyAllTransform () override
Returns:
True if any recomputation occurred
Implements Transform::ApplyAllTransform
function ApplyTransform
Recomputes transform matrix if dirty.
virtual bool Transform3D::ApplyTransform (
bool _forced=false
) override
Parameters:
_forcedIf true, recompute even if not dirty
Returns:
True if recomputation occurred
Implements Transform::ApplyTransform
function GetChildTransPtr
Returns pointer to first child transform.
inline Transform3D * Transform3D::GetChildTransPtr ()
Returns:
Non-owning pointer to child Transform3D, or nullptr if no children
function GetInvTransform
Computes inverse transform matrix.
virtual bool Transform3D::GetInvTransform () override const
Returns:
True if inverse was recomputed
Implements Transform::GetInvTransform
function GetParentTransPtr
Returns pointer to parent transform.
inline Transform3D * Transform3D::GetParentTransPtr ()
Returns:
Non-owning pointer to parent Transform3D, or nullptr if no parent
function GetTransformPtr
Returns pointer to this transform.
inline Transform3D * Transform3D::GetTransformPtr ()
Returns:
Non-owning pointer to Transform3D
function LookAt
Orients transform to look at target position.
void Transform3D::LookAt (
const glm::vec3 & tar,
const glm::vec3 & up={0, 0, 1}
)
Parameters:
tarTarget position to faceupUp vector for orientation (default: Z+)
function Move
Translates position by offset.
void Transform3D::Move (
const glm::vec3 & d_pos
)
Parameters:
d_posDelta position to add
function SetParent
Sets parent transform for hierarchy.
void Transform3D::SetParent (
Transform3D * _p_trans,
bool _keep_offset=true
)
Parameters:
_p_transPointer to new parent transform_keep_offsetIf true, maintains world position; if false, becomes local to parent
function SetPos
Sets world position.
bool Transform3D::SetPos (
const glm::vec3 & pos
)
Parameters:
posNew position in world space
Returns:
True if position changed
function SetPos1D
Sets single axis of position.
bool Transform3D::SetPos1D (
float _1d,
GLuint _dim
)
Parameters:
_1dNew value for specified axis_dimAxis dimension (0=X, 1=Y, 2=Z)
Returns:
True if position changed
function SetRot
Sets rotation via Euler angles.
bool Transform3D::SetRot (
const glm::vec3 & rot
)
Parameters:
rotNew rotation (pitch, yaw, roll) in radians
Returns:
True if rotation changed
function SetRot1D
Sets single axis of rotation.
bool Transform3D::SetRot1D (
float _1d,
GLuint _dim
)
Parameters:
_1dNew rotation value in radians_dimAxis dimension (0=pitch, 1=yaw, 2=roll)
Returns:
True if rotation changed
function SetScale
Sets local scale.
bool Transform3D::SetScale (
const glm::vec3 & scale
)
Parameters:
scaleNew scale (per-axis)
Returns:
True if scale changed
function SetScale1D
Sets single axis of scale.
bool Transform3D::SetScale1D (
float _1d,
GLuint _dim
)
Parameters:
_1dNew value for specified axis_dimAxis dimension (0=X, 1=Y, 2=Z)
Returns:
True if scale changed
function SetTrans
Sets transform from 4x4 matrix.
bool Transform3D::SetTrans (
const glm::mat4 & _trans,
bool pos=true,
bool rot=true,
bool scl=true
)
Parameters:
_transSource transformation matrixposExtract position component (default: true)rotExtract rotation component (default: true)sclExtract scale component (default: true)
Returns:
True if any component changed
function Spin [1/2]
Rotates around arbitrary axis through anchor point.
void Transform3D::Spin (
const glm::vec3 & anch,
const glm::vec3 & axis,
const float & angle
)
Parameters:
anchAnchor point (rotation center)axisRotation axis (normalized)angleRotation angle in radians
function Spin [2/2]
Rotates around anchor with pitch/yaw.
void Transform3D::Spin (
const glm::vec3 & anch,
const glm::vec2 & angle,
bool global_up=true
)
Parameters:
anchAnchor point (rotation center)anglePitch (X) and yaw (Y) angles in radiansglobal_upUse global up vector (Y+) vs. local up (default: true)
function Trans
Applies transformation matrix to current transform.
void Transform3D::Trans (
const glm::mat4 & _trans
)
Parameters:
_transTransformation to apply
Note:
Multiplies current transform: Transform = Transform * _trans
function Transform3D
Constructs a Transform3D with identity values.
Transform3D::Transform3D ()
function UnsetParent
Removes parent transform relationship.
virtual void Transform3D::UnsetParent (
bool _keep_offset=true
) override
Parameters:
_keep_offsetIf true, maintains world position; if false, resets to origin
Implements Transform::UnsetParent
function _debug
Debug utility for transform state inspection.
virtual int Transform3D::_debug () override const
Returns:
Debug status code
Implements Transform::_debug
function ~Transform3D
Destroys the Transform3D .
Transform3D::~Transform3D ()
The documentation for this class was generated from the following file src/compo/Transform.h