And the Doctors said he'd never walk again....
By David Rogers
Editing and proofreading: Jeff Cantin
Legs are actually pretty easy to get working right but the secret to a snappy and responsive set of legs is all in the targets. So lets look at it from a what we want to happen, what controls we'll need and then what we need to do to achieve it.
What we want to happen:
Okay, So here we have one leg posed in a way that shows all that we want it to do when we are finished.
"MY god!" you exclaim, "look at all those damn bones! I don't want to animate that many damn bones! Has this David Rogers guy lost his mind!?" Well lets look at what it does and what we actually animate before we freak out okay? Okay here's what we have:
These are the only four bones we actually animate they are our control bones.
Pelvis this lowers the upper body and pushes the legs down, bends the knees, but it has no effect over the feet. The feet are controlled instead by the foot bone.
The foot bone can pick the foot up off the ground and this will push the leg up and bend the knee (in the right direction, but we'll get to that in a minute). Pointing the tip of the foot bone causes the knee to follow but it has no effect on any portion of the upper body and it won't build you a fire. This bone does a lot of stuff but there are other 'fine-tune' controls built in.
The Toe and the Heel, these are used to lift the toe and or the heel separate from the rest of the foot (tapping toes etc.). Lifting the heel will cause the leg to behave as you would expect it (bending knee etc.). For the most part these are secondary controls, but they are there for those times when you need em. So what the hell are the rest of these bones for? Lets continue with the targets...
Here are our targets. Some of them are overkill for an average range of motion setup but if for some reason you need to animate something out there this will hold your legs together for you. Lets take a peek at what they are doing here.
Thigh Roll Target is up there just to make the thigh behave, with this little bone in place there is no way the thigh can ever flip over and twist at the hip unless you point the foot backwards. It also rotates the thigh to adjust for the foot position giving a more natural positioning throughout the character's range of motion. (And even a little beyond a normal range of motion giving you plenty of leeway for exaggerated movement.)
Knee is the target that keeps the knee pointing in the right direction (strange naming convention I have, I know, but you'll just have to deal with it -- hehe) No matter what we do the knee will point in this direction so if we bring the pelvis down and the knee must bend this is the way it will go. If we lift the foot, same thing.
Toe and Foot Roll Targets live for only one reason, to keep the bottom of the foot from ever pointing up at the knees. These two are semi-optional but if you have any weird leg action going on, they solve all sorts of problems with toes or feet flipping over.
Ball Target This tells the foot to bend at the toe when walking or when using the heel or toe controls it defines how the foot and toe behave in relation to each other.
The other bones in there are the ones that are attached to the geometry; pelvis, thigh, calf, foot and tarsals down the chain respectively they are a standard bone chain attached to parent (or not) wouldn't make a whole lot of difference but they are attached.
So lets Build it!!!!
This is pretty much what you had in your example the only major change is that I like two bones for the foot, one toe and one foot. This gives me something to bend during walks or other things. The other change (VERY IMPORTANT) is the ROLL handles of each bone needs to be in a specific direction for the roll targets to work later. The Thigh and Calf bones should have the roll handles pointing directly forward, the foot and tarsal bones should've roll handles pointing down. Roll handles are not always that important but when they are I'll tell you. These bones get the geometry attached just as you described in your example.
But then we need to add our Control Structure. The layer of targets and controls that will get the bugger to do what we want.
The final hierarchy will look like this (I'm isolating the right leg, the left is just a mirror of it.)
Okay now, this is where the majority of our work is going to be done for us!
Point one -- hierarchy is king. Unless told to behave otherwise a child will inherit it's position and orientation from it's parent. The chain I showed above is the Pelvis, Thigh, Calf, Foot, Tarsal chain, those are our geometry bones. Each of these bones will inherit it's position and rotation from the bone directly above it in the chain or (since we attached to parent) the tarsal can control the entire chain up to, but not including the pelvis, using standard IK. But for our enjoyment and edification we have at the same level as the Pelvis the foot control structure as shown below:
|Control Bones Top View|
|Control Bones Front View|
Control Bones Left View
Control Bones Birds Eye View (with mesh for reference)
Okay so that's easy right? Good, talk to ya later..... what? You mean that's not 100% clear? Oh well here then....
WE start with the Right Foot Control Bone (which is the parent of the control structure) this bone needs to sit on the same level of the hierarchy as the pelvis so that our foot is not effected by the pelvis's gyrations. Click on the model in the PWS, this puts you at the top of the hierarchy (assuming you are in bones mode in A:M) hit the 'A' key or click the add button, starting at the junction of the Right Foot and the Right Tarsal bones draw the Right Foot Control bone forward so that it extends a good distance from the actual foot, this makes for easy selection when animating.
While you still have that bone selected draw a new bone as a child (but not attached) this is going to be the Right Knee Target so we need to position it in a place where it will control our knee in the most desirable fashion, this tends to be a ways in front of the leg and slightly below the knee joint, so lets put it there.
While this bone is selected lets add the Right Thigh Roll Target Bone. Again we want this bone in a place where it will do the most good. I have found that in front of the thigh and about waist to chest height is a good place (remember how we put our roll handles on the thigh forward? here's why we did that... more on that when we get to constraints...) I cock em to the side a bit so that I can easily see what's going on with what later, but that's not a requirement by any means.
Okay now back to the Right Foot Control. We have 5 more bones to add to finish our control rig. Four of which are direct children of the Foot Control Bone. Lets start with the Toe Target. Remember the toe control from above? Well this is it. Logic tells us that we want the toe to point at this bone when we move it we'll accomplish that with constraints but knowing that when you are telling a constraint to aim at a bone you are telling it to aim at the BASE of said bone we are left with only one place to start the toe target: at the tip of the tarsal bone. SO with the Right Foot Control selected we add a bone starting at the tip of the Right Tarsal bone and aiming upwards at a rakish angle (which is unimportant, but makes it easier to select when animating later on.)
Select the Right Foot Control again and moving back on major joint on our character's foot we come to the ball. Now we need a target that sits at the junction of the foot and tarsal bones to keep the relationship between those two geometry bones from being affected by any animation of the toe target giving us the ability to animate the toe without having any funky bending in the foot (say upwards at sharp angles at the arch or something.) So we draw a new bone at the Base of the Right Foot Control bone and upwards at a rakish tilt (mostly just to keep it out of the way) this is our Right Ball Target. Functionally speaking it is kind of a pin. That locks the aiming direction of the foot bone.
Again Select the Right Foot Control, moving back up the foot one more joint we come to the ankle, now wee need to have a bone here that will keep the calf and keep it pointing down at the foot, it will also serve as our heel control. So, we need this bone to describe the ankle joint and act as a control later, we will start by placing the base of the bone at the joint of the Calf and Foot bones and have it pointing back (again to make it easier to select later but it's specific direction is not that important) this is our Right ankle target.
Two more bones and we are home free (and when compared to some 500+ bone rigs trust me this is nothing...) these two bones are semi-optional they are there to keep the foot from flopping over (which is, trust me again, more of a problem than you'd think...) If you remember how I told you to have the roll handles of the Foot and Tarsal bones point down here is the reason. Select the Right Foot Control and add a new bone directly under the roll handle of the Right Tarsal Bone this is the Right Tarsal Roll Target. While that new bone is still selected add a second bone under the roll handle of the right foot bone, this child of the Right Tarsal Roll Target is the Right Foot Roll Target.
That's all the bones, most of our work is taken care of with the hierarchy all we have to deal with are a few simple constraints and the legs should behave.
Can you believe after all that we hardly have any actual work left? Take a gander at this:
That's all the constraints that our leg will require. It won't make your bed and fry you an egg in the morning but it will give you good control!
Start by creating a new Action. Yes action, you can make constraints in a pose but I use the same rig on each of my characters and by doing it in an action I can apply a constraint setup to a boned character just by opening the action with the new character and doing create pose from the action menu. This means that all the work you do to constrain your character is a one time investment, that unless you need to adjust a rig for a special circumstance all your characters get setup for the time spent on one... What a deal!
Okay now it's pretty clear what to do from the above image, apply the constraints as they are shown, and things should behave. But here's the why of it:
We take the Right thigh and we know that we want it to behave in a certain way. We want the roll of the thigh to limit itself so that it won't flip over (which we _could_ do with spherical limits but this is much less work and more predictable when you're animating.) So we have it aim it's roll handle which we thoughtfully pointed forward when putting the geometry bones into the character at the target that we put out in front of the character for just this purpose. Now since the target is a child of the Foot Control bone when we rotate the foot control the roll target goes with it which keeps the thigh roughly in-line with the toe as we animate, this makes for a very natural appearance throughout the range of motion. We also know that the tip of the thigh bone is in fact the Knee, and we want to ensure that this joint will not bend backwards. So we simply aim at the knee target that we thoughtfully placed in front of the character for just this purpose. Again since the Knee target is a child of the foot control we can rest assured that when we position the foot the knee will behave and for most circumstances it need not be adjusted, but if you need to move the knee out of line with the foot the target can always be animated separately.
Okay so after you do that you have a leg just pointing forward, not what we want at all, we need the calf to point down at the ground so that when we move the Right Foot Control the lower leg and the foot follow along, and so that when we move the pelvis they remain stationary. This is accomplished with the Kinematic Chain to Right ankle Target constraint on the calf. This brings the foot back into place and keeps the calf aiming down, and under the control of the foot control bone. A kinematic is a stronger version of the aim at that will affect the entire IK chain up the leg, so now when the ankle target moves not only does the calf follow, but the thigh by virtue of it's connected child moves as well this makes the knee bend (forward thanks to the aim at constraint) when the foot or heel comes off the ground yes that's right the heel too, if you grab that ankle target bone and translate it up the heel will lift off the ground because the Right Foot bone is a child of calf and attached to parent. Now if we hadn't attached this bone to the parent we would do that now with a Translate to constraint forcing the Right Foot bone to translate to the ankle target, but the forethought of attaching to parent makes that unnecessary.
Now all we need do is ensure that the toes and foot behave and follow the Foot Control bone properly. What we want to do is make sure that the foot follows the movement of the Control bone and that the toe and foot don't flip their roll handles on us later. So we add two constraints to each bone. The tarsal gets a kinematic to the Toe target which as a child of the Foot Control Bone will drag our little Tarsal bone along with it as it follows the control bon's movements. Tarsal also gets an aim roll at to the Tarsal roll target bone, this is something I added to fix toe flips when I animated things like marshal art kicks that sometimes bring the feet up high enough that the program looses it's frame of reference for the roll, this fixes that and puts the control for the roll orientation of the toes under the roll of the foot control bone. The Foot bone gets similar constraints but rather than the more powerful kinematic constraint it gets the aim at to the Ball target to keep it in line and has it's roll aimed at the foot aim target, for the same reasons. Okay now before we go any further lets save out constraint work into the model as a pose. First check that the frame bar at the bottom has all options unchecked except the key constraints button which must be down, and select Create Pose from the action menu. Now we have a pose that will apply the constraints to the right leg.
So grab the foot control and take her for a spin!
If it behaves the way you wanted then hide the bones that you won't need and get cracking on the left leg.
I think this answers the first round of questions, if there is anything that isn't clear let me know and I will address those points, primarily I want you to see _why_ I do a thing rather than just how I do it. If you get the why's you will be able to build a rig that suits your needs.