![]() |
the animation language
|
||||
|
intro al reference scheme animation tools plugins tutorials tutorial #1 tutorial #2 references download index |
Tutorial #2: Animation
This tutorial introduces the AL programming constructs and functions used for track-based animation. It does not discuss procedural animation techniques (like particle systems) and it does not discuss animation principles (like "squash and stretch"). This tutorial assumes that you are already familiar with the material in Tutorial #1. There are a variety of ways to animate shapes in AL. All that you have to do is change the parameters to gops and/or gprims based on the value of time.
(The time global variable
and animation using time is illustrated in
Tutorial #1.) For that matter, you
don't even have to use time -- you could define
your own variables or functions which are incremented or evaluated
differently for each frame.
If however, you want to animate parameters by specifying a sequence of key frames (ie. track-based animation), you should use avars. Conceptually, avars ("articulated variables") are time-dependent variables that are defined by a sequence of key frames. (Avars are often called "tracks" or "channels" in other animation systems.) Each key frame denotes a specific value at a specific time (frame) in an avar. The value of an avar at times between key frames is computed using linear interpolation or splines based on the neighboring key frames.
In the figure above, time is shown along the horizontal axis. The value of the avar is shown along the vertical axis. The key frames are denoted by black dots. The 3 key frames are:
The values of the avar between key frames are smoothly interpolated using Bezier splines. The white circles and dashed lines are used to control the slope (ease-in/ease-out) of the avar at the keys. Looking at the graph, we can see that the value of the avar when time equals 5 is roughly 1.3. Also note that before the first key frame, the value of the avar is equal to the first key frame; and at any time after the last key frame, the value of the avar is equal to the last key frame. Avars which have no key frames have a value of 0 (zero) by default.
Avars are declared in AL programs using the model is also a important programming construct in AL.
(
Like the
Below is trivial example which defines a model called "ball" with 3 avars: xpos, ypos, and zpos. Those avars are the used to translate the ball into position.
(world
(model "ball" (xpos ypos zpos)
(translate (xpos) (ypos) (zpos))
(sphere)
)
)
There are two main things to note at this point:
An exposure sheet (or "x-sheet") defines the values (key frames) of all the avars corresponding to a particular world model. In other words, an exposure sheet "binds" the avars declared in your AL program to specific values. The working exposure-sheet refers to the current exposure sheet stored in memory. When the world model is evaluated, the values of the avars used in the world model are determined using the working x-sheet. If an avar in the world model doesn't already exist in the working x-xsheet, the avar is inserted into the working x-sheet. (Newly inserted avars will have no key frames and have a default value of zero.)
There are 2 ways to modify the working x-sheet:
In this section, we'll go through a trivial example to illustrate the roles of the individual tools.
Step 1Start Ogre and Ox. Load ball.al into ox. In ogre, you should see a sphere centered at the origin.
ox --> (load "ball.al") ![]()
Step 2Start Chant. By default, the root of the model hierarchy (the "world" model) and the models it immediately contains (in this case, the "ball" model) will be shown in the hierarchy browser on the left side of the chant window.
![]() To view the avars defined in the ball model, click on the arrow to the left of the ball label. Arrow buttons allow arbitrary parts of the world model hierarchy to be expanded or collapsed. Avars are show with a square toggle button to the left of each avar name.
![]()
Step 3In the Chant hierarchy browser, select the "xpos" avar by clicking on the square button to the left of it. This will load "xpos" causing it to be displayed and readied for editing. In Chant, avars are drawn with time along the horizontal axis and value along the vertical axis. Note that the "xpos" avar is drawn as a horizontal line at value = 0.0. That's because the avar doesn't have any keys and by default, avars with no keys have a value of zero (at all times).
![]()
Step 4Create a few key frames in Chant. You can do this by moving the cursor inside the region where the avar is drawn and clicking the mouse button to create a "Bezier" key. As you drag key frames in the window, the display in ogre should update (the sphere should move slightly).
![]()
In the figure above, note the pink vertical bar. This bar
represents the current value of global
Step 5The animation specified by the avar shown above is very simple (we didn't even modify the other 2 avars), but let's pretend that we like it. If you want to save your key frames, usesave-xsheet
to store the working exposure sheet (ball.xs).
ox --> (save-xsheet "ball.xs") You might also want to render theses frame with something like: ox --> (render 'frame '(1 20) 'style "vector" 'format '(160 120) 'display-type "file") Here is the resulting animation.
To try it out, save the model bouncingball.al and the exposure sheet bouncingball.xs in your own directory. Start ox and execute the following to render frame #1: ox --> (load "bouncingball.al") ox --> (load-xsheet "bouncingball.xs") ox --> (render-it 1)
To render the animation (frames 1-90): ox --> (render-it '(1 90)) To see how to use motion blur, look at blurredball.al. Note that the only real change is to add the 'motion-blur parameter to the "render" command. The value of the parameter specifies the duration that the virtual camera shutter is open. Also note that the pixel-samples is increased (and may need to be further increased) to improve the quality of the motion blurred image. AL: The Animation Language is Copyright © 1992-2000, Stephen F. May |