Skip to content

Transform3

A 3D transformation class supporting translation, scaling, and rotation.

Internally manages position, scale, and rotation in Euler angles. Lazily computes the final transformation matrix when accessed.

Properties

position Vector3

cpp
Vector3 position { 0.0f }

World-space translation.

rotation Euler

cpp
Euler rotation

Euler rotation (pitch, yaw, roll).

scale Vector3

cpp
Vector3 scale { 1.0f }

Local scale.

touched bool

cpp
bool touched { true }

Indicates whether the transformation matrix needs to be recomputed.

Functions

Get() auto

cpp
auto vglx::Transform3::Get()

Returns the 4x4 transformation matrix. Lazily recomputes the matrix if any component has changed since last access.

LookAt() auto

cpp
auto vglx::Transform3::LookAt(const Vector3 &position, const Vector3 &target, const Vector3 &world_up)
ParameterDescription
positionPosition of the object.
targetTarget point to look at.
world_upWorld up direction.

Sets the rotation such that the object looks at the given target. Computes the Euler rotation needed to look from position to target, using the given world-up vector to determine orientation.

Rotate() auto

cpp
auto vglx::Transform3::Rotate(const Vector3 &axis, float angle)
ParameterDescription
axisAxis to rotate around (Right, Up, or Forward).
angleRotation angle in radians.

Applies a rotation around a specific axis. Only cardinal axes (X, Y, Z) are supported.

Scale() auto

cpp
auto vglx::Transform3::Scale(const Vector3 &value)
ParameterDescription
valueScale factors to apply.

Applies a scale to the current scale.

SetPosition() auto

cpp
auto vglx::Transform3::SetPosition(const Vector3 &position)
ParameterDescription
positionNew position vector.

Sets the world position of the transform.

SetRotation() auto

cpp
auto vglx::Transform3::SetRotation(const Euler &rotation)
ParameterDescription
rotationNew Euler rotation.

Sets the rotation of the transform.

SetScale() auto

cpp
auto vglx::Transform3::SetScale(const Vector3 &scale)
ParameterDescription
scaleNew scale vector.

Sets the local scale of the transform.

Translate() auto

cpp
auto vglx::Transform3::Translate(const Vector3 &value)
ParameterDescription
valueTranslation vector.

Applies a translation in local space. If rotation is non-zero, the translation is rotated accordingly.

Released under the MIT License.