Thursday, May 15, 2014

Rigging tutorial 2

This is the english translation of the second part of a rigging tutorial I wrote.

Leg and foot rig

Leg and foot rig requires several additional bones. Three of these are IK "handles" which are manipulated during animation and three are invisible targets used internally by IK solver.


We normally want major skeletal bones to be connected and placed in anatomically correct way (foot attached to shin, toe attached to foot) to avoid unnatural stretching of body. On the other hand rigging requires targets to be attached to handles so they move together in animation. Thus we have to add three additional invisible bones that will determine the placement of heel, foot and toes.

Select the skeleton, switch to Edit Mode and select the endpoint of left shin (heel). Create mirrored bones (Shift-E) that extends 20cm backwards. Rename these new bones to Tgt_Heel_L and Tgt_Heel_R.

Tgt_Heel_L placement

In similar way create a pair of bones at the end of foot and another pair at the end of toe. Rename the first to Tgt_Foot_L/R and the second to Tgt_Toe_L/R.

The placement of foot and toe targets

These are the targets of leg IK solver. Later we connect these to a proper parent bones and move to an invisible skeleton layer because these are never animated directly.


The most important one is foot handle that determines the placement of heel and the direction of foot.
Select the endpoint of left shin (heel) and create pair of bones (Shift-E) extending about 20cm forwards. Rename these to IK_Foot_L and IK_Foot_R.


Foot handle has to be the child of Base and it has to lay exactly and ground level. It's origin has to be at the "rolling" point of heel (the back border of heel mesh) and endpoint below the toe joint.
Switch to wireframe mode (Z) and select IK_Foot_L.
From the bone properties panel switch off Connected checkbox and from Parent menu select Base as the new parent.

Bone Properties panel

Repeat the same procedure with the mirrored partner (IK_Foot_R).
Now select IK_Foot_L again and move it exactly to the ground level, then place the origin to the back edge of the heel and stretch the endpoint to below the toe joint.

The placement of IK_Foot_L
From the end of IK_Foot_L create mirrored bones (Shift-E) extending forwards. Rename these to IK_Toe_L and IK_Toe_R.


Assign more intuitive shapes to all handles. Simple blocks below ground will do.

Shaped foot and toe handles

Now we have to set up the proper hierarchy of target bones.
Disconnect Tgt_Heel_L (disable Connected checkbox) and set it's parent to IK_Foot_L.

Bone Relations panel

Do the same for Tgt_Heel_R (it's parent is, of course, IK_Foot_R).
Disconnect Tgt_Foot_L/R and set their parents to IK_Foot_L/R.
Disconnect Tgt_Toe_L/R and set their parents to IK_Toe_L/R.
All target and handle bones are now properly placed and connected.

Next we create the main IK chain of leg.
Select left shin and add Inverse Kinematics constraint from Bone Constraints panel.

IK constraint panel

On Target field select the armature object. On the new field Bone that appears select heel target (Tgt_Heel_L)
Set the length of the chain to 2 bones (thigh and shin).
Confirm now that by moving foot handle (IK_Foot_L) the whole leg bends, trying to keep the heel joint at the place determined by heel target bone.
Unfortunately sometimes leg twists unnaturally because IK solver does not "know" at which direction the knee should bend. To solve this we add two "handles" that determine the direction of knees.

Select the end of IK_Foot_L and create mirrored bones (Shift-E). Rename these to IK_Knee_L and IK_Knee_R.
For both created bones disable Connected on Bone Properties panel and move them to a place approximately in front of the knees.

The placement of knee targets

Select again the shin of the left leg. On Bone Constraints panel set Pole Target to the armature object and corresponding bone to IK_Knee_L.
Depending on how the local coordinate system of thigh bone is oriented the knee may now twist 90-180 degrees. Pole Target orients one of knee axes (default X) to the target object and if the X axis is, for example, oriented sideways the knee twists.

Twisted leg

If the bone is twisted change the Pole Angle field to either 90, 180 or -90 degrees until the knee is oriented correctly (by modifying this field we force some other local direction is oriented towards pole target instead of X axis).

Adjusting Pole Angle
Now change the shape of knee handles to something intuitive (for example icosahedron).

Knee direction handle

Confirm that by moving knee handle left and right the leg rotates so that the knee is always oriented towards the handle.
The main IK chain of left leg is now complete. Identical chain has to be created for right leg as well.

Rotating feet

Incorrect foot orientation

To guide the turning of foot ensure first that the local Z axes of foot and toe bones is oriented upwards. If they are not (like on figure) select the bone, switch to Edito Mode and adjust the Roll value on Bone Properties panel.

Bone Roll setting

Repeat the same procedure with toe bone if needed.
Now switch to Pose Mode and add Track To constraint to the left foot. On Target field chose the armature object and on Bone field Tgt_Foot_L. Enable Target Z checkbox so that the local Z-axis of foot would always be oriented as close as possible to the local Z-axis of target bone.

Track To constraint panel

Confirm now that if the foot handle(IK_Foot_L) is rotated the foot rotates with it.

Now select the toe bone (it is easier to do that in wireframe mode) and add Track To constraint to it. On Target field select armature object and on Bone field Tgt_Toe_L.
Confirm that if the toe handle is rotated toe rotates.
Add similar constraints to the right foot as well.

The IK of legs is now complete.

The hierarchy of skeleton root should be following:

The root of armature hierarchy

The third part of the tutorial: arms, upper body, eyes

No comments:

Post a Comment