Local vs Global Transform

When performing 3D development work, among the most important tasks you will take on is ensuring every asset in a scene is placed correctly to make a believable scene and a neat aesthetic for the users. In scenes where there are multiple complex objects placed together, understanding the difference between local and global transformations is key to making this happen.

Global Transformations

Global transformations describe where an item is located within the scene relative to the origin.

In the example below, a cabinet shape was created using several re-sized box meshes. These boxes form a 1x1x2 cabinet. The front face of the cabinet is a door with a handle.

With a flat scene graph structure, all mesh transformations match their global transformation.

As we can see, the door has a global translation of (0, 1, 0.51) with no rotations applied.

Let’s say we wish to add the ability to display the cabinet door as open. If we drag/rotate manually so the door appears open but still attached, we get a result like this:

This position looks believable, but wow those are some highly precise numbers for x and z! If you wish to show the cabinet in both positions (open and closed), those x and z values will need to be stored and configured along with the rotation every time the viewer switches position.

What if we wanted to rotate the entire cabinet, all 7 meshes? Get your spreadsheets ready!

OR… utilize local transformations!

Local Transformations

Local transformations describe how a node is transformed relative to its direct parent node. In the global transformation example above, there are no parent nodes. So, we are dealing in numbers translating the door relative to the origin.

However, much like when opening a real cabinet door, you can perform the task virtually with very few considerations if you set the door on a hinge!

Let’s go back to the original box and add a hinge null at the point where the door meets the main frame of the cabinet on the far left side.

To configure this scenario, drag the handle onto the door and the door onto the hinge null to create a parent-child relationship between the 3 nodes.

Observe what happens to the door translation values in this configuration when the door is attached by a hinge.

The translation automatically updates to show the door relative to the hinge null (the new parent) instead of relative to the origin.

To open our door, instead of rotating the door model and calculating the values (or manually dragging it to a new home), we can simply rotate the hinge null and observe the results.

Hinge Transformation Values:

Door Transformation Values:

The hinge is rotated -40 degrees on the y-axis. All of its child nodes also rotate -40 degrees on the y-axis. Visually, we can see this happen in the form of the door appearing to open. However, according to the right side panel, the door still has the same transformation applied to it, including 0 rotation! This is due to local transformations.

This same principle applies to all transformations you can perform on any parent node in a scene graph. If we moved the hinge null in the -x direction, the door would come along for the ride. Adding scale to the hinge will scale the door up or down as well.

What about rotating the whole cabinet? If you give the full cabinet a parent node, it will rotate everything below it, including the door (which sits directly below the hinge)!

A final note, when utilizing the Player API, just as we see in the 3D editor, the transformation information utilized by the API for any node on the scene graph will be the local transformation information for that node. When designing code for positioning an item inside a scene, it is important to pay attention to the scene graph to know what transformations will be impacting which nodes. Local transformations allow moving multiple nodes by only directly editing a single node, but by doing so you cannot skip moving something lower on the scene graph.

Last updated