the animation language
intro
al reference
scheme
animation tools
plugins
tutorials
     tutorial #1
     tutorial #2
references
download
index

Tutorial #2: Animation

Overview
Basic Concepts
Avars
The Model Construct
Exposure Sheets
Interactive Editing of Avars
A More Complete Example




Overview

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.




Basic Concepts

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.




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.

An avar (black curve) with 3 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:

  • at time 2, value = 1.9
  • at time 10, value = 0.2
  • at time 20, value = 1.4

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 programming construct.


The Model Construct

The term "model" is overused in the AL documentation. "Model" is often used to refer to any program that creates shapes. But model is also a important programming construct in AL.

(model name   (avar0 ...) <body>)

Like the separator, model can be used to construct hierarchies because it saves and restores transformations and rendering attributes affected by the <body>. However, the model construct also:

  • identifies subhierarchies using a string name; and
  • allows new avars to be declared locally to that subhierarchy.

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:

  1. In AL, avars are represented as functions with no required arguments. That's why they are enclosed in parentheses. When the avar function is evaluated, the value of the avar at the current value of global time is returned.
  2. There are no key frames specified. We say that the avars are "unbound." The avars are generally bound externally in the exposure sheet which is usually stored in a text file. Unbound avars return a value of 0 (zero) so the ball, in the example above, will be positioned at the origin initially.

The world construct is also a model with a fixed name ("world") and no avars.



Exposure Sheets

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.)

The working x-sheet always matches the current world model. When you load an exposure sheet file, avars in the file that don't exist in the world model will be ignored. Therefore, you cannot load the exposure sheet file before you have defined the world model.

There are 2 ways to modify the working x-sheet:

  1. you can modify the working x-sheet directly using interactive tools (See below.); or
  2. you can modify an exposure sheet file and then load it into the working x-sheet using load-xsheet.




Interactive Editing of Avars

The easiest way to work with avars is to use the interactive tools that are a part of the AL software environment. This section introduces two new tools:
  • hview -- a simple "hierarchy browser" used to select avars for editing; and
  • aardvark -- a graphical tool for editing avar keys.
In addition, you'll probably use ogre to view what's going on. Please consult the documentation on those tools for details about their use.

In this section, we'll go through a trivial example to illustrate the roles of the individual tools.


Step 1

Start Ogre and Ox. Load ball.al into ox. In ogre, you should see a sphere centered at the origin.

ox --> (load "ball.al")


Step 2

Start 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 3

In 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 4

Create 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 time. You can drag this bar left and right to change the current value of time. When you release the mouse button, the model will be updated in ogre.


Step 5

The 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, use save-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.

Quicktime (82K)




A More Complete Example

This section illustrates some of the concepts above with a simple, but more complete example. The animation is of a yellow ball bouncing along a floor. (The parquet floor shader "LGParquetPlank" is by Larry Gritz and is available from the RenderMan Repository.)

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