|
Using Expressions in Hash Animation Master - Introduction |
|
Hash Animation Master is a great 3D
modeling/rendering/animation program.
One of many of its powerful features is animation using expressions. In these pages, we'll try to cover the use of expressions in AM, starting
with simple examples and moving gradually to more complex examples. I must make
it clear right from the start, that this is a personal attempt to cover a
somehow complicated feature and I can offer nothing more than the experience
gained while trying to use this feature by trial and error and some support of
other AM users and the people from Hash (Thanks!). If you discover errors (in
these pages), or have other ideas/suggestions about expressions in AM, you are
more than welcome to email me, and I'll do my best to correct/add this info in
these pages. Ok? Also, all these are tested on a Windows XP computer, so all
keyboard shortcuts, mouse right-clicking, etc. must be "translated" into
Mac-speak (Mac people know ...). |
|
Keyframe animation: When we try to animate
something, we select the time, adjust the parameter, and create a keyframe
which holds the parameter value for that time. The computer then
"interpolates" between these keyframes (stored values in specific time
points) in order to create a smooth transition from the previous to the
next parameter value, at the time point(s) we specified. We can even
adjust this transition to be not so smooth, sudden or whatever, depending
on the effect we want. |
![]() |
|
The basic idea of Expressions: If we use an Expression to animate a parameter (the X position of the ball, for example), we do NOT create keyframes manually. Instead, we select the parameter and we create an expression for it, which can be simple or complicated, and this expression creates the "keyframes", or, in other words, defines the value of the parameter (the X position, in our basic example) for every frame of our choreography. (Read this again!) In effect, the computer "plots" the red line, depending on the syntax of the expression, and we have our animation. In a way, the difference between keyframed animation and animation with expressions is similar to the difference between using decals or procedural materials in order to texture a model. If we use a decal, we "paint" the surface parameters (color, bump, etc.) manually, but if we use procedural materials, we use "hidden" mathematical expressions (combiners, turbulence, etc.) to define the same surface parameters. |
|
Creating an expression: Really simple. Just right-click on a parameter and select "Edit Expression" from the local pop-up menu. A small "window" will open, allowing you to type the expression for the selected parameter. You'll recognize it. There will be a blinking cursor just like in a word processor. The difficult part is how to decide what the expression syntax will be. Well, Hash have done quite a good work and gave us the choice to avoid typing and select functions for an expression from a menu. On its top-right corner you'll see a small button marked with a "f" and a right pointing arrow. This is the button that opens the functions menu. Whatever you select in the functions menu, is copied into the text field of the expression, saving typing time and the trouble of remembering each function's syntax. The "math hungry" among you can go directly to this page to see detailed descriptions of all available functions (but please come back again!). |
![]() ![]() |
![]() |
|
Let's start with something simple. Download and open the ball.prj file (11kb), or create a new choreography with a 10 sec duration and any object (model) positioned at center (Position X=Y=Z=0cm). Open the Timeline window (press Alt+2) and in the Project Workspace, go to Choreography/Shortcut to Ball/Transform/Translate and right-click on X. Select "Edit Expression" from the popup menu and type a small number, 5 for example, in the expression window. Press Enter. Not great, right? The model just moves to position X=5cm and stays there, because the expression puts the value "5" to the X Translate parameter for every frame of our choreography. Let's try something more interesting. Click on 5 (the expression we created) and then press the "Functions menu" button and pick "GetTime()". Press Enter. Move the Time slider from 0sec to 10sec and back. The model moves! In every frame, the expression GetTime() takes the current time and "delivers" this value in decimal form to the X Translate parameter, so at 3sec the model is at X=3cm, at 7sec the model is at X=7cm, etc. Now we're getting somewhere! (Frame rate is not taken into account. Just time in decimal form.) |
![]() |
|
If we want to move the model more, we must multiply the expression's result. So, click on the expression, move the cursor to the start of the text and type "5*" (do not type the "", ok?). Press Enter. Now the expression must look like "5*GetTime()". For every frame, the X position is "the current time multiplied by 5". At 2sec the model is translated at X=10cm, at 3sec it is at X=15cm, etc. Now, we'll create the expression "50*Cos(GetTime())" for the model's Z Translate parameter. Right-click on the Translate Z parameter, select "Edit Expression" from the popup menu and type "50*Cos(GetTime())". Do not type the "". You can actually copy this text from this page and paste it in the AM expression window. Another way is to type "50*" and then select the Cos() and GetTime() functions from the functions menu, finishing with Enter. Now look at the graph. |
![]() |
|
Trying to avoid math as much as possible (but ... it's impossible!), let's just say that Cos(a) is a function which results in numbers changing smoothly in the range of -1 up to 1, depending on the value of a. We put GetTime() in the position of a, so "a" keeps increasing steadily throughout our animation, cos(a) produces results that change smoothly between -1 and 1, then this result is multiplied by 50, so we get a "wave" graph between -50 and 50. Now look at our model. It moves in the X and Z direction, according to the values that are produced by the two expressions at every frame. |
|
That was a simple example, just to get started. Of course it was not spectacular animation, it just showed how we can create expressions and the basic logic behind them. In the following examples we will try to use expressions in "useful" animations, discover a few tricks, and ... feel good about our high-school years, when we were listening carefully to our math teacher! Expressions have lots of uses and it is really one of those features where "your only limit is your imagination". Or your math knowledge. Or something like that ... |
|
Functions Example1 Example2 Example3 More examples in construction ... |
|
Comments,
questions, suggestions: sogou@hol.gr |
|
|