BUILDING LEG SKELETONS IN MAYA USING THE DETACHED FOOT METHOD
Several different techniques exist for creating a controlled leg skeleton in Maya, and all of the best ones address the issue of animating the foot using two different pivot point locations - one at the heel, and one at the ball of the foot. However, all of the tutorials I have read on this subject tend to approach the basic construction of the leg in the same way; that is, the leg and foot are built as an entire chain, and IK handles and/or expressions are then added to provide appropriate control over the foot position and rotation. In my experience as a character animator, however, I have noticed that these approaches ignore a very critical feature of a good Leg Skeleton design; namely, the ability to lock the position of a foot and ensure that it won't move or float during the course of an animation. While other techniques do allow the artist to set keyframes for the location of IK handles which control the leg and foot, if these IK handles are positioned out of reach of the fully extended skeleton, slipping will certainly occur.
Since a planted foot should remain completely static, even small movements become very noticeable, and severely undermine the illusion of weight. Of course, if a realistic character has been animated very carefully, technically a foot should have certain movement limits and the leg should retain a consistency in length. However, often times, even a carefully animated character will require a pose which extends the legs slightly beyond their true reach, and the process of correcting the position to account for the actual leg length can be tedious and time-consuming. Moreover, if we look at traditional, hand-drawn animation (particularly samples dealing with less realistically proportioned characters), we notice that artists frequently fudge reality in order to have a character reach a desirable pose, or move in a pleasing way. After all, the golden age of animation is all about exaggeration, and if we hope to make expressive, fluid 3D animation, we should look to the examples set by the great cell animators.
Because Maya gives users the ability to bind a character skin to a several separate joint hierarchies, we can easily overcome the "sliding foot" tendency associated with single chain leg skeletons. The process is as follows:
First, from the side view, create the leg bones (Skeleton>Joint tool), using your finished model as a reference for proportion and scale (for the sake of clarity, no geometry is shown in this tutorial). Since we will want to be fairly precise about the location of some joints, it is a good idea to turn grid snapping on. Make sure the last leg joint (joint3) is positioned at the origin (X, Y, and Z = 0).
Hit the enter key to resolve the leg chain, re-invoke the Skeleton>Joint Tool (if necessary), then mouse click away from the leg chain and drag this new joint (with the mouse button still down) to the origin. This will be the first joint of the foot chain, and creating it in this way will ensure that the foot chain and leg chain are independent hierarchies.
Finish constructing the three joint foot chain, as shown, taking note of the Z location of the second foot joint (in this example, the second foot joint is placed at Z = 2).
Next, using the Skeleton>IK Handle Tool create an IK solver between joint1 and joint3 of the leg chain (I use the default IK Handle Tool options and create an ikRP (Rotate Plane) solver).
Now, from the hypergraph, select both the IK handle, and the root of the foot chain, and group the two objects together (Edit>Group), then, with this new group still selected, repeat the group command (Edit>Group) to create an additional parent node. In the hypergraph, your scene should now contain two hierarchies: one consisting of the leg joint chain, and the other consisting of the foot joint chain and the IK handle for the leg nested under two parent nodes. If you haven't done so already, now would be a good time to rename the elements in your scene. In general, I make a habit of naming every object in my scenes, but this is particularly important with skeletons since descriptive names make the process of fine-tuning skin weights significantly easier. For the purposes of this exercise, name your objects as I have done in the following screen captured image.
As you can see, when leftFootGroup is selected and moved, this skeleton behaves just as a single chain leg/foot skeleton would.
However, if leftLegJoint1 (the root of the leg chain) is selected and moved to a location which prevents the leg from reaching the foot, the foot still remains in place, unaffected.
Although this method does permit a cartoon-like stretching of the lower leg, one way of ensuring that the leg still looks natural is to prevent the knee from ever becoming completely straight. Since a joint chain must be built with a slight bend in order for the IK solution to work correctly, skins attached to an IK chain will actually appear to hyper-extend if the chain is ever straightened completely. Imposing a limit on the knee's extension rotation will keep our model looking correct, even if the legs are being stretched. To limit the knee joint rotation, select leftLegJoint2, bring up the attribute editor (CTRL-A or Window>Attribute Editor...), expand the Limit Information portion of the editor, and in the Rotate region, put a check in the box next to Rot Limit Z. Then, enter a value slightly below zero in the Min window to designate the minimum rotation value of the knee. Zero would be the slightly bent position in which the legs were originally created, so I generally enter a value of -10 or -15 which will allow the leg to straighten somewhat, but will still prevent the leg from ever appearing hyper-extended. Close the Attribute Editor. Now, when we translate the leg, the knee never straightens completely, even if the foot is placed well beyond a "true" reach.
By selecting leftKneeOrient we can also easily change the orientation of the entire leg by simply rotating this root node along the Y axis. This is very handy for creating bow-legged or pigeon-toed characters, or for animating characters that need to change direction while walking.
Now we can begin creating the expressions which will allow for rotation (in the X axis) at either the heel or the ball of the foot. Currently, if we rotate leftFootGroup, along the X axis, the foot will pivot at the heel.
However, in order to create proper foot movement, we will want the flexibility to pivot on the heel of the foot when the leg is extended forward, and on the ball of the foot when the leg is extended behind the character and the foot is planted. To solve this problem, we will create a simple, conditional expression which will move the pivot point depending on whether the foot is rotated forward (positive X) or backward (negative X). Open the expression editor (Window>Animation Editors>Expression Editor...), type "leftFootPivot" in the Expression Name box, and in the Expression box (at the bottom of the Expression Editor), enter the following:
if (leftFootGroup.rotateX > 0)
Be sure to follow this syntax exactly and avoid typos, or the expression won't be generated. The ".rotatePivotZ" attribute used in lines 2 and 4 of this expression determines the location of the pivot point along the Z axis. In this example, the ball of the foot was created at Z = 2, so this is where we want to move the pivot point when the foot is rotating forward. If you build a foot in a different scale, you will need to take note of the Z value of the second foot joint (the ball of the foot), and modify line two of this expression accordingly. It is also worth noting that since this expression specifies rotation and translation axes, it will only work properly if the leg is built in the side view (as we have done in this exercise). Building the leg from a front or top orientation would require changing the rotate and rotatePivot axes specified in the expression. Hit the Create button, and you will notice that when leftFootGroup is rotated forward, it now pivots at the ball of the foot, whereas when it is rotated backwards, it rotates at the heel as before.
As for the toe joint (leftFootJoint2), I generally rotate this joint manually along its X axis as needed. On most occasions when the foot is rotated forward and planted on the ground, I will want to compensate with a negative X rotation of leftFootJoint2 to keep the toe from traveling through the ground. However, in many animations (such as a run cycle), there are instances where the foot is rotated forward but is above the ground (extended behind the character); in these cases, I want the toe to follow the line of the foot, and therefore would not be compensating with a reverse toe rotation.
Now that the leg skeleton is complete, we can duplicate the skeleton and move the two legs into their final positions. To duplicate the skeleton with IK chains and expressions intact, simply select the leftKneeOrient hierarchy, then in the Edit>Duplicate options window, place a check in the box next to Duplicate Upstream Path. Hit the Duplicate button, and a new leg with IK handles and working expressions will be created. Now, the two legs can be repositioned by moving an entire Leg Hierarchy and its associated Foot Hierarchy to the appropriate X location.
The duplicate hierarchies should also be renamed to distinguish the right leg and foot from the left; their expressions will automatically update. Once both of the legs have been moved into their final X location, the rest of the skeleton can be built, and the left and right KneeOrient chains can be attached to the pelvis. The left and right KneeOrient chains (containing the foot chains) should either remain ungrouped, or be grouped directly beneath a root node which controls the position and scale of the entire character skeleton.
The final step is to bind the geometry to the finished skeletons. The only trick here is that the root joint of each skeletal chain must be selected before the bind operation is invoked. Select Skin>Bind Skin>Smooth Bind to attach the skin to the skeleton (in this example, only the lower torso skeleton is shown).
Adjust the skin weighting as necessary using the Component Editor (Window>General Editors>Component Editor...) and you are ready to begin animating your character's legs.