In the previous movie, we added the ability to scale the no-flip leg non-uniformly
and connected the visibility of the controls to the current IK/FK blend mode.
In this movie, we’ll clean up our leg rig according to our checklist.
Start by opening the file "18-0- Character_Rigging_part18_start.mb"
or by using your own file from the previous lesson.
So far we've confirmed our controls are easy to use.
We also know from the work we did in part 12 of this series,
that the local rotation axes are set correctly for all legs.
A quick check confirms that the values for both the leg and foot rigs are zeroed appropriately
and that the rotation orders are consistent.
The next thing we should do is hide anything we don’t want the animator to touch.
First select everything related to the leg and foot and group it into a “leftLeg_GRP” node.
Make sure that you don’t include the settings_GRP.
Parent this group to the emma_root_transform_CTRL.
Next, take all the distance nodes, start locators, IK joints, and result joints,
and group them under a “DO_NOT_TOUCH_GRP”.
We're going to hold off on locking and hiding attributes for the time being
and instead work on getting the leg to move in conjunction with the rest of the body.
The reason for this is because we're going to need these attributes available for our constraints.
Group all the measurement start locators along with all the IK joints into a “leftLeg_IKConst_GRP”.
into a “leftLeg_IKConst_GRP”.
Likewise, group the result joints into a "leftLeg_resultConst_GRP".
Set the result_skeleton_LYR to Reference mode and point snap the pivots of both these groups
to the thigh joint.
Notice that if you select both groups and translate them, the leg moves from the thigh.
That means all we need to do is constrain these groups to the hip bind joint,
which is the key joint controlling the base of the spine.
Create a new locator named “leftLeg_hipSpace_LOC”.
Point snap it to the thigh joint,
and parent it under torso_GRP > DO_NOT_TOUCH_GRP > hip_bind_JNT.
Now point constrain both the leftLeg_IKConst_GRP
and leftLeg_resultConst_GRP to this space locator.
Next we'll do the same with the FK leg. Switch over to FK mode.
Recall when we were connecting the FK neck to the body in part 9,
we allowed the head to move in various spaces.
We’d like to do the same thing here.
First, create a group for the FK leg chain named "leftLeg_FKConst_GRP"
and move its pivot to the thigh joint.
Like the IK leg, point constrain this group to the hip_bind_JNT. (Correction: HipSpace_LOC)
The FK leg follows the hips as expected.
Unlike the head, this is the only translation space we need to cater to,
since the leg is directly attached to the hip.
Conversely, we will want the ability to switch the leg's rotation
between hip space, upper body space, and root space.
Since we already have a locator for the hip space,
duplicate it twice more and rename the duplicates "leftLeg_bodySpace_LOC"
and "leftLeg_rootSpace_LOC".
Re-parent each of these locators under the torso's DO_NOT_TOUCH_GRP
and the emma_root_transform_CTRL respectively.
Select the space locators in the order we created them,
and orient constrain both the leftLeg_FKConst_GRP
and leftLeg_resultConst_GRP to them.
Now add an "FK_rotationSpace" attribute to the leftLeg_settings_CTRL.
Set the Data Types to "Enum" with the three spaces as options.
Open the Set Driven Key window.
Use the leftLeg_settings_CTRL as the "Driver" and both the leftLeg_FK_const_GRP
and leftLeg_result_const_GRP orient constraints as "Driven".
Set the weighting in each mode, just like you did with the neck in part 9.
Everything looks like it's working great.
However, try twisting the hip then switching back to IK mode.
The leg is now completely offset from the foot control, which makes it unusable for the animator.
The problem stems from the fact that we orient constrained the result leg
to the space locators according to the FK rotation space.
However, because the IK leg also uses this result group, the effect is bleeding over
and causing problems even when we're in IK mode.
What we need to do is blend the result group between the FK orientation space
and the IK space.
Then we’ll control the blender attribute
by connecting it directly to the Setting’s "FK / IK Blend" attribute.
Select the leftLeg_resultConst_GRP and open the Node Editor. Show the connections.
Create a Blend Colors node and rename it "leftLeg_resultOrientChoice".
Connect the leftLeg_resultConst_GRP orientConstraint's "Constraint Rotate" attribute
to the blend node's Color 2 attribute.
Set Color 1 to 0, 0, 0.
Now connect the leftLeg_settings_CTRLs' "FK / IK Blend" attribute to the "Blender" attribute.
Connect the "Output" of this new blend node to the "Rotate" attribute
of the leftLeg_resultConst_GRP.
Now the leg is affected by the orientation spaces in FK mode,
but not at all in IK mode, and we can blend nicely between them.
Once you've tested the various modes adequately,
lock and hide all the newly created group nodes' attributes and hide the space locators.
Next, we need to do is make sure our leg works within our rig’s root transform.
If you try translating and rotating the root node while the leg rig is either in IK or FK modes,
you’ll see these work fine.
If you try scaling the rig in FK mode, you can see this is also taken care of.
The only real problem is when you scale in IK mode. The leg scales disproportionately.
This is happening because our shin and thigh scale calculations
aren’t taking the root scale into account.
We’ll fix this just as we did for our torso and neck rigs by using a Multiply Divide node.
Select the leftLeg_noFlip_IK_length and leftLeg_pv_IK_length shape nodes,
the no flip and pole vector joint chains, and display their connections in the Node Editor.
Create two Multiply Divide nodes named “globalScale_leftLeg_noFlipNormalize_DIV”
and "globalScale_leftLeg_pvNormalize_DIV”.
Feed the "Distance" measurement of the respective legs into the “Input 1X” of both nodes.
Also feed the "Scale Y" of the root transform into the "Input 2X" of both nodes.
Make sure to change their Operations to Divide.
Now connect them each to the “Input” of the shin and foot driven key animation nodes
that determine the length of each portion of the leg.
Now if you scale up and down the leg scales properly.
Now we're ready to lock and hide any extraneous attributes.
Lock and hide all the transform attributes and "Visibility" attribute on the leftLeg_settings_CTRL.
Also lock and hide the "Scale" and "Visibility" attributes on the leftFoot_CTRL.
On the leftKnee_CTRL, lock and hide everything
except for the "Translate" and "Knee Snap" attributes.
And on the leftKnee_GRP, lock and hide everything.
Switching over to the FK controls,
lock and hide everything except the “Rotate” attribute on all the FK controls
as well as the "Length" attributes on the thigh and shin.
Now animators can only modify what we want them to modify.
That completes our checklist, which means we’re now finished with the leg!
In the next movie we’ll begin tackling the IK foot rig.