View Full Version : XP lab 01 - Stretch and Squash

02 February 2006, 11:34 PM
I thought I'd share some of my experiences in dealing with character animation in EIAS. More specifically, using XPressionist in rigs. To be honest, these are just my own solutions that I came up with and for all I know, there are much better ways of doing these things. Any feedback is therefore welcome.
This is certainly not a step-by-step guide, I'm only explaining the principle here. You will still have to adapt and interpret.

02 February 2006, 11:34 PM
Stretch and Squash with bones

Stretch and squash is like the pepper and salt of cartoon animation. Without it, things become dead and lifeless. But too much is overpowering. We'll have a look at a way of adding stretch and squash capabilities to a rigged element in Animator. It will only really work if you have the Encage plug-in from Konkeptoine, Xpressionist and a bit of patience.

From a mechanical point of view, stretch and squash of a body-part means two things:
1. The body part grows longer or shorter.
2. It bulges in and outward to retain volume.

02 February 2006, 11:36 PM
1.A. Growing

Let's start with the growing longer and shorter bit. For this we'll use a relatively unknown feature of Animator: the fact that bone-lengths can be animated. Well, almost. You can't do it directly. You'll need XPressionist to make it happen. The trick is to animate one property of an object, say the position of a cube, and link that to the length of one or more bones.

- Import your element as a low-res cage, subdivision level 0. In my case, I used Silo for modelling.
- Rig it in Animator as you would normally and then attach the low-res model to Encage. The simple shape I used could be the basis for an arm, leg or any other body part.
- It is important that you rig the element itself, NOT the Encage plug-in. The reason that it will only work with Encage is that you'll never get a smooth result without it. The skin will start to tear pretty much instantaneously if you rig a high-res model.
- Note the little bone at the end of the bone-chain. It's there for a reason. It shouldn't be animated and it's best to simply lock it (Link Editor > Link Type > Lock)
(FIG 1)

A bit more explanation. The two long bones are the ones that will be scaled. The little bone at the end will not be scaled, it is there to grab hold of the lowest vertices of the model and drag them along. For this purpose, you have to make sure, by using strength-maps, that the last vertices are ONLY influenced by that last little bone. If you don't do this, the low-res model will start to slide as the bones scale. The little end bone sort of "pins" the skin down.

- Make a strength map that ensures the lowest vertices are 100% attached to the little bone.
- Make a strength map that ensures the lowest vertices are completely free from any influence from any other bones. This will probably be the inverted version of the first strength map.
(FIG 2)

02 February 2006, 11:36 PM
1.B. Xpressionist

Next you need something to control the bone-scaling. I prefer to use an object in the scene, but you can use a slider in the morph-window. In this case, I just took an UberShape cube and made the Y-position control the bone-scaling.

All you now have to do is write a little XP script to link the controller to the bone-scaling.
(FIG 3)
- Write down the length of every bone you want to scale. You'll find the bone length under: Bone info> Special>Bone Length. This will give you an initial value to start from in the XP script (There is probably a more elegant way of doing this).
- Make sure that all the bones that you want to scale have animation enabled (green arrow on)

The script works as follows:

stretch_amount = (whatever you use to control the stretch)

Bone1 length = initial bone1 length + stretch_amount
Bone2 length = initial bone2 length + stretch_amount

And here is a practical example:

double stretch_amount = - (Cube.Position.Y);

Bone_1.Length = 48.7026 + stretch_amount;
Bone_2.Length = 43.9005 + stretch_amount;

resist the temptation to simply write:

Bone_1.Length = 48.7026 - (Cube.Position.Y);
Bone_2.Length = 43.9005 - (Cube.Position.Y);

Later on, we may want to replace or refine the stretch control mechanism, change its responsiveness... Defining a variable stretch_amount will allow us to do that far more efficiently.
Also note that I had to negate the cube position. If I didn't do that, the cube would have moved in the opposite direction of the stretch. This keeps it more intuitive.

One more thing, you will only get realtime feedback when Encage Editing subdivision is set to 0 (Encage window > subdivision steps > Animator = 0). This is a limitation of Animators API. It will subdivide fine when rendered, but when animating, you'll be staring at a crude low-res model.
(FIG 4) Stretching! Yippeee

