Thursday, 25 November 2010

Rotation orders

Rotation orders are perhaps one of the most neglected areas of rigging and yet they have a major impact on the stability of the rig and usability for the animators. Setting the correct orders can save hours of work trying understand curves that make no sense and struggling to clean up wierd rotation pops in a single animation. Multiply that over all animations for a character, all characters in a project and suddenly the importance of getting this right becomes self evident.

The rotation order of a node is basically the order that rotation axis are evaluated. By default Maya creates nodes with an order of xyz which is generally not the optimal setting.

Choosing the most suitable order for a control or joint reduces the likelihood of running into gimbal lock where the object is rotated such that two of the axis overlap and it is then impossible to rotate the object in three axis.

You can see the actual axis of a node by setting the rotate tool to 'gimbal' mode.
Here I've set the rotation order to the default xyz. You'll notice as you rotate the joint in Y that the X axis eventually overlaps the Z axis. This is gimbal lock, and effectively at this point we can only rotate in two axis.

To illustrate why this is kind of a big deal, make sure you have 90 degrees of rotation in Y then set the rotate tool back to 'local' mode. Using the rotate tool, rotate the joint in the tools Z axis and pay attention to the rotation attributes. You will see a sudden 90 degree value changes on the X and Z axis. Imagine trying to animate with that going on!
The thing to remember is that gimbal mode is the only one to show you a true representation of the node rotation, all other modes offer easier manipulation but the trade-off is that they'll bung any old (and usually undesirable) rotation values in to orientate the node correctly.

 So essentially a node in gimbal lock can cause issues in a number of ways:
  • Extremely difficult to animate the node when axis cross, and animation curves that are difficult to manage.
  • Prevents you from using rotation values as a driver for rig systems as the rotation values can suddenly jump by 90 degrees or more in multiple axis. Forearm roll joints are a great example here - you can use wrist rotation to drive them but only if you have good rotation order on the wrist joint that gives you sensible rotation values all the time.
  • For games, depending on your export pipeline gimbal lock issues can creep into game causing orientation errors. While these might not have been noticeable in Maya, once compression has re sampled the animation curve you tend to lose step-changes in rotation value and these issues suddenly become visible.
So, lets look at how we can improve the situation for this joint. The best rotation order for a particular joint or control will vary depending it's likely range of movement. It's important to bare this in mind when setting a rig up, ask yourself 'how is this control/joint most likely to be rotated?'
Something else to bare in mind is that changing the rotation order does not magically banish gimbal lock, it simply moves where it happens to a different position. So, with that in mind the aim is to set the order so that gimbal occurs in the place it is least likely to be rotated to.

The best way of figuring out the correct rotation order is to put your rotate tool in gimbal mode and try it out, identifying what the most important axis is first of all. For the COG joint on this skeleton (and used as the example in this post) this is the Y axis as when this is rotated we want to be sure that the X axis will always bend forwards/backwards and the Z axis side-to-side. By setting the rotation order so that Y is the last to evaluate (either xzy or zxy) we can ensure that the X and Z axis will follow when Y is rotated.
Y rotated 45 degrees, X and Z axis follow
Then it's a question of resoving your last two axis. Do you want Z to follow X or the other way round? I reckon the more important of the two remaining axis is X which would give us a zxy rotation order.

It's worth experimenting with orders in different areas of the skeleton to find the best solution. The COG joint is relatively straightforward but other joints such as the arm are much less so and can come down to personal preference. You can see what orders I use on this skeleton.

One final point on rotation orders; when it comes to setting up control systems it is really important that connected nodes should always have matching orders. So for example if you have a control object driving a joint via an orient constraint the rotation order of the joint and control should match.

1 comment:

  1. Your images and links are 404, could you fix them?