This article was printed in the 1998 siggraph issue of 3D Design magazine, for an article Alex Alvarez wrote entitled 'Organic Modeling and Animation in Maya V.1',
Alex is director and instructor at Gnomon Training Center, a HIGHEND3D.COM strategic partner. Alex teaches advanced acharacter nimation classes covering these techniques and many more at Gnomon. I have learned a great deal from his animation classes and highly recommend anyone interested in character animation to take his classes.
In this article I will be concentrating on kinematic set-up and workflow for my character Lanker, with whom I wanted to be able to achieve a very wide range of motion. While it is simple to set up a skeleton that can walk in a straight line, it is another thing to set up a skeleton which can do anything.
When the modeling phase is complete, the next step is the construction of a skeleton with which to deform the surfaces. While building skeletons was never really a time consuming endeavor, there are a few new tools in Maya which make the workflow a bit more streamlined: Reroot Skeleton, Insert Joint, Remove Joint, Connect Joint, Disconnect Joint, Mirror Joint and Orient Joint.
The above mentioned tools have clear functions based on their names except for Orient Joint. This allows us the ability to automaticaly orient joints after they have been created so that their local axes position themselves in line with the bone which descends from them as in Figure 1: an important issue with forward kinematics. An alternate method for orienting the joint is to select its local rotation axes, in component mode, and manually modify it with the rotate tool. Orient Joint can be invoked while initially drawing a skeleton by turning on AutoJointOrient, or afterwards by selecting joints and excecuting a MEL (Maya's embedded language) command: 'joint -e -zso -oj xyz'. This command is not in the user interface (UI), so it is a good idea to create a custom button on the shelf for it. To do this, type the command in the Command Line window, highlight it with the left mouse button, and then middle mouse button drag the high-lighted text to the Shelf window.
With the skeleton in place as in Figure 2, shown in X-ray mode with the geometry, the next phase will involve setting up your base controls for the skeleton. Fine tuning will need to occur after the surface attachments have been made, but setting up some controls before setting up deformations is necessary. The reason for this is that when you begin attaching geometry, you need to check the attachment by bending joints. Before adding any controls, however, we need to 'clean up' any modifications we have made to the joints via the Rotate tool. The reasons for this are that joints need to be in their default pose as surface attatchments and deformations are made and edited, so it is useful to have a simple means of getting them there. When a joint is created, it's X,Y and Z rotation attributes have a value of zero. But rotating the joints in order to better suit the skeleton to your geometry will obviously change that. If the new rotation of the joints is the newly desired default position, the joint should be selected and 'Modify/Freeze Transforms' should be used. This will keep the joint in its current position/rotation, but reset the rotation attributes to zero making it much easier to get the joints back to this position later. Freeze Transforms can alter the joints local rotation axes, however, and so you will want to orient joint local rotation axes accordingly. Another useful thing to do at this point is to create a button on the shelf which will select all joints and set their rotations to zero allowing you to have a 'default pose' button.
The first methodology for controlling skeletons is Forward Kinematics. Simply picking a joint and rotating is the purest means of animating a character, but this can now be taken a bit further. With Lanker, areas of a skeleton which are best suited for manual rotation over Inverse Kinematics are head, neck and collar bone rotations as well as hands and fingers.
The first thing to become aquainted with in regards to forward kinematics are Selection Handles. All objects in Maya which can be transformed have hidden Selection Handles which are displayed by selecting the object and invoking Display/Object Components/Selection Handles. Selecting a Selection Handle actually selects the object for which it was displayed. When dealing with a skeleton, it is often difficult to select the desired joint when they are visually overlapping in the view panel. Selection Handles appear as a red cross located by default at the pivot point of the selected object, which for a joint is always located at the joint's position. Two other convenient things about them is that they can be moved, in component mode, to an easier to see location for picking and that they are always displayed on top of shaded geometry as in Figure 3.
Manual rotation of joints is a straight forward process when dealing with single joint areas of influence such as the head or neck. Selection handles simply make the workflow much quicker. Multiple joint areas of influence can be a bit more involved, however. Picking each joint in a spine or finger one by one and rotating them for animation purposes is quite time consuming. But using Inverse Kinematics is not really that much better. With the hand, for example, there is a definite repetoire of poses such as fist, clench, relaxed, pointing, and so on. So the ideal control for this is to have a hand control panel where we have sliders which allow us to gradually assume these preset poses, while maintaining individual control over each joint in each finger for tweaking.
There are three methods which I use to go about setting up forward kinematic controls. The first method is simple but lacks flexibility in assuming the hand gestures. Again we will create custom buttons on the shelf, but this time each button will cause each hand to assume a predefined pose. Two new shelves should be created using Options/Customize UI/Shelves, one for the left hand and one for the right. First a button should be made for the neutral pose by shift-selecting each joint, and then typing 'rotate 0 0 0' in the command line. Open the Script Editor via Window/General Editors/Script Editor and then left mouse button drag/highlight all the commands which listed as we performed the above action, and middle mouse button drag this text to the Shelf to create the 'neutral' button. Now we can rotate all the joints in the hand so that the hand is posed, open the Script editor and drag the associated text for the next button. The very important thing to remember with this technique is that using the rotate tool creates MEL commands in the Script Editor which are relative transformations (i.e. rotate -r 1 .3 5.8). Thus to assume the gestures of these buttons, you must first click on the ?neutral? button we created, and then the 'gesture' button.
The second technique involves the use of Custom Attributes and Expressions. Attributes in Maya are things like 'translateX' or 'visibility'. Yet new attributes can be added to any object by using Modify/Add Attribute. A custom attribute simply stores a number which has no meaning until another object is told to look at this number. Thus a dummy object can be made to store attributes which control literally anything. The most common object to use for storing attributes is called a Locator which looks like a jack, but does not show up in renderings. Figure 4 shows the dialogue box for the Add Attribute tool as well as the default attributes for a selected locator listed in the Channel Box, a window which lists only keyframable attributes. After adding some attributes to the locator and turning off the keyframability of the default attributes, our channel box becomes a custom control panel for whatever we choose, as seen in Figure 5. Selecting an attribute with the left mouse button in the Channel Box and then dragging with the middle mouse button then creates a virtual slider which changes the attribute?s value. The thing to remember is that these new attributes still do not control anything. To give them meaning, we need to write Expressions. For example, let's say we named our locator 'master_control'. A custom attribute called 'wrist_rx' ('rx' meaning x rotation) would be seen by Maya as 'master_control.wrist_rx', where a period separates the object name from the attribute name. Using the Expression Editor found in Window/Expression Editor, we could enter an expression such as: wrist_joint.xrotate = master_control.wrist_rx. We have now given meaning to the custom attribute that we added to the 'master_control' locator.
The third technique for setting up controls involves Custom Attributes and Set Driven Key. While the above use of custom attributes allowed us to easily set up controls for an individual joint, what about having several joints take a specific pose based on a custom attribute as I mentioned earlier? We could try and write an expression to do this, but this gets a little hairy. While in PowerAnimator this was our only option, Maya has a new tool whose usefulness is unique and powerful: Set Driven Key. This tool allows for the interactive creation of object relationships without having to write any expressions. The terminology is that of the Driver and the Driven where the Driver can be any attribute of any object and the Driven can be multiple attributes of multiple objects. Thus an attribute called 'fist' on our 'master_control' locator can drive the x,y and z rotations of all the joints in a hand. The set-up for this is rather simple. First we will add an attribute to the locator called, for example, 'fist', whose minimum value is zero, max value is one hundred, and default value is zero. Next the Set Driven Key window must be opened via Keys/Set Driven Key/ Set. Then the ?master_control? locator is selected and we click on ?load driver?. We then shift-select all the joints in the hand and click ?load driven?. At this point the attributes which we want to relate to each other are selected as in Figure 6. Again, one attribute can 'drive' multiple attributes. The last step involves defining the relationship. With the driver and the driven in their neutral states, select the locator (driver) and all the hand joints (driven) and click 'Key' in the Set Driven Key window. Then set the 'fist' attribute to one hundred, rotate the hand joints into a fist, select both the driver and the driven, and click Key again. And that's it. Even more amazing is that fact that the same driver can be used with the same driven in another relationship, or the same driven can be driven by another driver. For example, we can add another attribute called 'clenched' to the locator which will drive the same hand joints into a different pose. After spending less than an hour setting up relationships, you can end up with a control panel offering a wide range of gestures which are triggered interactively, in a manner substantially faster than any traditional forward or inverse kinematic method.
While forward kinematics have been given new life in Maya, inverse kinematics have improved as well in both flexibility and stability. There are four types of inverse kinematic (IK) controls, or handles, in Maya: Multi-Chain(MC), Spline, Rotate-Plane(RP) and Single-Chain(SC). The MC, SC and RP handles are created by enabling Skeletons/IK Handle and selecting the desired root and end effector of the ik handle. All joints located between and including the root and end effector will be affected by the handles translation. The Spline handle, however, allows us to constrain a skeleton to the shape of a NURBS curve.
While Multi-Chain (enabled by typing 'createNode ikMCsolver' in the Command Line) and Spline handles have their uses, especially on skeletons with many joints such as snakes, spines, tentacles, etc... with Lanker they were not necessary. Lanker's hands, spine, head and neck were set up with forward kinematics. The arms, legs and feet are then set up with the Rotate-Plane and Single-Chain IK handles.
The first thing to understand about these two solvers is that they are history independent. What this means is that they will always solve the same way, thus making them completely predictable. With the MC solver, the skeleton could look any number of ways with the handle in the same position and each joint could rotate in any direction. The RP and SC solvers, however, calculate based on how the skeleton was drawn prior to adding the handle: they 'remember' the neutral state of the skeleton. Furthermore, each joint can only rotate in a 180 degree arc based on where you placed a bend in the skeleton. With a leg, for example, by drawing the skeleton with a bend at the knee, these solvers will never allow the knee to hyperextend. After substantially moving the handles around, Figure 7 shows the same skeleton with an SC handle on the left, a MC handle on the right and an untouched skeleton in the middle.
While based on the same engine, the difference between the RP and SC handles is in how a phenomenon called 'gimble-locking' is managed. Gimble-locking is a result of the fact that these solvers calculate based on the position of two aspects of the handle called the Plane and the Pole Vector. In Figure 8 you can see the appearance of these when an RP handle is selected, represented as a disc at the root of the handle where the white line is the Pole, and the white triangle is the Plane. Both can be independantly moved by selecting the RP handle and invoking Modify/Transformation Tools/Show Manipulators. An example of their use is when you bring a spoonful of soup to your mouth. The position of the elbow may be above the shoulder line or below. Rotating the Plane allows for this type of control. The Pole Vector, however, is used when 'flipping' occurs. When the line which extends from the IK handle to its root is parallel to the Pole Vector, the skeleton will ?flip? as shown in Figure 9. Notice how when the wrist is below the shoulder line, the elbow is behind the torso in the top view, but when the wrist moves above the pole vector, the elbow flips to the other side. Thus it is by animating the Pole Vector?s position, that this usually undesired result can be avoided.
The Single-Chain solver fixes the problem of flipping. But this is at the sacrifice of control. The SC solver automatically moves the Pole Vector out of the way where flipping would occur. But because of this, the user loses control. With Lanker, I chose to use the RP solver for the arms as I needed full control, but with the legs and feet I used SC. The reason for this has to do with a technique I use which offers more predictability and flexibilty. When setting up a leg it is important to understand the relationship between the leg and the foot in reality and the limitations of a default IK set up in Maya. First of all, a foot needs to be able to roll on the heel, ball and toe. Next it needs to be able to rotate in a manner such as when you are standing straight and then point your feet out at 90 degree angles, like a ballerina. Also important is to note that when you do the ballerina maneuver, it is not just the foot that is rotating but the leg as well. If you simply create an IK handle from the hip to the ankle, then one from the ankle to the toe, creating the above motion is unintuitive and time consuming. The best technique for setting this up involves grouping ik handles to themselves.
A common technique to use when multiple pivot points are needed for an object is to group the object to itself. While Maya does allow us to animate pivot points, this creates one more item we need to worry about and so the old technique works well. Figure 10 shows the skeletal hierarchy of a leg where joints exist at the hip, knee, ankle, ball and toe. Also diplayed are the three SC handles which have been created from the hip to the ankle, ankle to the ball, and ball to the toe. Notice that the nodes for these handles exist outside the hierarchy of the skeleton in the Hypergraph. The affect of this is that IK handles constrain to their position when the skeleton is moved as in Figure 11. If you want to disable this, you can parent an IK handle to the parent of it's root.
In order to now set up the heel to toe stuff, the following steps must be taken. First, group all three IK handles to each other using Edit/Group which will create the hierarchy in Figure 12. Now name this hierarchy 'foot' and move its pivot point to the heel: not the ankle but the heel, based on the foot geometry's heel. Now select the IK handle at the ankle and group it to itself. Name the new node Ball_roll and move it's pivot point to the ball of the foot. Now select the IK handle at the ball of the foot as well as the 'Ball_roll' node and group them together. Call this node Toe_roll and move its pivot point to the toe. Now select the three IK handles and hide them using Display/Hide Selection. Then turn on the selection handles for 'foot', 'ball_roll' and 'toe_roll' and move the selection handles to the side to make them easier to select. At this point things will look as they do in Figure 13. The reason for hiding the IK handles is that you no longer want to move them: you want to move/rotate the new nodes you have created. We now have a fully functional foot and leg where the 'foot' node is used to move the foot around and rotate on the heel, which also rotates the leg. The ball_roll and toe_roll nodes are used for what their names imply, and thus it is a good idea to set rotational limits on those nodes. You could even make custom attributes on the 'foot' node which control ball_roll and toe_roll.
Transform Limits, Stiffness and Damping are the next attributes which we could modify to further refine our control of the skeleton. These are joint attributes which affect how the ik handle solutions are calculated. They are edited in the Attribute Editor for a selected joint. The only limitation is that they do not work on the root joints of ik handles. Limits are self-explanatory, a stiffness of 100 makes a joint immovable and damping slows a joint down when it is about to approach its user defined rotational limit.
The final topic for today is the issue of keyframing from forward to inverse kinematics. You have seen how to create hand gestural controls using forward kinematics and positionally constrained motion using inverse kinematics. Well, what if you have a character that needs walk its fingers along a table like a spider, and then raise its arm and make some hand gestures? Maya allows you to keyframe IK solvers on and off. IK handles have an attribute called 'Solver Enable' which is either on or off. By keyframing this attribute, you can achieve the above effects. Thus a hand can have both Set Driven Key and Inverse Kinematic controls available for it.
In part three, the conclusion to this series, we will move on to skeleton driven surface deformations. Body and facial animation workflow, including techniques for animating high-res character models, sound synchronization and dialogue will also be addressed.
Page 1 of 3
Author:sdb1987 Submitted: 2005-09-20 22:23:15 UTC Tags: Software: Maya Views: 32,953