Advanced Rigging

Leg with Roll/Slide and IK/FK Switch

Introduction

This tutorial is a custom tutorial based on the classic IK/FK switch desribed in The Art of Rigging Volume 1 and the master class tutorial led by Jason Schleifer for SIGGRAPH 2006. The skeletal creation, mesh segmentation, and advanced foot controls are based on Animator Friendly Rigging, however we will not be implementing the stretch (which limits the complexity). Instead of the stretch, we will be using a method similar to the one described in The Art of Rigging. If you would like to learn more about creating an IK/FK switch or advanced foot controls, and further understand the concepts behind this tutorial, please view the origonal text: Animator Friendly Rigging Part 4 , pages 56 through 116 and The Art of Rigging Volume 1 pages 16 through 18 (available for purchase at CG Toolkit or you can ask Kendal nicely to borrow hers).

Tutorial

  1. Unhide l_shoes_geo and l_leg_geo
  2. Create joints for the leg, there should be one for the upper leg, lower leg, heel to ball of the foot, and ball to end of foot. Name the joints l_upLeg_joint, l_lowLeg_joint, l_foot_joint, l_toe_joint, l_toeEnd_joint.
  3. Segment the mesh (cutting at the kne on the l_leg_geo and cutting where the toes would bend on l_shoes_geo). The cuts in the mesh should corespond to the joint placement.
  4. Select l_upLeg_joint and click the "grep rename" button on the Rigging Shelf. Search for "l_" and replace with "l_fk_", make sure that the Duplicate then rename box is checked (so that you create a duplicate of the skeleton you just made).
  5. Delete the fk geometry so that you only have one set of leg geometry.
  6. Select l_fk_upLeg_joint and click the "grep rename" button on the Rigging Shelf. Search for "fk" and replace with "ik", make sure that the Duplicate then rename box is checked (so that you create a duplicate of the fk skeleton you just made).
  7. Create a new group by clicking Create > Empty Group. Click on the new group, then on all_anim and hit "p". Rename the null group "settings_grp".
  8. Create two more groups. Name them settings_anim and settings_visibility
  9. Select settings_anim and settings_visibility and then settings_grp and hit "p" to parent the anim and visibility settings under the settings_grp.
  10. Select settings_anim and lock and hide all attributes in the channel box (translate, scale, rotate, and visibility). Do the same for settings_grp and settings_visibility.
  11. Select settings_anim and choose Modify > Add Attribute. Enter an attribute name of l_leg_state. Set the Data Type to enum. Set the Enum names to fk and ik. Click okay.
  12. Connect up_leg with blender. Click on the connect blend button on the Rigging shelf. Set object1 to l_fk_upLeg_joint. Set object 2 to l_ik_upLeg_joint. Set target object to l_upLeg_joint. Set attribute to rotate. Set driver to settings_anim.l_leg_state. Click "Go".
  13. Connect low_leg with blender. Set object 1 to l_fk_lowLeg_joint. Set object 2 to l_ik_lowLeg_joint. Set target object to l_lowLeg_joint. Set attribute to rotate. Set Driver to settings_anim.l_leg_state. Click "Go".
  14. Connect foot with blender. Set object 1 to l_fk_foot_joint. Set object 2 to l_ik_foot_joint. Set target object to l_foot_joint. Set attribute to rotate. Set Driver to settings_anim.l_leg_state. Click "Go". Change the attribute to translate and click "Go" again.
  15. Connect toe with blender. Set object 1 to l_fk_toe_joint. Set object 2 to l_ik_toe_joint. Set target object to l_toe_joint. Set attribute to rotate. Set Driver to settings_anim.l_leg_state. Click "Go".
  16. Choose Create > Nurbs Primitives > Circle.
  17. Rotate the circle so that it is parallel to the side plane (you should be able to achieve this with 90 degree rotations). Freeze transformations on the circle.
  18. Click on the circle and then l_fk_upLeg_joint and use the shape script to parent the shape to the joint. Click F8 to modify vertices and make the circle fit around the joint (please refer to AFR4 page 75 and on to see how to shape the FK controls... this will be MUCH more clear than just reading through this text).
  19. Create controls in the same manner (transfering shape, modifying vertices) for the lower leg, foot, and toes. Create a new nurbs circle for each control, don't just duplicate the original.
  20. Delete the free floating shapes when you are done, only the controls around the joints should be left.
  21. Fix the names of the l_fk_upLeg_joint, l_fk_lowLeg_joint, l_fk_foot_joint, l_fk_toe_joint by selecting them and clicking the add suffix button in the Rigging Shelf. Change the suffix to anim and click "add suffix".
  22. Fix the names of the shapes by selecting the nurbsShapes that are children of the anim controls. Click the Rename Selected as Parent button in the Rigging Shelf. Add "Shape" onto the end of each name, so the shapes should be called l_fk_upLeg_animShape for l_fk_upLeg_anim.
  23. Hide the fk leg so that we can work on the ik leg (select l_upLeg_anim and hit ctrl+h). Change l_leg_state in settings_anim from fk to ik.
  24. Set l_upLeg_joint so it can’t be selected. Select l_upLeg_joint. In the display layer editor, select doNotTouch_layer. Choose RMB > add selected objects
  25. Select l_ik_lowLeg_joint and open the attribute editor. Rotate the leg so that the heel comes towards the butt, take note of which axis the joint is rotating around (there should probably be a positive rotation in the Rotate Y field. In the attribute editor and type the number in the Rotation field into the Prefered angle field.
  26. Go to Skeleton > IK Handle Tool > Options, change the solver to ikRPsolver and click on l_ik_upLeg_joint and then l_ik_foot_joint.
  27. Change the solver type to ikSCsolver and create ikHandles from the foot to the toe and the toe to the toeEnd.
  28. Rename the ikHandles for what they represent. Rename ikHandle1 to l_leg_ikHandle. Rename ikHandle2 to l_foot_ikHandle. Rename ikHandle3 to l_toe_ikHandle
  29. Hide all_anim so that it doesn't get in your way.
  30. Create a nurbs curve for the foot control, snap it to the heel joint (so that it is a little bit above the top plane) and then move the vertices so that they fit around the foot. Rename the control l_foot_anim.
  31. Put pivot on l_foot_joint. Select l_ik_foot_joint then l_foot_anim. Click on the copy pivot button in the Rigging shelf.
  32. Create heel pivot. Choose Create > Locator. Move the locator to the location of the heel (YOU NEED TO LOOK AT THE AFR4 NOTES FOR THIS! IF YOU MESS UP, THE FOOT DOESN'T WORK CORRECTLY! REFER TO PAGE 92 AND ON). Rename locator1 to heel_loc.
  33. Create ball pivot. Choose Create > Locator. Move the locator to the position of l_ik_toe_joint. Rename locator1 to ball_loc.
  34. Create toeWiggle pivot. Choose Create > Locator. Move the locator to the position of l_ik_toe_joint. Rename locator1 to toeWiggle_loc.
  35. Create toe pivot. Choose Create > locator. Move the locator to the position of l_ik_toeEnd_joint. Rename locator1 to toe_loc.
  36. Add side to side locators. Choose Create > locator. Move the locator to the inside of the foot. Rename locator1 to inside_loc. Choose Create > Locator. Move the locator to the outside of the foot. Rename locator1 to outside_loc.
  37. Re-order the hierarchy. READ THIS VERY CAREFULLY, and maybe a few times...
                l_heel_loc under l_foot_anim
                l_toe_loc under l_heel_loc
                l_outside_loc under l_toe_loc
                l_inside_loc under l_outside_loc
                l_ball_loc + l_foot_ikHandle + l_toeWiggle_loc under l_inside_loc
                l_toe_ikHandle under l_toeWiggle
                l_leg_ikHandle under l_ball_loc
  38. Add Attributes to foot_anim. Select l_foot_anim. Click on the quick add attribute button on the Rigging shelf. Add "roll toeLift toeStraight lean side toeSpin toeWiggle" (don't use quotes, but keep the spaces exactly where they are, this will add roll, toeLift, toeStraight, lean, side, toeSpin, and toeWiggle attributes independently of eachother.
  39. Create a new expression, LFT_foot_expr for all the foot controls. Go to Window > Animation Editors > Expression Editor. Change the select filter to "by expression name", type "l_foot" into the expression name. Type the following into the expression field.
                $roll = l_foot_anim.roll;
                $toeLift = l_foot_anim.toeLift;
                $toeStraight = l_foot_anim.toeStraight;
                $lean = l_foot_anim.lean;
                $side = l_foot_anim.side;
                $spin = l_foot_anim.toeSpin;
                $wiggle = l_foot_anim.toeWiggle;

                l_heel_loc.rotateX = min($roll,0);
                l_ball_loc.rotateX = (linstep(0, $toeLift,$roll)) * (1-(linstep($toeLift, $toeStraight, $roll))) * $roll;
                l_toe_loc.rotateX = linstep($toeLift, $toeStraight, $roll) * $roll;
                l_ball_loc.rotateZ = $lean;
                l_outside_loc.rotateZ = min($side,0);
                l_inside_loc.rotateZ = max($side,0);
                l_toe_loc.rotateY = $spin;
                l_toeWiggle_loc.rotateX = $wiggle;
  40. Hit "create" to make the expression.
  41. Group everything except l_foot_anim together and call it "l_leg_ctrl_grp"
  42. Group l_leg_ctrl_grp and l_foot_anim together into a group called "l_leg_grp"
  43. Put l_leg_grp into anim_grp.
  44. Hook up the legs to the hip controls. Parent the leg_grp under the anim_grp. Press the insert key while you have the leg_grp selected and hold down "v". Move the pivot of the group to the top of the l_upLeg_joint. Move the pivot of l_leg_ctrl_grp to the top of the l_upLeg_joint.
  45. Duplicate the l_leg_ctrl_grp, delete all it's children and call it l_leg_ctrl_pos. Parent l_leg_ctrl_pos under hip_anim.
  46. Parent constraint l_leg_ctrl_grp to l_leg_ctrl_pos.
  47. Done!