Class Transform
Transform metatype, wrapper for godot_transform.
Constructed using the idiom Transform(...), which calls __new.
typedef union godot_transform {
uint8_t data[48];
float elements[12];
struct { Basis basis; Vector3 origin; };
} godot_transform;
Methods
| Transform:affine_inverse () | Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation. |
| Transform:inverse () | Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use affine_inverse for transforms with scaling). |
| Transform:looking_at (target, up) | Returns a copy of the transform rotated such that its -Z axis points towards the target position. |
| Transform:orthonormalized () | Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors. |
| Transform:rotated (axis, angle) | Rotates the transform around the given axis by the given angle (in radians), using matrix multiplication. |
| Transform:scaled (scale) | Scales basis and origin of the transform by the given scale factor, using matrix multiplication. |
| Transform:treturn (offset) | Translates the transform by the given offset, relative to the transform's basis vectors. |
| Transform:xform (value) | Transforms the given Vector3, Plane, AABB, or PoolVector3Array by this transform. |
| Transform:xform_aabb (aabb) | Transforms the given AABB |
| Transform:xform_inv (value) | Inverse-transforms the given Vector3, Plane, AABB, or PoolVector3Array by this transform. |
| Transform:xform_inv_aabb (aabb) | Inverse-transforms the given AABB |
| Transform:xform_inv_plane (plane) | Inverse-transforms the given Plane |
| Transform:xform_inv_vector3 (vector) | Inverse-transforms the given Vector3 |
| Transform:xform_plane (plane) | Transforms the given Plane |
| Transform:xform_vector3 (vector) | Transforms the given Vector3 |
Metamethods
| Transform:__concat (a, b) | Concatenates values. |
| Transform:__eq (a, b) | Equality operation
If either a or b are not of type Transform, always return false. |
| Transform:__mul (self, b) | Multiplication operation. |
| Transform:__new (...) | Transform constructor, called by the idiom Transform(...). |
| Transform:__tostring () | Returns a Lua string representation of this transform. |
Constants
| Transform.FLIP_X | Transform with mirroring applied perpendicular to the YZ plane. |
| Transform.FLIP_Y | Transform with mirroring applied perpendicular to the XZ plane. |
| Transform.FLIP_Z | Transform with mirroring applied perpendicular to the XY plane. |
| Transform.IDENTITY | Transform with no translation, rotation or scaling applied. |
Methods
- Transform:affine_inverse ()
-
Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation.
Returns:
- Transform:inverse ()
-
Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use affine_inverse for transforms with scaling).
Returns:
- Transform:looking_at (target, up)
-
Returns a copy of the transform rotated such that its -Z axis points towards the
targetposition. The transform will first be rotated around the given up vector, and then fully aligned to thetargetby a further rotation around an axis perpendicular to both thetargetandupvectors. Operations take place in global space.Parameters:
Returns:
- Transform:orthonormalized ()
-
Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors.
Returns:
- Transform:rotated (axis, angle)
-
Rotates the transform around the given
axisby the givenangle(in radians), using matrix multiplication. The axis must be a normalized vector.Parameters:
- axis Vector3
- angle number
Returns:
- Transform:scaled (scale)
-
Scales basis and origin of the transform by the given
scalefactor, using matrix multiplication.Parameters:
- scale Vector3
Returns:
- Transform:treturn (offset)
-
Translates the transform by the given
offset, relative to the transform's basis vectors. Unlike rotated and scaled, this does not use matrix multiplication.Parameters:
- offset Vector3
Returns:
- Transform:xform (value)
-
Transforms the given Vector3, Plane, AABB, or PoolVector3Array by this transform.
Parameters:
- value Vector3, Plane, AABB or PoolVector3Array
Returns:
-
Vector3, Plane, AABB or PoolVector3Array
Transformed value
- Transform:xform_aabb (aabb)
-
Transforms the given AABB
Parameters:
- aabb AABB
Returns:
See also:
- Transform:xform_inv (value)
-
Inverse-transforms the given Vector3, Plane, AABB, or PoolVector3Array by this transform.
Parameters:
- value Vector3, Plane, AABB or PoolVector3Array
Returns:
-
Vector3, Plane, AABB or PoolVector3Array
Transformed value
- Transform:xform_inv_aabb (aabb)
-
Inverse-transforms the given AABB
Parameters:
- aabb AABB
Returns:
See also:
- Transform:xform_inv_plane (plane)
-
Inverse-transforms the given Plane
Parameters:
- plane Plane
Returns:
See also:
- Transform:xform_inv_vector3 (vector)
-
Inverse-transforms the given Vector3
Parameters:
- vector Vector3
Returns:
See also:
- Transform:xform_plane (plane)
-
Transforms the given Plane
Parameters:
- plane Plane
Returns:
See also:
- Transform:xform_vector3 (vector)
-
Transforms the given Vector3
Parameters:
- vector Vector3
Returns:
See also:
Metamethods
- Transform:__concat (a, b)
-
Concatenates values.
Parameters:
Returns:
- Transform:__eq (a, b)
-
Equality operation
If either
aorbare not of type Transform, always returnfalse.Parameters:
Returns:
-
bool
- Transform:__mul (self, b)
-
Multiplication operation.
Either multiply another Transform or xform value.
Parameters:
Returns:
-
Transform, Vector3, Plane, AABB or PoolVector3Array
Transformed value
- Transform:__new (...)
-
Transform constructor, called by the idiom
Transform(...).Transform(): IDENTITY transformTransform(Basis basis[, Vector3 origin = Vector3.ZERO]): setbasisandoriginTransform(Quat quat[, Vector3 origin = Vector3.ZERO]): setbasisfrom quaternion andoriginTransform(Vector3 euler[, Vector3 origin = Vector3.ZERO]): setbasisfrom Euler angles andoriginTransform(Vector3 x, Vector3 y, Vector3 z, Vector3 origin): constructs the transform from the four column vectors.Transform(Transform other): returns a copy ofother
Parameters:
- ...
Returns:
- Transform:__tostring ()
-
Returns a Lua string representation of this transform.
Returns:
Constants
- Transform.FLIP_X
-
Transform with mirroring applied perpendicular to the YZ plane.
- FLIP_X Transform(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
- Transform.FLIP_Y
-
Transform with mirroring applied perpendicular to the XZ plane.
- FLIP_Y Transform(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0)
- Transform.FLIP_Z
-
Transform with mirroring applied perpendicular to the XY plane.
- FLIP_Z Transform(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0)
- Transform.IDENTITY
-
Transform with no translation, rotation or scaling applied.
- IDENTITY Transform(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)