Object, Local & World Space

I need to remember to blog more…Here are some notes on 3d space, important especially when considering things like local rotation axes.

World Space

World space is in relation to our origin (0,0,0).

Object Space

Object space is in relation to the pivot point of the object. The values will also reflect the local rotation axes of the object.

Local Space

Local Space is in relation to the parent of the object. If we freeze transformations on an object that is in a hierarchy, then the object automatically follows the same values as it’s parent. If there is no parent/hierarchy (and if the object isn’t in a group), then world space is used.

Local Rotation Orders

Good video from Guerilla CG, helps remind me of the important things to think about with LR Orders every time. To remember:

When you have a rotation order, for example xyz, is like a hierarchy where z is the parent with y as a child of z, and x is a child of y. So we first have z evaluated, which affects y and x, then y is evaluated, which affects x, then x is evaluated on it’s own. (It’s reversed!)

With all 6 possible LRO combinations, gimbal lock happens when the middle axis y moves (usually 90 degrees), because it only affects one axis (x) it can rotate so that z and x line up and become gimbal locked. To find the most suitable order, we have to think about how our joint will be moving.

The last axis (z in xyz) will carry the other 2 axis with it. The most important axis should go there, the least important axis should be on the most left. The middle axis should be the least used axis, as its rotation can cause gimbal lock.

If you’re rotating/orbiting a character around an axis, current example being the Y axis, then it is important that the y axis carries the x and z to ensure that the character can bend forward and backwards; so y must be the first axis in the order (so either zxy or xzy)

Script that selects all of a selected type of object in a hierachy

Was on riggingdojo – credits to Chad Moore! Selects all of a certain type of object in a hierachy, all joints, curves or constraints – found it useful for resizing joints

import maya.cmds as cmds

cmds.select(cmds.ls(dag=1, ap=1, sl=1, type=”joint”))

or

cmds.select(cmds.ls(dag=1, ap=1, sl=1, type=”nurbsCurve”))

or

cmds.select(cmds.ls(dag=1, ap=1, sl=1, type=”constraint”))

Script to delete empty group nodes from scene

Found a script on polycount forums (credits to Shawner) which deletes empty group nodes from your scene. Watch out when there are empty group nodes used (such as stretchy IK) though they will be fine if there are constraints attached to them.

import maya.cmds as cmds

transforms = cmds.ls(type=’transform’)

deleteList = []

for tran in transforms:

if cmds.nodeType(tran) == ‘transform’:

children = cmds.listRelatives(tran, c=True)

if children == None:

print ‘%s, has no childred’ %(tran)

deleteList.append(tran)

if len(deleteList) > 0:

cmds.delete(deleteList)