Debian Codegraph @

doc/classes/Transform3D.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="Transform3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A 3×4 matrix representing a 3D transformation.
5 </brief_description>
6 <description>
7 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.
8 For a general introduction, see the [url=$DOCS_URL/tutorials/math/matrices_and_transforms.html]Matrices and transforms[/url] tutorial.
9 [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_3d_scenes/model_export_considerations.html#d-asset-direction-conventions]3D asset direction conventions[/url] tutorial.
10 </description>
11 <tutorials>
12 <link title="Math documentation index">$DOCS_URL/tutorials/math/index.html</link>
13 <link title="Matrices and transforms">$DOCS_URL/tutorials/math/matrices_and_transforms.html</link>
14 <link title="Using 3D transforms">$DOCS_URL/tutorials/3d/using_transforms.html</link>
15 <link title="Matrix Transform Demo">https://godotengine.org/asset-library/asset/2787</link>
16 <link title="3D Platformer Demo">https://godotengine.org/asset-library/asset/2748</link>
17 <link title="2.5D Game Demo">https://godotengine.org/asset-library/asset/2783</link>
18 </tutorials>
19 <constructors>
20 <constructor name="Transform3D">
21 <return type="Transform3D" />
22 <description>
23 Constructs a [Transform3D] identical to [constant IDENTITY].
24 [b]Note:[/b] In C#, this constructs a [Transform3D] with its [member origin] and the components of its [member basis] set to [constant Vector3.ZERO].
25 </description>
26 </constructor>
27 <constructor name="Transform3D">
28 <return type="Transform3D" />
29 <param index="0" name="from" type="Transform3D" />
30 <description>
31 Constructs a [Transform3D] as a copy of the given [Transform3D].
32 </description>
33 </constructor>
34 <constructor name="Transform3D">
35 <return type="Transform3D" />
36 <param index="0" name="basis" type="Basis" />
37 <param index="1" name="origin" type="Vector3" />
38 <description>
39 Constructs a [Transform3D] from a [Basis] and [Vector3].
40 </description>
41 </constructor>
42 <constructor name="Transform3D">
43 <return type="Transform3D" />
44 <param index="0" name="from" type="Projection" />
45 <description>
46 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).
47 </description>
48 </constructor>
49 <constructor name="Transform3D">
50 <return type="Transform3D" />
51 <param index="0" name="x_axis" type="Vector3" />
52 <param index="1" name="y_axis" type="Vector3" />
53 <param index="2" name="z_axis" type="Vector3" />
54 <param index="3" name="origin" type="Vector3" />
55 <description>
56 Constructs a [Transform3D] from four [Vector3] values (also called matrix columns).
57 The first three arguments are the [member basis]'s axes ([member Basis.x], [member Basis.y], and [member Basis.z]).
58 </description>
59 </constructor>
60 </constructors>
61 <methods>
62 <method name="affine_inverse" qualifiers="const">
63 <return type="Transform3D" />
64 <description>
65 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].
66 [b]Note:[/b] For this method to return correctly, the transform's [member basis] needs to have a determinant that is not exactly [code]0.0[/code] (see [method Basis.determinant]).
67 </description>
68 </method>
69 <method name="interpolate_with" qualifiers="const">
70 <return type="Transform3D" />
71 <param index="0" name="xform" type="Transform3D" />
72 <param index="1" name="weight" type="float" />
73 <description>
74 Returns the result of the linear interpolation between this transform and [param xform] by the given [param weight].
75 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.
76 </description>
77 </method>
78 <method name="inverse" qualifiers="const">
79 <return type="Transform3D" />
80 <description>
81 Returns the [url=https://en.wikipedia.org/wiki/Invertible_matrix]inverted version of this transform[/url]. See also [method Basis.inverse].
82 [b]Note:[/b] For this method to return correctly, the transform's [member basis] needs to be [i]orthonormal[/i] (see [method orthonormalized]). That means the basis should only represent a rotation. If it does not, use [method affine_inverse] instead.
83 </description>
84 </method>
85 <method name="is_equal_approx" qualifiers="const">
86 <return type="bool" />
87 <param index="0" name="xform" type="Transform3D" />
88 <description>
89 Returns [code]true[/code] if this transform and [param xform] are approximately equal, by running [method @GlobalScope.is_equal_approx] on each component.
90 </description>
91 </method>
92 <method name="is_finite" qualifiers="const">
93 <return type="bool" />
94 <description>
95 Returns [code]true[/code] if this transform is finite, by calling [method @GlobalScope.is_finite] on each component.
96 </description>
97 </method>
98 <method name="looking_at" qualifiers="const">
99 <return type="Transform3D" />
100 <param index="0" name="target" type="Vector3" />
101 <param index="1" name="up" type="Vector3" default="Vector3(0, 1, 0)" />
102 <param index="2" name="use_model_front" type="bool" default="false" />
103 <description>
104 Returns a copy of this transform rotated so that the forward axis (-Z) points towards the [param target] position.
105 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.
106 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).
107 </description>
108 </method>
109 <method name="orthonormalized" qualifiers="const">
110 <return type="Transform3D" />
111 <description>
112 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.0[/code]), which also means it can only represent a rotation. See also [method Basis.orthonormalized].
113 </description>
114 </method>
115 <method name="rotated" qualifiers="const">
116 <return type="Transform3D" />
117 <param index="0" name="axis" type="Vector3" />
118 <param index="1" name="angle" type="float" />
119 <description>
120 Returns a copy of this transform rotated around the given [param axis] by the given [param angle] (in radians).
121 The [param axis] must be a normalized vector (see [method Vector3.normalized]). If [param angle] is positive, the basis is rotated counter-clockwise around the axis.
122 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].
123 This can be seen as transforming with respect to the global/parent frame.
124 </description>
125 </method>
126 <method name="rotated_local" qualifiers="const">
127 <return type="Transform3D" />
128 <param index="0" name="axis" type="Vector3" />
129 <param index="1" name="angle" type="float" />
130 <description>
131 Returns a copy of this transform rotated around the given [param axis] by the given [param angle] (in radians).
132 The [param axis] must be a normalized vector in the transform's local coordinate system. For example, to rotate around the local X-axis, use [constant Vector3.RIGHT].
133 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].
134 This can be seen as transforming with respect to the local frame.
135 </description>
136 </method>
137 <method name="scaled" qualifiers="const">
138 <return type="Transform3D" />
139 <param index="0" name="scale" type="Vector3" />
140 <description>
141 Returns a copy of this transform scaled by the given [param scale] factor.
142 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].
143 This can be seen as transforming with respect to the global/parent frame.
144 </description>
145 </method>
146 <method name="scaled_local" qualifiers="const">
147 <return type="Transform3D" />
148 <param index="0" name="scale" type="Vector3" />
149 <description>
150 Returns a copy of this transform scaled by the given [param scale] factor.
151 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].
152 This can be seen as transforming with respect to the local frame.
153 </description>
154 </method>
155 <method name="translated" qualifiers="const">
156 <return type="Transform3D" />
157 <param index="0" name="offset" type="Vector3" />
158 <description>
159 Returns a copy of this transform translated by the given [param offset].
160 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].
161 This can be seen as transforming with respect to the global/parent frame.
162 </description>
163 </method>
164 <method name="translated_local" qualifiers="const">
165 <return type="Transform3D" />
166 <param index="0" name="offset" type="Vector3" />
167 <description>
168 Returns a copy of this transform translated by the given [param offset].
169 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].
170 This can be seen as transforming with respect to the local frame.
171 </description>
172 </method>
173 </methods>
174 <members>
175 <member name="basis" type="Basis" setter="" getter="" default="Basis(1, 0, 0, 0, 1, 0, 0, 0, 1)">
176 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 shear.
177 </member>
178 <member name="origin" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)">
179 The translation offset of this transform. In 3D space, this can be seen as the position.
180 </member>
181 </members>
182 <constants>
183 <constant name="IDENTITY" value="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
184 The identity [Transform3D]. This is a transform with no translation, no rotation, and a scale of [constant Vector3.ONE]. Its [member basis] is equal to [constant Basis.IDENTITY]. This also means that:
185 - Its [member Basis.x] points right ([constant Vector3.RIGHT]);
186 - Its [member Basis.y] points up ([constant Vector3.UP]);
187 - Its [member Basis.z] points back ([constant Vector3.BACK]).
188 [codeblock]
189 var transform = Transform3D.IDENTITY
190 var basis = transform.basis
191 print("| X | Y | Z | Origin")
192 print("| %.f | %.f | %.f | %.f" % [basis.x.x, basis.y.x, basis.z.x, transform.origin.x])
193 print("| %.f | %.f | %.f | %.f" % [basis.x.y, basis.y.y, basis.z.y, transform.origin.y])
194 print("| %.f | %.f | %.f | %.f" % [basis.x.z, basis.y.z, basis.z.z, transform.origin.z])
195 # Prints:
196 # | X | Y | Z | Origin
197 # | 1 | 0 | 0 | 0
198 # | 0 | 1 | 0 | 0
199 # | 0 | 0 | 1 | 0
200 [/codeblock]
201 If a [Vector3], an [AABB], a [Plane], a [PackedVector3Array], or another [Transform3D] is transformed (multiplied) by this constant, no transformation occurs.
202 [b]Note:[/b] In GDScript, this constant is equivalent to creating a [constructor Transform3D] without any arguments. It can be used to make your code clearer, and for consistency with C#.
203 </constant>
204 <constant name="FLIP_X" value="Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
205 [Transform3D] with mirroring applied perpendicular to the YZ plane. Its [member basis] is equal to [constant Basis.FLIP_X].
206 </constant>
207 <constant name="FLIP_Y" value="Transform3D(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0)">
208 [Transform3D] with mirroring applied perpendicular to the XZ plane. Its [member basis] is equal to [constant Basis.FLIP_Y].
209 </constant>
210 <constant name="FLIP_Z" value="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0)">
211 [Transform3D] with mirroring applied perpendicular to the XY plane. Its [member basis] is equal to [constant Basis.FLIP_Z].
212 </constant>
213 </constants>
214 <operators>
215 <operator name="operator !=">
216 <return type="bool" />
217 <param index="0" name="right" type="Transform3D" />
218 <description>
219 Returns [code]true[/code] if the components of both transforms are not equal.
220 [b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable.
221 </description>
222 </operator>
223 <operator name="operator *">
224 <return type="AABB" />
225 <param index="0" name="right" type="AABB" />
226 <description>
227 Transforms (multiplies) the [AABB] by this transformation matrix.
228 </description>
229 </operator>
230 <operator name="operator *">
231 <return type="PackedVector3Array" />
232 <param index="0" name="right" type="PackedVector3Array" />
233 <description>
234 Transforms (multiplies) every [Vector3] element of the given [PackedVector3Array] by this transformation matrix.
235 On larger arrays, this operation is much faster than transforming each [Vector3] individually.
236 </description>
237 </operator>
238 <operator name="operator *">
239 <return type="Plane" />
240 <param index="0" name="right" type="Plane" />
241 <description>
242 Transforms (multiplies) the [Plane] by this transformation matrix.
243 </description>
244 </operator>
245 <operator name="operator *">
246 <return type="Transform3D" />
247 <param index="0" name="right" type="Transform3D" />
248 <description>
249 Transforms (multiplies) this transform by the [param right] transform.
250 This is the operation performed between parent and child [Node3D]s.
251 [b]Note:[/b] If you need to only modify one attribute of this transform, consider using one of the following methods, instead:
252 - For translation, see [method translated] or [method translated_local].
253 - For rotation, see [method rotated] or [method rotated_local].
254 - For scale, see [method scaled] or [method scaled_local].
255 </description>
256 </operator>
257 <operator name="operator *">
258 <return type="Vector3" />
259 <param index="0" name="right" type="Vector3" />
260 <description>
261 Transforms (multiplies) the [Vector3] by this transformation matrix.
262 </description>
263 </operator>
264 <operator name="operator *">
265 <return type="Transform3D" />
266 <param index="0" name="right" type="float" />
267 <description>
268 Multiplies all components of the [Transform3D] by the given [float], including the [member origin]. This affects the transform's scale uniformly, scaling the [member basis].
269 </description>
270 </operator>
271 <operator name="operator *">
272 <return type="Transform3D" />
273 <param index="0" name="right" type="int" />
274 <description>
275 Multiplies all components of the [Transform3D] by the given [int], including the [member origin]. This affects the transform's scale uniformly, scaling the [member basis].
276 </description>
277 </operator>
278 <operator name="operator /">
279 <return type="Transform3D" />
280 <param index="0" name="right" type="float" />
281 <description>
282 Divides all components of the [Transform3D] by the given [float], including the [member origin]. This affects the transform's scale uniformly, scaling the [member basis].
283 </description>
284 </operator>
285 <operator name="operator /">
286 <return type="Transform3D" />
287 <param index="0" name="right" type="int" />
288 <description>
289 Divides all components of the [Transform3D] by the given [int], including the [member origin]. This affects the transform's scale uniformly, scaling the [member basis].
290 </description>
291 </operator>
292 <operator name="operator ==">
293 <return type="bool" />
294 <param index="0" name="right" type="Transform3D" />
295 <description>
296 Returns [code]true[/code] if the components of both transforms are exactly equal.
297 [b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable.
298 </description>
299 </operator>
300 </operators>
301 </class>