2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-07-06 08:08:05 +00:00
<class name= "Transform3D" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 20:42:36 +00:00
<brief_description >
2023-04-27 23:35:33 +00:00
A 3× 4 matrix representing a 3D transformation.
2017-09-12 20:42:36 +00:00
</brief_description>
<description >
2024-01-15 11:10:52 +00:00
The [Transform3D] built-in [Variant] type is a 3× 4 matrix representing a transformation in 3D space. It contains a [Basis], which on its own can represent rotation, scale, and shear. Additionally, combined with its own [member origin], the transform can also represent a translation.
2023-12-31 13:04:38 +00:00
For a general introduction, see the [url=$DOCS_URL/tutorials/math/matrices_and_transforms.html]Matrices and transforms[/url] tutorial.
2024-01-15 11:10:52 +00:00
[b]Note:[/b] Godot uses a [url=https://en.wikipedia.org/wiki/Right-hand_rule]right-handed coordinate system[/url], which is a common standard. For directions, the convention for built-in types like [Camera3D] is for -Z to point forward (+X is right, +Y is up, and +Z is back). Other objects may use different direction conventions. For more information, see the [url=$DOCS_URL/tutorials/assets_pipeline/importing_scenes.html#d-asset-direction-conventions]Importing 3D Scenes[/url] tutorial.
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
2021-11-15 09:43:07 +00:00
<link title= "Math documentation index" > $DOCS_URL/tutorials/math/index.html</link>
<link title= "Matrices and transforms" > $DOCS_URL/tutorials/math/matrices_and_transforms.html</link>
<link title= "Using 3D transforms" > $DOCS_URL/tutorials/3d/using_transforms.html</link>
2020-10-01 08:34:47 +00:00
<link title= "Matrix Transform Demo" > https://godotengine.org/asset-library/asset/584</link>
<link title= "3D Platformer Demo" > https://godotengine.org/asset-library/asset/125</link>
<link title= "2.5D Demo" > https://godotengine.org/asset-library/asset/583</link>
2017-09-12 20:42:36 +00:00
</tutorials>
2021-09-21 02:49:02 +00:00
<constructors >
<constructor name= "Transform3D" >
2021-07-30 13:28:05 +00:00
<return type= "Transform3D" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-15 11:10:52 +00:00
Constructs a [Transform3D] identical to the [constant IDENTITY].
2017-09-12 20:42:36 +00:00
</description>
2021-09-21 02:49:02 +00:00
</constructor>
<constructor name= "Transform3D" >
2021-07-30 13:28:05 +00:00
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "from" type= "Transform3D" />
2017-09-12 20:42:36 +00:00
<description >
2020-05-03 08:27:36 +00:00
Constructs a [Transform3D] as a copy of the given [Transform3D].
2017-09-12 20:42:36 +00:00
</description>
2021-09-21 02:49:02 +00:00
</constructor>
<constructor name= "Transform3D" >
2021-07-30 13:28:05 +00:00
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "basis" type= "Basis" />
<param index= "1" name= "origin" type= "Vector3" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-15 11:10:52 +00:00
Constructs a [Transform3D] from a [Basis] and [Vector3].
2017-09-12 20:42:36 +00:00
</description>
2021-09-21 02:49:02 +00:00
</constructor>
<constructor name= "Transform3D" >
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "from" type= "Projection" />
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
<description >
2024-01-15 11:10:52 +00:00
Constructs a [Transform3D] from a [Projection]. Because [Transform3D] is a 3× 4 matrix and [Projection] is a 4× 4 matrix, this operation trims the last row of the projection matrix ([code]from.x.w[/code], [code]from.y.w[/code], [code]from.z.w[/code], and [code]from.w.w[/code] are not included in the new transform).
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
</description>
</constructor>
<constructor name= "Transform3D" >
2021-07-30 13:28:05 +00:00
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "x_axis" type= "Vector3" />
<param index= "1" name= "y_axis" type= "Vector3" />
<param index= "2" name= "z_axis" type= "Vector3" />
<param index= "3" name= "origin" type= "Vector3" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-15 11:10:52 +00:00
Constructs a [Transform3D] from four [Vector3] values (also called matrix columns).
The first three arguments are the [member basis]'s axes ([member Basis.x], [member Basis.y], and [member Basis.z]).
2017-09-12 20:42:36 +00:00
</description>
2021-09-21 02:49:02 +00:00
</constructor>
</constructors>
<methods >
2021-03-18 13:44:42 +00:00
<method name= "affine_inverse" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform3D" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns the inverted version of this transform. Unlike [method inverse], this method works with almost any [member basis], including non-uniform ones, but is slower. See also [method Basis.inverse].
[b]Note:[/b] For this method to return correctly, the transform's [member basis] needs to not have a determinant of exactly [code]0[/code] (see [method Basis.determinant]).
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "interpolate_with" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "xform" type= "Transform3D" />
<param index= "1" name= "weight" type= "float" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns the result of the linear interpolation between this transform and [param xform] by the given [param weight].
The [param weight] should be between [code]0.0[/code] and [code]1.0[/code] (inclusive). Values outside this range are allowed and can be used to perform [i]extrapolation[/i], instead.
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "inverse" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform3D" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns the inverted version of this transform. See also [method Basis.inverse].
[b]Note:[/b] For this method to return correctly, the transform's [member basis] needs to be [i]orthonormal[/i] (see [method Basis.orthonormalized]). That means, the basis should only represent a rotation. If it does not, use [method affine_inverse] instead.
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "is_equal_approx" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "xform" type= "Transform3D" />
2019-11-08 07:33:48 +00:00
<description >
2023-10-02 18:11:43 +00:00
Returns [code]true[/code] if this transform and [param xform] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component.
2019-11-08 07:33:48 +00:00
</description>
</method>
2022-08-11 08:12:27 +00:00
<method name= "is_finite" qualifiers= "const" >
<return type= "bool" />
<description >
Returns [code]true[/code] if this transform is finite, by calling [method @GlobalScope.is_finite] on each component.
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "looking_at" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "target" type= "Vector3" />
<param index= "1" name= "up" type= "Vector3" default= "Vector3(0, 1, 0)" />
2023-04-15 08:01:43 +00:00
<param index= "2" name= "use_model_front" type= "bool" default= "false" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns a copy of this transform rotated so that the forward axis (-Z) points towards the [param target] position.
2022-08-09 15:19:47 +00:00
The up axis (+Y) points as close to the [param up] vector as possible while staying perpendicular to the forward axis. The resulting transform is orthonormalized. The existing rotation, scale, and skew information from the original transform is discarded. The [param target] and [param up] vectors cannot be zero, cannot be parallel to each other, and are defined in global/parent space.
2023-02-07 17:48:33 +00:00
If [param use_model_front] is [code]true[/code], the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the [param target] position. By default, the -Z axis (camera forward) is treated as forward (implies +X is right).
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "orthonormalized" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform3D" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns a copy of this transform with its [member basis] orthonormalized. An orthonormal basis is both [i]orthogonal[/i] (the axes are perpendicular to each other) and [i]normalized[/i] (the axes have a length of [code]1[/code]), which also means it can only represent rotation. See also [method Basis.orthonormalized].
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "rotated" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "axis" type= "Vector3" />
<param index= "1" name= "angle" type= "float" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns a copy of this transform rotated around the given [param axis] by the given [param angle] (in radians).
2022-08-09 15:19:47 +00:00
The [param axis] must be a normalized vector.
2023-03-16 05:56:09 +00:00
This method is an optimized version of multiplying the given transform [code]X[/code] with a corresponding rotation transform [code]R[/code] from the left, i.e., [code]R * X[/code].
2022-07-30 10:17:33 +00:00
This can be seen as transforming with respect to the global/parent frame.
</description>
</method>
<method name= "rotated_local" qualifiers= "const" >
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "axis" type= "Vector3" />
<param index= "1" name= "angle" type= "float" />
2022-07-30 10:17:33 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns a copy of this transform rotated around the given [param axis] by the given [param angle] (in radians).
2022-08-09 15:19:47 +00:00
The [param axis] must be a normalized vector.
2023-03-16 05:56:09 +00:00
This method is an optimized version of multiplying the given transform [code]X[/code] with a corresponding rotation transform [code]R[/code] from the right, i.e., [code]X * R[/code].
2022-07-30 10:17:33 +00:00
This can be seen as transforming with respect to the local frame.
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "scaled" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "scale" type= "Vector3" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns a copy of this transform scaled by the given [param scale] factor.
2023-03-16 05:56:09 +00:00
This method is an optimized version of multiplying the given transform [code]X[/code] with a corresponding scaling transform [code]S[/code] from the left, i.e., [code]S * X[/code].
2022-07-30 10:17:33 +00:00
This can be seen as transforming with respect to the global/parent frame.
</description>
</method>
<method name= "scaled_local" qualifiers= "const" >
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "scale" type= "Vector3" />
2022-07-30 10:17:33 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns a copy of this transform scaled by the given [param scale] factor.
2023-03-16 05:56:09 +00:00
This method is an optimized version of multiplying the given transform [code]X[/code] with a corresponding scaling transform [code]S[/code] from the right, i.e., [code]X * S[/code].
2022-07-30 10:17:33 +00:00
This can be seen as transforming with respect to the local frame.
2017-09-12 20:42:36 +00:00
</description>
</method>
2022-07-30 10:17:33 +00:00
<method name= "translated" qualifiers= "const" >
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "offset" type= "Vector3" />
2022-07-30 10:17:33 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns a copy of this transform translated by the given [param offset].
2023-03-16 05:56:09 +00:00
This method is an optimized version of multiplying the given transform [code]X[/code] with a corresponding translation transform [code]T[/code] from the left, i.e., [code]T * X[/code].
2022-07-30 10:17:33 +00:00
This can be seen as transforming with respect to the global/parent frame.
</description>
</method>
2022-07-16 09:47:54 +00:00
<method name= "translated_local" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "offset" type= "Vector3" />
2017-09-12 20:42:36 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns a copy of this transform translated by the given [param offset].
2023-03-16 05:56:09 +00:00
This method is an optimized version of multiplying the given transform [code]X[/code] with a corresponding translation transform [code]T[/code] from the right, i.e., [code]X * T[/code].
2022-07-30 10:17:33 +00:00
This can be seen as transforming with respect to the local frame.
2017-09-12 20:42:36 +00:00
</description>
</method>
</methods>
<members >
2019-09-24 17:45:03 +00:00
<member name= "basis" type= "Basis" setter= "" getter= "" default= "Basis(1, 0, 0, 0, 1, 0, 0, 0, 1)" >
2024-01-15 11:10:52 +00:00
The [Basis] of this transform. It is composed by 3 axes ([member Basis.x], [member Basis.y], and [member Basis.z]). Together, these represent the transform's rotation, scale, and shearing.
2017-09-12 20:42:36 +00:00
</member>
2019-09-24 17:45:03 +00:00
<member name= "origin" type= "Vector3" setter= "" getter= "" default= "Vector3(0, 0, 0)" >
2024-01-15 11:10:52 +00:00
The translation offset of this transform. In 3D space, this can be seen as the position.
2017-09-12 20:42:36 +00:00
</member>
</members>
<constants >
2019-09-24 17:45:03 +00:00
<constant name= "IDENTITY" value= "Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)" >
2024-01-15 11:10:52 +00:00
A transform with no translation, no rotation, and its scale being [code]1[/code]. Its [member basis] is equal to [constant Basis.IDENTITY].
When multiplied by another [Variant] such as [AABB] or another [Transform3D], no transformation occurs.
2018-08-20 22:35:30 +00:00
</constant>
2019-09-24 17:45:03 +00:00
<constant name= "FLIP_X" value= "Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)" >
2024-01-15 11:10:52 +00:00
[Transform3D] with mirroring applied perpendicular to the YZ plane. Its [member basis] is equal to [constant Basis.FLIP_X].
2018-08-20 22:35:30 +00:00
</constant>
2019-09-24 17:45:03 +00:00
<constant name= "FLIP_Y" value= "Transform3D(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0)" >
2024-01-15 11:10:52 +00:00
[Transform3D] with mirroring applied perpendicular to the XZ plane. Its [member basis] is equal to [constant Basis.FLIP_Y].
2018-08-20 22:35:30 +00:00
</constant>
2019-09-24 17:45:03 +00:00
<constant name= "FLIP_Z" value= "Transform3D(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0)" >
2024-01-15 11:10:52 +00:00
[Transform3D] with mirroring applied perpendicular to the XY plane. Its [member basis] is equal to [constant Basis.FLIP_Z].
2018-08-20 22:35:30 +00:00
</constant>
2017-09-12 20:42:36 +00:00
</constants>
2021-09-21 02:49:02 +00:00
<operators >
<operator name= "operator !=" >
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Transform3D" />
2021-09-21 02:49:02 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns [code]true[/code] if the components of both transforms are not equal.
2021-11-04 15:58:20 +00:00
[b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable.
2021-09-21 02:49:02 +00:00
</description>
</operator>
2021-11-28 08:48:57 +00:00
<operator name= "operator *" >
<return type= "AABB" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "AABB" />
2021-11-28 08:48:57 +00:00
<description >
2024-01-15 11:10:52 +00:00
Transforms (multiplies) the [AABB] by this transformation matrix.
2021-11-28 08:48:57 +00:00
</description>
</operator>
2021-09-21 02:49:02 +00:00
<operator name= "operator *" >
<return type= "PackedVector3Array" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "PackedVector3Array" />
2021-09-21 02:49:02 +00:00
<description >
2024-01-15 11:10:52 +00:00
Transforms (multiplies) every [Vector3] element of the given [PackedVector3Array] by this transformation matrix.
On larger arrays, this operation is much faster than transforming each [Vector3] individually.
2021-09-21 02:49:02 +00:00
</description>
</operator>
2022-07-30 22:32:03 +00:00
<operator name= "operator *" >
<return type= "Plane" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Plane" />
2022-07-30 22:32:03 +00:00
<description >
2024-01-15 11:10:52 +00:00
Transforms (multiplies) the [Plane] by this transformation matrix.
2022-07-30 22:32:03 +00:00
</description>
</operator>
2021-09-21 02:49:02 +00:00
<operator name= "operator *" >
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Transform3D" />
2021-09-21 02:49:02 +00:00
<description >
2024-01-15 11:10:52 +00:00
Transforms (multiplies) this transform by the [param right] transform.
This is the operation performed between parent and child [Node3D]s.
[b]Note:[/b] If you need to only modify one attribute of this transform, consider using one of the following methods, instead:
- For translation, see [method translated] or [method translated_local].
- For rotation, see [method rotated] or [method rotated_local].
- For scale, see [method scaled] or [method scaled_local].
2021-09-21 02:49:02 +00:00
</description>
</operator>
<operator name= "operator *" >
<return type= "Vector3" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Vector3" />
2021-09-21 02:49:02 +00:00
<description >
2024-01-15 11:10:52 +00:00
Transforms (multiplies) the [Vector3] by this transformation matrix.
2021-09-21 02:49:02 +00:00
</description>
</operator>
<operator name= "operator *" >
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "float" />
2021-09-21 02:49:02 +00:00
<description >
2024-01-15 11:10:52 +00:00
Multiplies all components of the [Transform3D] by the given [float], including the [member origin]. This affects the transform's scale uniformly, also resizing the [member basis].
2021-09-21 02:49:02 +00:00
</description>
</operator>
<operator name= "operator *" >
<return type= "Transform3D" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2021-09-21 02:49:02 +00:00
<description >
2024-01-15 11:10:52 +00:00
Multiplies all components of the [Transform3D] by the given [int], including the [member origin]. This affects the transform's scale uniformly, also resizing the [member basis].
2021-09-21 02:49:02 +00:00
</description>
</operator>
2023-12-20 16:42:39 +00:00
<operator name= "operator /" >
<return type= "Transform3D" />
<param index= "0" name= "right" type= "float" />
<description >
2024-01-15 11:10:52 +00:00
Divides all components of the [Transform3D] by the given [float], including the [member origin]. This affects the transform's scale uniformly, also resizing the [member basis].
2023-12-20 16:42:39 +00:00
</description>
</operator>
<operator name= "operator /" >
<return type= "Transform3D" />
<param index= "0" name= "right" type= "int" />
<description >
2024-01-15 11:10:52 +00:00
Divides all components of the [Transform3D] by the given [int], including the [member origin]. This affects the transform's scale uniformly, also resizing the [member basis].
2023-12-20 16:42:39 +00:00
</description>
</operator>
2021-09-21 02:49:02 +00:00
<operator name= "operator ==" >
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Transform3D" />
2021-09-21 02:49:02 +00:00
<description >
2024-01-15 11:10:52 +00:00
Returns [code]true[/code] if the components of both transforms are exactly equal.
2021-11-04 15:58:20 +00:00
[b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable.
2021-09-21 02:49:02 +00:00
</description>
</operator>
</operators>
2017-09-12 20:42:36 +00:00
</class>