Twist joints and low-res mesh
To create the twist joints, we will once again use the Joint Splitter script
. First, select l_upperLeg_jnt and hit Ctrl+D to duplicate it. Hide the original joint chain (Ctrl+H) and from the newly created chain, delete the following joints: l_ankleTwist_jnt, l_ankle_jnt, l_ball_jnt and l_toeEnd_jnt. Then rename the remainder of the joints randomly so they do not clash with our original joint chain when we use the script.
In the Script Editor, load the Joint Splitter script into a MEL tab and execute it to bring up the GUI. Select the root joint from our duplicated joint chain and click Select Start Joint on the Joint Splitter tool. Set the Jnt Qty to 3 and hit Split Joints. Then select the lower leg joint and do the same again. We now want to get rid of the unnecessary joints. Start by selecting the end joint of the chain and deleting it. Then select the third joint up from the end of the joint chain and un-parent it (Shift+P). We should now have 2 independent joint chains. For the upper leg joint chain, select the end joint and delete it. Then select the second joint in the joint chain and hit Shift+P to un-parent it. You should have a single joint left over which you can select and delete.
Using the Joint Splitter tool to do exactly that, split the joints
Select all the remaining joints now and hit Shift+P so they are all independent. Rename them from top to bottom as follows: l_upperLegTwistA_jnt, l_upperLegTwistB_jnt, l_upperLegTwistC_jnt, l_lowerLegTwistA_jnt, l_lowerLegTwistB_jnt and l_lowerLegTwistC_jnt. Now select the upper leg twist joints and parent them under l_upperLeg_jnt. Then select the lower leg twist joints and parent them under l_lowerLeg_jnt.
The next thing to do is to chop up the geometry and to parent the relevant mesh to the relevant joint. I do this by duplicating the main mesh, deleting all the unnecessary polygons and then using the Mesh > Extract tool to split the mesh up. Once you have all the individual pieces, select them all and go Edit > Delete By Type > History. Finally, parent the relevant part of the geometry to the relevant joint. Remember to rename the geometry appropriately also.
The twist joints parented under the relevant joint
Adding the IK and FK joints and creating the FK controls
Select l_upperLeg_jnt and hit Ctrl+D to duplicate it. Open up the hierarchy for the newly created joint chain in the Outliner and delete all the twist joints and the geometry that has come along for the ride. Now select the root joint for the new chain and go Modify > Search and Replace Names. When the window pops up, type _jnt in the Search for space, and _FK_jnt in the Replace with space. Then take the 1 off the end of l_upperLeg_FK_jnt. Now duplicate l_upperLeg_FK_jnt and use the Search and Replace Names tool to rename _FK_jnt to _IK_jnt.
Duplicating the original leg chain to create the FK and IK set
Hide the original joint chain and the IK joint chain for now so we can create the FK controls. Open up the Script Editor and load the createControls.py script into a Python tab. Select l_upperLeg_FK_jnt, l_lowerLeg_FK_jnt, l_ankleTwist_FK_jnt, l_ball_FK_jnt and then execute the script. Now to correct the control hierarchy. First parent l_ball_FK_ctrl_offset under l_ankleTwist_FK_ctrl. Then parent l_ankleTwist_FK_ctrl_offset under l_lowerLeg_FK_ctrl_offset. Next parent l_lowerLeg_FK__ctrl_offset under l_upperLeg_FK_ctrl. Lastly, parent l_upperLeg_FK_ctrl_offset under hip_FK_ctrl. If needed, reshape the controls to make them more easily selectable. Remember to do this in component mode by hitting F8.
Creating the FK controls using the createControls.py script
IK leg controls part 1
Hide the FK joint chain and the controls for now and then un-hide the IK joint chain by selecting it in the Outliner and hitting Shift+H. Let's now add the IK handles that will drive the leg and the foot. Go Skeleton > IK Handle Tool (Options) and set the Current solver to Rotate-Plane Solver. Then in the Outliner, click l_upperLeg_IK_jnt and then l_legEnd_IK_jnt. Rename the newly created IK handle to l_leg_IK. Now go Skeleton > IK Handle Tool (Options) and set the Current solver to Single-Chain Solver. Then in the Outliner, click on l_ankleTwist_IK_jnt first and then l_ball_IK_jnt. In the video, I first create the IK handle between l_ankle_IK_jnt and l_ball_IK_jnt, but do correct this later on. Rename this IK handle to l_ball_IK. Then create another Single-Chain IK between l_ball_IK_jnt and l_toeEnd_IK_jnt rename it l_toe_IK.
To create the control for the IK leg, select l_arm_IK_ctrl_offset and duplicate it (Ctrl+D). Then un-parent it by hitting Shift+P. Use the Search and Replace Names tool to Search for _arm and Replace with _leg. Also get rid of the 1 on the end of the offset node. To position the control correctly, parent l_leg_IK_ctrl_offset under l_leg_IK and then zero out the translate values in the Channel Box. Once in place, with l_leg_IK_ctrl_offset still selected, hit Shift+P to un-parent it from l_leg_IK. Now parent all three IK handles under l_leg_IK_ctrl. Lastly, with l_leg_IK_ctrl selected, in the Channel Box, go Edit > Edit Attribute and rename elbowTwist to kneeTwist and armTwist to legTwist.
The IK leg control in place and the IK handles parented below
IK leg controls part 2
Now we need to add an extra IK leg chain to allow for the twist of the lower leg, just like we have done for the IK arm. Start by selecting l_upperLeg_IK_jnt and hitting Ctrl+D to duplicate it. Select the root joint for the duplicated joint chain and go Modify > Search and Replace Names. Set Search for to _IK and Replace with to Drive_IK. Once again, remove the 1 at the end of the root joint.
Now to constrain the original IK joint chain to the driver set. First, select in this order, l_upperLegDrive_IK_jnt, l_upperLeg_IK_jnt and go Constrain > Orient (Options). Make sure the Constraint axes is set to All and hit Apply. Now, select in this order, l_lowerLegDrive_IK_jnt, l_lowerLeg_IK_jnt and go Constrain > Orient (Options). This time, set the Constraint axes to X and Z only. Then select, in this order, l_ankleTwistDrive_IK_jnt, l_ankleTwist_IK_jnt and go Constrain > Orient (Options). Turn All back on for Constraint axes and hit apply. Lastly, select in this order, l_ballDrive_IK_jnt, l_ball_IK_jnt and go Constrain > Orient, keeping the settings the same.
Now, select the lower leg joint for each leg, and one at a time, set the Rotate Order to YZX in the Attribute Editor.
Constraining the original IK leg chain to a driver set of joints and making sure not to constrain the rotate Y attribute on the lower leg