Building a Stretchy IK Chain in Maya

priimuse's picture

Hello persons! I'm Wesley Wilson, 3D artist with Tiny Phoenix and I'm here to tell you all about building a stretchy Ik chain in Maya. Let's dive in and get started building the arm rig!

Start by making a 3 chain joint chain and naming the chain as shoulder_jnt, elbow_jnt, and wrist_jnt. It is important that you introduce a bit of a bend in the elbow in order for predictable IK behavior.

It is also crucially important to orient your joints so that the shoulder joint's X axis points towards the elbow joint, and the elbow joint's X axis points towards the wrist joint. This detail is critical when it comes to building our stretching functionality later. Orienting joints is also something anyone interested in rigging should become very familiar with. It is impossible to overstate the importance of joint orientations to any rig building involving joints.     

We then will want to create an IK solver running from the shoulder to the wrist. Choose Skeleton, then click on the option box beside Create IK handle. We will be using a Rotate Plane Ik solver, as opposed to the other selection, a single chain solver. All the rest of the tools settings should be at the default position.  If they are not, please click on Reset Tool, then change the solver type to rotate plane. Maya's Rotate Plane solver calculates the polevector of the IK chain in a predictable and stable fashion, making it ideal for it's use in building arm or leg rigs. Select the newly made IKhandle in maya's outliner and rename it "test_ikh". 

Next we will make a control object to manipulate our IKchain. Creating control objects and understanding their transforms is critical in making a clean and stable rig.  Choose create>nurbs primitives> nurbs circle. Rename this new control as "wrist_ctrl", then group this object while it is at the center of the world, with 0's in the translates and rotates. Rename this new group as "wrist_ctrl_grp". Now we need to position this new control where it will do the most good - the wrist joint. A quick trick for doing this is with parent constraints. Simply select the wrist joint, add the wrist control group to your selection, then navigate to constrain>parent option box. Modify the default settings by turning OFF maintain offset. When you apply the constraint you will see the control's group, and thus the control, have snapped to the wrist joint, perfectly matching the joints position and orientation. We need to delete this constraint by going to the outliner and selecting the constraint underneath the wrist control group.

After the control is in position, we are ready to attach it to our IK solver. The wrist control will control the IK chain via a parent constraint. select the control, then the IK handle, then click on parent constraint.

The wrist control cleanly controls the ik handle!  Because we used groups for our control object, we can return it back to its starting position at anytime by simply entering 0's for the values in the channel box! But, we still have no control over the scaling of the joints.

Now, we need to control the scaling of the joint chain. This will require a SLIGHT amount of math and some use of maya utility nodes. We need to measure the length of our chain to determine the maximum length we can go before starting to stretch the joints. We also need a way to track the current chain length, so we know when to apply the stretching. This is what the distance measure node will do for us. To make a distance measure node, choose create>measure tool > distance tool. Click on the shoudler joint and the wrist joint and notice how the node gets created in the outliner with two new locators. Parent one of the new locators underneath the wrist ctrl and move it to the wrist ctrl. Move the other one to the shoulder joint. This next part involves the node editor and some simple math.

Open up the node editor and select the distance node in the outliner. Graph the connections in the node editor and find the shape node for the distance node.  The attribute we are concerned about is the distance attribute in this node and we will use it in a formula to drive the scale of our joints intelligently. We will also need to create a multiplyDivide. Once created, map the distance into the input1X slot.

Change the operation of the multDiv node to be division and set the input2x value to the combined total of our elbow joint's and our wrist joint's translateX values.  In my case, that number is 3 + 2.987. The reason we use the translate X of the elbow joint is because of the way we built our joints in teh very beginning of this. The  X-axis points down the elbow joint towards the wrist joint and provides us with a distance between the two.  In my case,  the wrist joint is 3 units away from the elbow joint. These translate X values are also the maximum length of our joint chain.  we want to divide the current distance (input1x) by the maximum length of our joint chain (input2x) inside our multiply divide node.  we next need some way to use the resulting number to drive the stretching of our joints. This will be done conditionally, with there being conditions when we want the joints scaled and conditions when we would rather the joints not be scaled.  So what better node to use than a condition node?!

In the node editor, create a condition node. The condition node works by comparing the first and second terms, using the operation you select. If the result is true, then the color if true is the result of the node, and if the result is false the color if false is the result. We want to compare actual chain's length to the maximum length. When the first term (the actual length) is greater than the second term (the maximum length), then our condition is true and we use the color if true result. Conversly, when the actual length is less than the maximum length, we should get the color if false as the result.  

Let's plug the actual length of the chain (the distance attribute we also have plugged into our multiply divide node) into the first term slot of the condition node.  the second term in the condition node should be the total maximum length of our chain, which is the input 2x value in our multiply divide node.  Set the operation to greater than on the condition node, and we will need the result of the multiply divide node (it'll be called output X) plugged into the color if true R of our condition node.  We are almost done.

The last thing we need to do is to channel the outcolor R number from the condition node into the shoulder and elbow joint's scale X attributes. Now take this knew found knowledge out for a spin and impress all your friends at parties!

Add new comment

Basic Editor

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain Text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.