diff options
author | tagcup <tagcup@yahoo.com> | 2017-12-26 19:15:20 -0500 |
---|---|---|
committer | tagcup <tagcup@yahoo.com> | 2017-12-27 16:40:49 -0500 |
commit | e9896b17a9804ba6392dab0bd6c484f4d2e294c1 (patch) | |
tree | d35e6d3097458c56ef07021155b9de855a89eae4 /doc/classes | |
parent | c2240a2a714526e226ead5a20e3a070bb3eaaef6 (diff) |
Restore the behavior of Spatial rotations recently changed in c1153f5.
That change was borne out of a confusion regarding the meaning of "local" in #14569.
Affine transformations in Spatial simply correspond to affine operations of its Transform. Such operations take place in a coordinate system that is defined by the parent Spatial. When there is no parent, they correspond to operations in the global coordinate system.
This coordinate system, which is relative to the parent, has been referred to as the local coordinate system in the docs so far, but this sloppy language has apparently confused some users, making them think that the local coordinate system refers to the one whose axes are "painted" on the Spatial node itself.
To avoid such conceptual conflations and misunderstandings in the future, the parent-relative local system is now referred to as "parent-local", and the object-relative local system is called "object-local" in the docs.
This commit adds the functionality "requested" in #14569, not by changing how rotate/scale/translate works, but by adding new rotate_object_local, scale_object_local and translate_object_local functions. Also, for completeness, there is now global_scale.
This commit also updates another part of the docs regarding the rotation property of Spatial, which also leads to confusion among some users.
Diffstat (limited to 'doc/classes')
-rw-r--r-- | doc/classes/Basis.xml | 2 | ||||
-rw-r--r-- | doc/classes/Spatial.xml | 60 |
2 files changed, 43 insertions, 19 deletions
diff --git a/doc/classes/Basis.xml b/doc/classes/Basis.xml index a873bd9a27..1573596487 100644 --- a/doc/classes/Basis.xml +++ b/doc/classes/Basis.xml @@ -38,7 +38,7 @@ <argument index="1" name="phi" type="float"> </argument> <description> - Create a rotation matrix which rotates around the given axis by the specified angle. The axis must be a normalized vector. + Create a rotation matrix which rotates around the given axis by the specified angle, in radians. The axis must be a normalized vector. </description> </method> <method name="Basis"> diff --git a/doc/classes/Spatial.xml b/doc/classes/Spatial.xml index ea04192a5e..7940e4065e 100644 --- a/doc/classes/Spatial.xml +++ b/doc/classes/Spatial.xml @@ -5,6 +5,8 @@ </brief_description> <description> Most basic 3D game object, with a 3D [Transform] and visibility settings. All other 3D game objects inherit from Spatial. Use Spatial as a parent node to move, scale, rotate and show/hide children in a 3D project. + + Affine operations (rotate, scale, translate) happen in parent's local coordinate system, unless the Spatial object is set as top level. Affine operations in this coordinate system correspond to direct affine operations on the Spatial's transform. The word local below refers to this coordinate system. The coordinate system that is attached to the Spatial object itself is referred to as object-local coordinate system. </description> <tutorials> </tutorials> @@ -32,15 +34,35 @@ Returns the current [World] resource this Spatial node is registered to. </description> </method> + <method name="rotate_object_local"> + <return type="void"> + </return> + <argument index="0" name="axis" type="Vector3"> + </argument> + <argument index="1" name="angle" type="float"> + </argument> + <description> + Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in object-local coordinate system. + </description> + </method> + <method name="scale_object_local"> + <return type="void"> + </return> + <argument index="0" name="scale" type="Vector3"> + </argument> + <description> + Scales the local transformation by given 3D scale factors in object-local coordinate system. + </description> + </method> <method name="global_rotate"> <return type="void"> </return> - <argument index="0" name="normal" type="Vector3"> + <argument index="0" name="axis" type="Vector3"> </argument> - <argument index="1" name="radians" type="float"> + <argument index="1" name="angle" type="float"> </argument> <description> - Rotates the current node along normal [Vector3] by angle in radians in Global space. + Rotates the global (world) transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in global coordinate system. </description> </method> <method name="global_translate"> @@ -49,7 +71,7 @@ <argument index="0" name="offset" type="Vector3"> </argument> <description> - Moves the node by [Vector3] offset in Global space. + Moves the global (world) transformation by [Vector3] offset. The offset is in global coordinate system. </description> </method> <method name="hide"> @@ -115,45 +137,45 @@ <return type="void"> </return> <description> - Resets this node's transformations (like scale, skew and taper) preserving its rotation and translation. Performs orthonormalization on this node [Transform3D]. + Resets this node's transformations (like scale, skew and taper) preserving its rotation and translation by performing Gram-Schmidt orthonormalization on this node's [Transform3D]. </description> </method> <method name="rotate"> <return type="void"> </return> - <argument index="0" name="normal" type="Vector3"> + <argument index="0" name="axis" type="Vector3"> </argument> - <argument index="1" name="radians" type="float"> + <argument index="1" name="angle" type="float"> </argument> <description> - Rotates the node in local space on given normal [Vector3] by angle in radians. + Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians. </description> </method> <method name="rotate_x"> <return type="void"> </return> - <argument index="0" name="radians" type="float"> + <argument index="0" name="angle" type="float"> </argument> <description> - Rotates the node in local space on X axis by angle in radians. + Rotates the local transformation around the X axis by angle in radians </description> </method> <method name="rotate_y"> <return type="void"> </return> - <argument index="0" name="radians" type="float"> + <argument index="0" name="angle" type="float"> </argument> <description> - Rotates the node in local space on Y axis by angle in radians. + Rotates the local transformation around the Y axis by angle in radians. </description> </method> <method name="rotate_z"> <return type="void"> </return> - <argument index="0" name="radians" type="float"> + <argument index="0" name="angle" type="float"> </argument> <description> - Rotates the node in local space on Z axis by angle in radians. + Rotates the local transformation around the Z axis by angle in radians. </description> </method> <method name="set_as_toplevel"> @@ -255,16 +277,18 @@ World space (global) [Transform] of this node. </member> <member name="rotation" type="Vector3" setter="set_rotation" getter="get_rotation"> - Local euler rotation in radians of this node. + Rotation part of the local transformation, specified in terms of YXZ-Euler angles in the format (X-angle, Y-angle, Z-angle), in radians. + + Note that in the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three indepdent parameters of the Euler-angle parametrization of the rotation matrix, are stored in a [Vector3] data structure not because the rotation is a vector, but only because [Vector3] exists as a convenient data-structure to store 3 floating point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful. </member> <member name="rotation_degrees" type="Vector3" setter="set_rotation_degrees" getter="get_rotation_degrees"> - Local euler rotation in degrees of this node. + Rotation part of the local transformation, specified in terms of YXZ-Euler angles in the format (X-angle, Y-angle, Z-angle), in degrees. </member> <member name="scale" type="Vector3" setter="set_scale" getter="get_scale"> - Local scale of this node. + Scale part of the local transformation. </member> <member name="transform" type="Transform" setter="set_transform" getter="get_transform"> - Local space [Transform] of this node. + Local space [Transform] of this node, with respect to the parent node. </member> <member name="translation" type="Vector3" setter="set_translation" getter="get_translation"> Local translation of this node. |