Coordinate spaces

From Neos Wiki
Revision as of 18:57, 19 June 2020 by Zyzyl (talk | contribs)
Jump to navigation Jump to search

Every slot (object) in a world within Neos has an associated set of position, rotation and scale values. This is true even if the slot does not have a visual component associated with it. Since space is three dimensional inside Neos worlds, position is encoded as a float3 datatype - a 3D vector of coordinates along X, Y, and Z axes. Rotations can also be expressed as angular displacements about these three axes and this is how it is displayed in the slot inspector panel. However rotations are managed internally, and exposed to LogiX, as a four dimensional floatQ - a quaternion. Scale works similarly to position and is encoded as a float3.

In Neos the positive X axis direction is defined as 'right', negative X direction is 'left'. The positive Y axis direction is defined as 'up', negative Y is 'down'. The the positive Z axis direction is defined as 'forward', negative Z direction is 'back. The positive X, Y and Z axes correspond to the red, green and blue arrows on the gizmo tool. Distances are scaled such that a unit of 1 in any axis direction corresponds to 1 meter. Angles are displayed in the slot inspector panel in units of degrees.

Coordinate Spaces

For any slot, there are two coordinate spaces which may be relevant:

  • The Global coordinate space, which is measured relative to the world root slot.
  • The Local coordinate space, which is measured relative to the slot's immediate parent in the slot hierarchy.

Local coordinates are the ones displayed in the slot inspector panel.

The world's root slot is unique and always at the top of the world slot hierarchy. It has a fixed position at [0,0,0], fixed identity rotation (basically [0,0,0] degrees) and [1,1,1] scaling. This means that, for a slot parented directly under the world root, global and local coordinate measures will be equivalent. This is also true if, and only if, all of a slot's parents have [0,0,0] position, [0,0,0] rotation, and [1,1,1] scale.

For example, if a slot, Slot_A, is parented under the world root and has global position [1,0,0] (i.e. 1 meter to the right of the world root) its local position, as shown in the inspector, will be [1,0,0]. If another slot, Slot_B, is parented under Slot_A and also has local position [1,0,0], its global position is [2,0,0]. If Slot_A is now moved to [1,1,0] (i.e. translated 1 meter upwards), Slot_B will move with Slot_A and its local position remains [1,0,0]; its global position will now be [2,1,0].

LogiX and Transformations

In principle one could calculate a slot's global position by summing its local position vector with those of all of its parents. However it is much easier to use the Global Transform (LogiX node) for this purpose. The same goes for global rotation and scale, although those would require the element-wise product of parent local rotations or scales due to how those quantities are combined.

There are many LogiX nodes which are particularly useful for moving, rotating and scaling slots in the LogiX: Transform category of the LogiX node browser. When applying a transformation (movement, rotation or scale) to a slot, such as via a Drive (LogiX node) or a Tween (LogiX node), one usually wants the input value to be in the target slot's local coordinate space. Initially calculating transformations using global coordinates may be useful if the intended effect should not depend on the slot's current context. Conversely, typically one wants transformations to happen relative to the slot's current state which requires the use of local coordinates.

Tutorials