Showing posts with label Stretchy. Show all posts
Showing posts with label Stretchy. Show all posts

Friday, November 28, 2014

Stretchy Arm using node editor with global scale, no scripting required!

Few days back I got an email from a friend asking me for a method to stretch the arm with global scaling without using any scripting.
Here is a quick way to do it:

1/ I created a basic IK arm rig, nothing fancy.


2/ I used the Distance tool(Create-Measure Tools-Distance Tool) to measure the distance between shoulder and wrist. Snap the start and end locator to shoulder joint and wrist joint respectively. Point constraint the l_armDistStart_loc to the l_shoulder_bn and l_armDistEnd_loc to the l_arm_ctrl.


A distance node is created and you can find the distance value in the shape node of the distance node.

3/Open the node editor, and add the Global_ctrl to it; create a multiply divide node and rename it to GlobalArmScaleMult_nd.  Connect the Global_ctrl.scaleY to GlobalArmScaleMult_nd.input1X and the operation is meant to be Multiply. 
As my arm is slightly bend in the default pose, I need to straighten it before it starts stretching, that is the total distance I need to note before I apply stretching. Copy the distance value and paste it in GlobalArmScaleMult_nd.input2X. 



4/Add distance shape node to the node editor and create another multiply divide node; rename this node to l_armStretchDiv_nd. Here we will divide the distance value with outputX value of the GlobalArmScaleMult_nd.

5/As this is an arm, we aren't going to squash it. We need to keep the scale value 1 if the distance between Shoulder and wrist gets less. To do this, we will add a condition node. Create a condition node and link the outputX value of the l_armStretchDiv_nd to the first term; check if it is greater than or equal to one which means the distance has increased(the control has been stretched). If true, hook the value of  l_armStretchDiv_nd .outputX else leave the value to 1.

6/We are almost there, all you need to do it connect the outputX value of the condition node to the l_shoulder_bn.scaleX and l_elbow_bn.scaleX.

Tadaaa!! All done :D