Using Expressions in Hash Animation Master - Example 1

Automatic squash and stretch

  Let's start with the same example we can find at the Hash website, but we'll make it simpler. Squash and stretch is a powerful effect used in many styles of character animation. If we have an elastic ball on the floor and we push down on it, we try to decrease its Y scale value. We see that the ball tries to "expand horizontally" increasing its X and Z scale. It tries to "maintain volume". So, we need to create expressions which will increase the X and Z scale parameters of a model when Y scale decreases and decrease X and Z scale when Y scale increases. In other words, X and Z scale must be "inversely proportional" to Y scale. X=1/Y and Z=1/Y will do the trick. Download the ball.prj file (11kb), or create a choreography with one model on a floor. In the Project Workspace click on Choreography/Shortcut to Ball/Transform/Scale to see the X, Y and Z parameters. Right-click on X scale, select Edit Expression from the popup menu and type "1/" in the expression text field (do not type the "", do not press Enter). Then, while the text cursor is blinking inside the expression text field, move the mouse pointer and click on the Y scale parameter. This will create the text we need to refer to the Y scale parameter inside the expression. Now press Enter. Do exactly the same for the Z scale parameter. Now that the expressions are complete, click on the Y scale parameter, keep the left mouse button pressed and drag the mouse to change the Y scale parameter ("virtual slider"). We see that the ball "squashes" and "stretches" automatically. All we have to do is animate the Y scale (create keyframes) and let the expressions take care of the X and Z scale parameters. If, for whatever reason, you could not create the expressions, just download the autosquash.prj file (12kb) and have a look.

  We must note, however, that if we want precise, "physically correct" squash and stretch we must use the square root of Y scale as a guide. The "correct" expressions would be "1/Sqrt(..|Y)" for both the X and Z scale parameters. Without getting deep into the math/physics required, let's just say that calculating volume is simple if the model is a cube, but difficult if it is a ... rabbit. And do great character animators care if their characters squash in a physically correct way? No. They "exaggerate" motion (most times).

Comments, questions, suggestions: sogou@hol.gr
Back