In the previous movie, we created a snappable knee that allows us to plant it in a specific spot.
In this movie, we’ll add non-uniform stretching to the no-flip leg
and then start cleaning up the leg rig.
Start by opening the file "17-0-Character_Rigging_part17_start.mb"
or by using your own file from the previous lesson.
By creating a snappable knee, we also inadvertently added the ability
to scale each of the pole vector leg joints non-uniformly.
Likewise, the FK joints also have the ability to scale non-uniformly as well.
In order to guarantee parity, we should really add this ability to the no-flip leg.
In the leftLeg_settings_CTRL, set the leg to IK, and the knee to "Auto" mode.
Now, let’s add a new attribute to the leftFoot_CTRL called “autoKneeThighLength”.
Set a minimum value of 0 and the default value of 1.
Create a second attribute for the shin called “autoKneeShinLength”
and give it the same min and default values.
We’ll use these new attributes to manually adjust the length of the thigh and shin no-flip IK joints.
Select the leftFoot_CTRL, and no-flip shin and foot IK joints.
Open the Node Editor and show the connections.
If we take a moment to look at the Node Editor, notice that our thigh’s length,
determined by the "Translate X" value of the shin joint,
is already calculated by this animation curve node.
Remember that this represents the driven key scaling we created for the entire no-flip IK leg
in part 14 of this series.
Create a Multiply Divide node and rename it "leftThigh_noFlipScale_MULT".
To scale the thigh specifically, we just need to connect the "Auto Knee Thigh Length" attribute
from the leftFoot_CTRL to the “Input 1X”.
And the "Output " of the driven key animation for the shin into the “Input 2X”.
Then replace the no-flip shin’s incoming connection to its Translate X attribute,
with the "Output X" of the Multiply Divide node.
You can now extend the thigh using the attribute on the leftFoot_CTRL.
We’ll hook up the shin length attribute the same way.
Create another Multiply Divide node and rename it “leftShin_noFlipScale_MULT”.
Connect both the "Auto Knee Shin Length" attribute from the leftFoot_CTRL
and the “Output” of the driven key animation for the foot as inputs.
Then replace the existing input to the no-flip foot’s “Translate X” attribute
with the “Output X” of the Multiply Divide node.
Now we can scale each part of the leg individually as well as a whole.
We're ready to consult our general rigging checklist.
First, are our controls easy to use?
The IK controls are pretty simple and straightforward, so let’s switch to FK mode.
Our FK controls don’t appear because they’re assigned to a layer that's currently hidden.
This back-and-forth visibility toggling
seems like it could potentially be annoying for the animator, doesn’t it?
Why don’t we streamline this by having the FK controls appear automatically in FK mode,
and the IK controls appear in IK mode?
Start by adding some custom Boolean attributes to the leftLeg_settings_CTRL
including "FK_visibility", "IK_visibility", and "knee_visibility".
Use the Connection Editor to connect these attributes to the "Visibility" attributes
of the leftThigh_FK_CTRL, leftFoot_CTRL, and leftKnee_CTRL respectively.
Now you can toggle the visibility of these controls with these attributes.
Next, let's tie the visibility of our controls to the blend mode we’re in.
Open the Set Driven Key window and load the leftLeg_settings_CTRL
as both the driver and driven.
Set the "FK / IK Blend" attribute to 0 and the "FK Visibility" to "On".
Set a driven key between them.
Now set the "FK / IK Blend" to 1 and turn off the "FK visibility", then set another key.
The FK joints automatically turn on and off when you switch from FK to IK mode.
Repeat this for the IK controls.
Now the controls’ visibility automatically turns on and off in their respective modes,
but we can also override them via the visibility attributes.
It's important to note that this new functionality overlaps with that of the display layers.
This could create some confusion for the animator.
In order to eliminate the confusion, it'd be best to either remove the IK and FK leg layers,
or hide these attributes, depending on your animator's preference.
For the sake of versatility, we'll leave both avenues open.
However, while turning the opposing controls’ visibility off when in IK or FK mode makes sense,
what about when we're between states?
These states represent a blend between IK and FK,
so really both controls should be visible at the same time.
So set two driven keys for both sets of controls in their visible state
when the blend attribute value is anywhere between 0.001 and 0.999.
Now the appropriate leg controls appear in IK, FK, and blended states.
We'll set a driven key for the knee control exactly as we did for the IK and FK controls,
but this time connecting the knee control's visibility
to the "Auto / Manual Knee Blend" attribute.
The leftKnee_CTRL should disappear when in Auto mode.
Finally, group the leftKnee_CTRL into a "leftKnee_GRP".
Now set a new driven key to connect the visibility of this group to the leftLeg_settings_CTRL's
"FK / IK Blend" attribute such that the control will never appear in FK mode.
That’s quite a bit of cleanup so far, but we’ve only scratched the surface of our checklist.
In the next movie, we’ll finish cleaning up our leg and integrate it into our entire rig.