Page 1 of 1

Simple Stretchy Leg

PostPosted: Tue Feb 28, 2012 6:06 am
by BenChang
stretch2.jpeg (16.71 KiB) Viewed 2435 times

keepontruckin.jpg (31.85 KiB) Viewed 2435 times

Basic squash and stretch added to an IK Leg

This technique adds a simple squash and stretch control to an IK leg. By scaling joints (here, on the X axis), we can stretch the joint chain. Scaling the hip and knee both proportionately gives a nice stretching effect over the whole leg, which we can control with one attribute via an expression.

stretch3.jpeg (10.87 KiB) Viewed 2435 times

1. select LFootControl and add a float attribute, [i]legStretch[i], with a min of -10 and max of 10.

2. Open the Expression Editor (Window->Animation Editors->Expression Editor)
3. Enter this expression:
Code: Select all
LHip.scaleX = pow(2, LFootControl.legStretch/10.0)

4. Click "Create"

pow is the exponent function. When legStretch = -10, this returns 2^(-1), or 1/2. When legStretch = 10, scaleX = 2. When legStretch=0, 2^0=1 so scaleX = 1.

stretch4.jpeg (32.43 KiB) Viewed 2435 times

IK handle pulled beyond leg length
stretch5.jpeg (7.55 KiB) Viewed 2435 times

Stretch applied to the hip joint
stretch6.jpeg (8.04 KiB) Viewed 2435 times

5. This only scales the hip joint, though. To make it a little nicer, we can divide the effect between the hip and the knee. Open the expression editor and edit the expression:

Code: Select all
LHip.scaleX = pow(2, LFootControl.legStretch/20.0);
LKnee.scaleX = pow(2, LFootControl.legStretch/20.0);

Stretch only applied to hip joint
stretch7.jpeg (8.59 KiB) Viewed 2435 times

stretch applied to both hip and knee
stretch8.jpeg (8.01 KiB) Viewed 2435 times