Thursday 26 November 2009

Stretchy Limbs

Right, I'm back in Maya again, rigging my character from some time ago. I've made a few minor tweaks to the model such as finishing the hair, and scaling up the body so the head is a bit more proportioned... you seem to notice the smallest things after not seeing your own work for a couple of weeks, and the head:body ratio stood out too much for my liking.

But yes, for a special treat, I've been working on my rig for the model. Ideally I want it to be as functional and user friendly as possible, being a stock rig and all. There are a number of things I've learnt from the past 3-and-a-bit years of character building, and one of those is that it's all well and good to automate features such as the clavicle raising once the arm lifts above the t-pose (see this vid for what I mean), but if you have to then fight it during animation... just leave it or give the animator the option to turn it off.

With this in mind, I'm currently making a variety of different features for the limbs which can be toggled on or off. One of these is a stretchy limb option. Pretty much once the IK leg control moves out of range for the typical leg, the joints and mesh stretch a little (or a lot) to meet it. So you have some squash and stretch at hand if you want it in your piece. This is pretty much all done with the expression editor.

First of all, you use the distance tool (under Create>Measure Tools) to look at the distance between the hip and ankle joints, and point constrain the resulting locators to the hip, and the foot Control (the ankle locator has to stay with the contoller at all times for good reasons). You will see a number between these locators. Now, this may be the same as the Distance Attribute or may not (I was lucky as it was), but this number is important to note when you stretch your IK leg to its maximum.



A little expression needs to be written that pretty much says "if the distance between the 2 locators is greater than the full length of the joint chain is, then scale the joints along the appropriate axis until they meet."

To keep that scale even, so the joint stretches at a proportioned rate with the distance, you just have to divide the distance attribute by the original distance. (Bit of example maths distance of 30, original distance is 20:. the scale will be 30/20= ScaleX 1.5) The rest is sorted by a few conditional branches to ensure the scale is at its default of 1 at any other time.


And this is the result when the stretch is switched on! When skinned, the leg will stretch out nicely to meet the foot controller. Note the distance is greater than normal, so the scale is increased to stretch the joint chain.

That's about it. It's eaten up a lot of time as I'm new to expressions. A word of advice... make sure the distance number you jot down is actually right. Mine was a fraction too low to start with. That's 2 hours I shan't see again!

-Stuart

No comments:

Post a Comment