Many character rigs require both stretchy limbs and twist bones in the same appendage. It can be tricky to get these two things working in unicen, and there are many different methods. I am going to show you the technique I have been using as of late. I prefer this method because it is very straight forward, easy to set up and easy to maintain.
This tutorial is being done in 3ds Max 2008 and uses some beginner level MAXScript. Click here to download the starting max file.
I suggest first watching Paul Neale’s IK/FK Arm video tutorial and Twist Bones video tutorial before going any further. I will be refering to many things he covers in these videos, I will be starting this tutorial where Paul leaves off at the end of his IK/FK Arm tutorial, and will be using the same technique for twist bones that Paul explains in his Twist Bones tutorial just implementing it in a different way.
The entire idea behind this method is that the twist bones are just going along for the ride with the blend bones, so we can set up our IK/FK blend system and stretch system fully and then just add the twist bones in after. Again, the twist bones are just going along for the ride, we are essentially keeping them completely separated from the actual rig.
Here is how your viewport should look when you open the starting file:
We will begin by putting our stretchy limb system in place. The way I like to do this is through the position list that should already exist on your blend bones, if you remembered to freeze their transform. I have a few reasons for doing it this way. The main reason is that if you put the stretchy limb system on the IK bones you need to set up position constraints on the blend system for it to blend to the stretched out position. Having position constraints on the blend system can create issues with the bones separating, the same reason you have to use look-at constraints and point helpers when creating a stretchy bone.
So, go to the nub bone of the blend bones chain, go into your curve editor and add a Position XYZ controller to the available slot and then in the Motion Panel rename it to “IK Stretch”. Then go back into the curve editor and add a float script controller to the X Position of IK Stretch. Create three new variables in the script controller, “sh”, “wr”, and “dis”, and then enter the expression “if ((distance sh wr) – dis) > 0 then ((distance sh wr) – dis) / 2 else 0″. If you would like to understand what is actually happening with this expression and have a more in depth look at stretchy limb systems, you can pick up (I swear hes not paying me for the plugs) Paul Neale’s Rigging DVDs from CG Academy.
Next we will have to assign values to each of the variables we created here.
Select the first bone in the IK bone system, then select “sh” in the variables list in our script controller and click “Assign Node”. A window should appear. Put your mouse over “Objects”, which should be at the bottom of the list, right click and choose “Expand Objects”. Find the object highlighted yellow, which in this case should be ikBone01, select it and press OK.
Select the ikWrist control object, then select “wr” in the variables list and follow the same process as explained above.
Lastly we need to figure out what value to assign to our “dis” variable. Make sure you are at frame 0 so that the arm is fully extended. Select both the first bone in the IK bone system and the ikWrist control object, open your MAXScript Listener and evaluate the following line of code “distance $ $“. Copy the returned value, go back into our script controller, select “dis” from the variables list and click “Assign Constant”. Paste the value we got from the Listener, click Evaluate and then OK.
Back in the script controller’s main window, click Evaluate and then Close.
You should not get any errors if you followed these steps correctly and find that now if you pull the ikWrist control further than the arm’s full extension, the blend system will go half the distance.
To get it to go the full distance, select the nub bone of the blend bones chain, the one we added the script controller to, and in the curve editor right click the IK Stretch controller and click copy. Select the forearm blend bone, named blend02, and in the curve editor go to the available slot in the position list, right click and select paste. When prompted as to whether you want this to be a copy or instance, choose instance. You will have to go back to the Motion panel and rename this one to IK Stretch as well. The blend bone system should now go the entire distance when you pull the ikWrist control further than its full extension.
We do have a slight problem here, but one that is easily fixed. Scrub the timeline through the entire animation I have set up on the rig. You’ll notice that by the end the ikWrist control has been stretched out and our stretchy limb system is working. If you select the ikWrist control and ramp up our IK/FK blend so we go over to FK you’ll notice that our stretch doesn’t go away.
To fix this we just need to wire the weights of our stretch system back into the IK/FK value that is on our control objects. You will have to do the following steps for each of the blend bones we added the script controllers to.
Select the bone, right click and select wire parameters. Go to Transform/Positions/Weights and click IK Stretch. Click any control object for the arm, IK or FK, and go to Modified Object/Attribute Holder/Custom_Attributes and click IK/FK. You want to create the wire going right to left with the expression “(100 – IK_FK) / 100″. Click connect and do the same for the next bone. The blend bones should now have the stretch system blend on and off when switching between IK and FK.
Now we can start creating our twist bones. Go to your top view and create two bone chains, each consisting of two bones and a nub.
We are now going to create stretchy bones from these bone chains. This is not the same as what we did above, which was a stretchy limb system. We can easily do this step by using Jason Labbe’s Stretchy Bones Tool. Drag the script into Max’s viewport then double click the bone at the root of a bone chain to select the entire chain in it’s hierarchial order. Change the size from 25.0 to 3.0, turn off Box and turn on Cross, then click “Create Stretchy Bones”. Do this for both bone chains. Your scene should now look like this:
If you select and move one of the resulting red point helpers that were created you will see that our bones are now constrained to the point helpers and will stretch accordingly. This is great, but not exactly what we are looking for yet. If you watched Paul’s Twist Bones tutorial you’ll have noticed that the calculations being done in the parameter wiring rely on the bone hierarchy and rotation being inherited; we no longer have a hierarchy in place with the current stretch bones setup. What we want to do is re-create the hierarchy, but through the point helpers instead of the bones.
Select and link the point helper that controls the nub bone to the point helper that controls the middle bone, and then that point helper to the one that controls the root bone. Do this on both bone chains.
Now we want to get our twist bones to follow along with our blend bones. Hide the ik and fk layers so we only see the blend bones and our twist bones. In Bone Tools, under the Animation menu, we want to turn on the front fin for all of these bones and set the size to 1.0.
Select the point helper that controls the root bone for either of the twist bone hierarchies and align it positionally and orientationally to the pivot of the forearm blend bone. With the point helper still selected, position constrain it to the forearm blend bone and then position constrain it to the nub blend bone. It should now be sitting half way on our forearm blend bone. We want this to be sitting two thirds of the way towards the elbow joint, so in the motion panel select our position constraint and set the weights to 65.5 for blend02 (forearm bone) and 33.5 for blend03 (nub bone). Now do the same thing for the next two point helpers but have the middle point helper constrained two thirds towards blend03 and the the nub point helper constrained 100% to blend03.
Follow the same technique for the other twist bones on the bicep. You’ll probably notice that it doesn’t appear as though your bones are lined up properly. Select all of the twist bones and in Bone Tools click “Reset Stretch”, it can be found near the bottom of the rollout. After you’re done it should look like this.
Now if you unhide the ik and fk layers and play through the animation you will see that the twist bones follow along perfectly with our blend bones. All there is left to do is set up the twisting. I am not going to go through how to set up the twist system, since it is the same as what Paul outlines in his tutorial. All you have to remember is that we re-created our bone hierarchy through the point helpers we used to create our stretchy bones, so anything Paul does to the twist bones you just need to do with the point helpers instead.
Hope you learned something from reading this tutorial. Here is the finished Max file incase you ran into some problems along the way and want to see how the final thing looks, and here is the final with all the twists set up.
Now, with no further adieu, Paul’s Twist Bones video tutorial.