Begin by creating a distance dimension node for the arm. You will do
this the same way you created the distance dimension for the clav to shoulder.
This begins the controls that cause the arm to stretch.
-
Go to Create, Measure Tools, Distance Tool to activate the Distance
tool.
-
Now click with the mouse once in the general area of the shoulder
and again in the general area of the wrist. You will get two locators,
most likely named locator1 and locator2. Rename these locators shoulderPoint
for the locator near the shoulder, and wristPoint for the locator
near the wrist. Also rename the distanceDimension node armDistance_distanceDimension.
-
Select the shoulderJoint node, Shift+select the shoulderPoint locator,
and point-constrain the locator to the shoulder by using Constrain,
Point. Next, point- constrain the wristPoint locator to the armWrist_IkControl
by selecting the armWrist_IkControl, Shift+selecting the wristPoint
locator, and again performing the menu command Constrain, Point. Finally,
select the two locators and the distanceDimension node, and group
them using the Ctrl+g keyboard combination. Name this new group armDistanceGroup
(see Figure 17.54).

Figure 17.54
Setting up the constraints for the stretchy arm.
-
Parent the armDistanceGroup node under the connectToSpine joint node
so that it is part of the hierarchy that will comprise the arm.
Next, you will create a bunch of math utility nodes to create a node-based
expression network. These nodes were built in Maya traditionally for
rendering, but they are more commonly being used for character rigging
as well.
-
Open the Hypershade window by clicking Window, Rendering Editors,
Hypershade, and go to the Create, Create New Node menu. This launches
the Create Render Node window. Next, click the tab labeled Utilities
and create the following series of nodes (you will create four total
utility nodes—see Figure 17.55):
Create three multiplyDivide nodes and rename them armScaleRatio,
autoStretchMultiplier, and armScaleMultiplier.
Create one Condition node and rename it shortenToleranceCondition.
Figure 17.55
Setting up the utility nodes for the stretchy arm.
Next, you will create a few attributes that an animator can use to
control the stretchiness of the character's arms.
-
Select the armWrist_IkControl and load up the Add Attribute window
by going to Modify, Add Attribute.
-
In the Add Attribute window, create three float data type attributes
with the following names and settings:
autoStretch (min 0, max 1, default 1)
shortenTolerance (min 0, max 1, default 1)
armScale (min 0, max 10, default 1)
Now it is time to get started connecting some attributes to create
our stretchy IK arm.
Because you already have the Hypershade window open, you will use
it (instead of the Hypergraph) to make all of your node connections.
-
Choose the Utilities tab from the Hypershade, and select all four
of the new utility nodes that you just created. Shift+add to the selection
the armDistance_distanceDimension node and the armWrist_IkControl
node from either the Hypergraph or the 3D view port. Now, with the
current active selection in the Hypershade, click the menu item Graph,
Input and Output Connections. You get a somewhat disorganized display
of nodes. Organize the nodes in your window so that they are visually
lined up similar to the order pictured, to make it easier to connect
the appropriate attributes (see Figure 17.56).

Figure 17.56
Preparing the utility nodes for the stretchy arm.
-
Holding down the Shift key and the middle mouse button, drag and
drop the distanceDimensionShape node onto the armScaleRatio multiplyDivide
node. Using the Connection Editor, connect the distance attribute
to the input1X attribute of the multiplyDivide node.
-
Now select the armScaleRatio multiplyDivide node that you just connected
to, and hit Ctrl+a to launch the Attribute Editor. Change the multiplyDivide
node's operation mode from Multiply to Divide. Now copy the number
from the input1X channel and paste it into the input2X channel so
that you are dividing the current distance by the original distance.
The node's output should currently equal 1; as the distance grows,
the output will be a normalized ratio equal to how much the initial
distance has scaled (starting from 1). This output will eventually
be the number that you use to drive the scale of the arm joints, but
you will set up a few extra nodes to add a small amount of logic and
control over the stretchiness.
-
Using the Connection Editor window, connect the following attributes
to create an expression-based node network:
The armWrist_IkControl.autoStretch attribute into the autoStretchMultiplier.input1X
attribute
The armScaleRatio.outputX attribute into the autoStretchMultiplier.input2X
attribute (The output of this autoStretchMultiplier node enables
you to blend the stretchy behavior from on to off, and vice versa.)
The autoStretchMultiplier.outputX attribute into the shortenToleranceCondition.firstTerm
attribute
The autoStretchMultiplier.outputX attribute also into the shortenToleranceCondition.colorIfFalseR
attribute
The armWrist_IkControl.shortenTolerance attribute into the shortenToleranceCondition.secondTerm
attribute
The armWrist_IkControl.shortenTolerance also into the shortenToleranceCondition.colorIfTrueR
attribute (The output of the shortenToleranceCondition node's outColorR
attribute now keeps the arm from shrinking shorter than the shortenTolerance
attribute specifies.)
The shortenToleranceCondition.outColorR attribute into the armScaleMultiplier.input1X
attribute
The armWrist_IkControl.armScale attribute into the armScaleMultiplier.input2X
attribute
-
Next, select the shortenToleranceCondition node and open the Attribute
Editor by hitting Ctrl+a. Change the operation mode of this condition
node to Less Than.
This condition node keeps the arm from scaling any shorter than what
the armWrist_IkControl.shortenTolerance attribute is set to by making
a decision for you. The logic behind how the condition node works
is as follows: If the First Term is Less Than the Second Term, use
Color If True; otherwise, use Color If False. This output, which goes
into the armScaleMultiplier, enables you to manually stretch the arm
longer or shorter by changing this attribute.
All that is left is to connect the output of this scale multiplier
to each of the arm joints (the shoulder and the elbow).
-
Again, using the Connection Editor, connect the armScaleMultiplier.outputX
attribute into both the shoulderJoint.scaleX and elbowJoint.scaleX
attributes. Figure 17.57 shows a Hypershade and Hypergraph Input and
Output Connections view of what your final node network should look
like.

Figure 17.57
A Hypershade and Hypergraph Input and Output Connections view
of what your final node network should look like.
Figure 17.58 shows a Hypergraph Scene Hierarchy view of what your
node's groupings should look like.

Figure 17.58
A Hypergraph Scene Hierarchy view of what your node's groupings
should look like.
Now spend a few minutes testing the controls and attributes that you
just created. Try moving around the freeIkHand locator while the handPlant
attribute on the IK handle is set to 0. Experiment with your controls
to make sure you didn't miss a step and that everything is functioning
properly. If something seems to be working incorrectly, go back and retrace
your steps to troubleshoot what might have gone wrong. This completed
exercise with all the rigging finished is found in the file Jerk_ArmSetup_Finished.mb
in the CD folder for this chapter.
In the next exercise, you will add the hand to the arm setup and, finally,
put in all the control boxes that the character animator will ultimately
use to animate the entire arm and hand.