From e9896b17a9804ba6392dab0bd6c484f4d2e294c1 Mon Sep 17 00:00:00 2001 From: tagcup Date: Tue, 26 Dec 2017 19:15:20 -0500 Subject: 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. --- doc/classes/Basis.xml | 2 +- doc/classes/Spatial.xml | 60 ++++++++++++++++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 19 deletions(-) (limited to 'doc') 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 @@ - 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. 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 @@ 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. @@ -32,15 +34,35 @@ Returns the current [World] resource this Spatial node is registered to. + + + + + + + + + Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in object-local coordinate system. + + + + + + + + + Scales the local transformation by given 3D scale factors in object-local coordinate system. + + - + - + - 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. @@ -49,7 +71,7 @@ - Moves the node by [Vector3] offset in Global space. + Moves the global (world) transformation by [Vector3] offset. The offset is in global coordinate system. @@ -115,45 +137,45 @@ - 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]. - + - + - 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. - + - 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 - + - 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. - + - 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. @@ -255,16 +277,18 @@ World space (global) [Transform] of this node. - 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. - 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. - Local scale of this node. + Scale part of the local transformation. - Local space [Transform] of this node. + Local space [Transform] of this node, with respect to the parent node. Local translation of this node. -- cgit v1.2.3