02 February 2006, 11:38 PM
2.A. Bulging

For the stretch and squash to look credible, the model has to bulge in-and-out as the stretch happens. There is two ways to create a bulge:
- Use Animators deformation tool to create the bulging. This works well enough for simple, stylised models that are segmented, that is to say, have the head, body and limbs as separate groups. For instance, if the arms are part of the same group as the body, the bulge deformations that you apply to the body will make the arms grow like crazy. In that case, use...
- Morph-targets, much more precise, but also much more work. Remember to only model the bulging in-and-out, not the growing, that's the task of the bones.

To be perfectly honest, I've never tried it with morph-targets. I'm quite happy to design characters so that they work with the simple bulge-deformation in Animator.

- Create the bulge deformation.
(FIG 4b)

02 February 2006, 11:39 PM
2.B. Xpressionist again

All we now have to do is to allow the script to control the bulging.

- Make sure the model has animation enabled

The script works as follows:

stretch_amount = (whatever you use to control the stretch)

Bone1 length = initial bone1 length + stretch_amount
Shape bulge or morph target = stretch_amount * factor

You may need to multiply or divide the stretch_amount to visually create the right amount of bulging for the stretch.
Here is the same script with added bulging:

double stretch_amount = - (Cube.Position.Y);

Bone_1.Length = 48.7026 + stretch_amount;
Bone_2.Length = 43.9005 + stretch_amount;

Shape.Region1.Bulge = - (stretch_amount * 2);

Note that I had to negate the bulge amount. Otherwise the shape would have bulged out when being stretched and vice versa.

Often, the amount of bulging may look good for the stretch but not the squash or vice versa. In that case, simply adapt the script:

double stretch_amount = - (Cube.Position.Y);

Bone_1.Length = 48.7026 + stretch_amount;
Bone_2.Length = 43.9005 + stretch_amount;

if (stretch_amount < 0)
Shape.Region1.Bulge = - (stretch_amount * 3); // when squashing
Shape.Region1.Bulge = - (stretch_amount * 2); // when stretching

Factor 3 for squashing and factor 2 for stretching are often the values I end up with.
(FIG 5) Result !!!

02 February 2006, 11:39 PM
3. Deformation engines order

There are three ways in which Animator can distort a mesh:
1. Morph-targets
2. Deformations
3. Bones

The thing to remember here is that Animator will apply these distortions ALWAYS in that order. The whole technique I explained here relies on combining two or sometimes three distortions applied to one mesh. If you suddenly find that your model shoots of into infinity, breaks up... don't panic. Simply think it through like so:

1. I have a mesh "A", to which I apply a morph-target. This gives me mesh "B"
2. I now have mesh "B", to which I apply deformations. This gives me mesh "C"
3. I now have mesh "C", to which I apply bone deformations. This gives me the final result.

Try to visualise your mesh being distorted by one engine at a time. It's quite common for something to go wrong in step 3. Less common in step 2. Here is a typical scenario:

problem: In step 2, with the deformation engine, you applied a bulge deformation to mesh "B", resulting in mesh "C", which is thicker in the middle than "B". When you try to deform mesh "C" with the bones, parts of the mesh are now outside the bones range and will suddenly not follow the bones anymore.
solution: Make sure the ranges of your bones are big enough to allow for bulging. This may sound obvious, but when you've spend many hours on a rig, it's easy to feel your brain collapse when a problem like this arises.
(FIG 6)

02 February 2006, 11:42 PM
Phew, I hope all this information may be useful to some of you. :)

So far, we've only looked at squashing and stretching a single element. In the next instalment, we'll look at some of the problems that arise when dealing with an actual character.

02 February 2006, 12:04 AM
Thank you so much.. this is excellent material. I appreciate your contribution.

02 February 2006, 08:38 AM
Excellent! I didn't know you could lengthen bones!

One by one lets get everyone into XP!

Very nice Manuel

CGTalk Moderation
02 February 2006, 08:38 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.