In the previous movie, we added the ability to stretch both the IK and FK arms.
In this movie, we'll create an elbow control for the IK arm.
Start by opening the file "24-0-Character_Rigging_part24_start.mb"
or by using your own file from the previous lesson.
As you may recall from rigging the leg in part 14,
we created a pole vector constraint for the leg's IK handle to point the knee at the locator.
We also developed a no-flip solution where we set up a "Knee Twist" attribute to orient the knee,
and by extension, the leg, to facilitate animating certain motions, such as walk cycles.
However, because of the wide range of movement for the arm,
an animator will most often want to have direct control over the elbow's twist.
Therefore, a no-flip solution wouldn't be very useful,
so we aren't going to bother worrying about it.
This simplifies our rig requirements considerably
because we only need to deal with this one IK arm,
instead of implementing a "dual IK arm" system.
Let's start by creating the elbow control itself.
Create a locator and rename it "leftElbow_LOC".
Point snap it to the forearm joint and then translate it back a bit in Z.
Select the locator, then the leftArm_HDL, and select Constrain > Pole Vector.
We can now aim the elbow by moving the locator.
Just like the knee though, we'd prefer to have a NURBS curve control
rather than this locator to stay consistent with the rest of our controls.
Since the elbow and the knee are so similar in function,
let's use the leftKnee_CTRL as reference.
Select the leftKnee_CTRL and go to Edit > Duplicate Special.
Reset the settings and then switch the "Group under" option to "World".
This will re-parent the duplicate to the world so we can find it easily.
Rename the curve "leftElbow_CTRL" and delete all its child nodes.
Let's also remove this control from the legs_IK_LYR
and instead add it to the arms_IK_LYR.
Just like the arm IK control, we want to center this control at 0.
Grid snap it to the origin then freeze its translation.
Since the elbow faces the opposite direction from the knee,
we actually need to select all the control vertices at its tip
and pull them to the other side so it points the correct way.
Point snap the curve to the leftElbow_LOC, and then parent the locator under the curve.
Save your new control's transform preset as "leftElbow_CTRL_bind"
Great, now we have a working elbow.
Next let's work on a snap attribute.
You'll remember that we set up this functionality in part 16
to pin the knee in place and animate the rest of the body around it.
Here we'd like to mimic that functionality for the elbow.
We'll accomplish this as we did before,
by scaling the upper arm and forearm IK joints to meet the leftElbow_CTRL.
First, use the Distance Tool to create two measurements,
one with the upper arm joint to the leftElbow_CTRL
and another from the leftElbow_CTRL to the hand joint.
Rename them appropriately.
We'll also need to parent them to the appropriate controls so the distances adjust correctly.
Now that we know these distances,
we just need to extend the upperarm and forearm to the elbow control when appropriate.
First, let's remove the "Knee Snap" attribute from the elbow control,
and replace it with an "Elbow Snap" attribute.
Select the leftForeArm_IK_JNT,
leftUpperArm_to_elbowDistance node, and leftElbow_CTRL.
Open the Node Editor and display the connections.
Remember, we want to choose between the upperarm stretching
according to the overall arm length versus the elbow snap.
Create a Blend Colors node and rename it "leftUpperArm_stretchChoice".
Use the leftElbow_CTRL's "Snap" attribute to drive the "Blender" attribute.
Now we want to blend between either the entire arm length, or the upper arm to elbow distance...
... so feed the leftUpperArm_to_elbowDistanceShape node's
"Distance" attribute into the blend node's "Color 1R".
Then feed the leftForeArm_IK_JNT driven key animation node's output
into the blend node's "Color 2R".
Finally, feed the "Output R" of that blend node into the "Translate X" attribute of the forearm IK joint.
We'll have to do the same thing for the forearm using the animation curve of the hand joint.
Excellent, now we can plant the elbow and move the hand and body around it!
As always, we'll hide all the locators and distance nodes.
Now, as nice as this is, there is a case we should consider that differs from the knee.
Because of the leg's typical range of motion,
movement of the shin tends to be quite limited once the knee is planted.
Any situation where it can move would be more easily handled in FK mode anyway.
However, for the arm there's all kinds of movement we can do when the elbow's pinned.
For example, we can bring the arm up to rest our head in it,
bring it down to grab an object on a table, or even move back and forth in a heated arm wrestle.
However, many of these movements don't lend themselves well to an imprecise IK control.
In the next movie, we'll outfit our IK elbow control with an FK forearm
to make these kinds of movements easier for the animator.