AL Animation Basics


Time

Animation requires a representation of time. AL provides a global variable, "time" which can be used to keep track of frame information.

It just so happens that "time" is a special variable, because it is shared by multiple programs you'll be using. They all know what "time" it is. As such, "time" has its own function for setting it called "set-time!".

This should be used for setting the value of time, instead of "set!" so that other programs get informed of the update to "time". If you are only running ox and icam, using "set!" is fine, but when the program "aardvark" is added to the mix...

For example, to set the current time to frame five, one would type:

  ox --> (set-time! 5)
Time is like "render" in that, when it is set, the world is reevaluated. Ergo, never, ever set time within the world construct. The result is an infinite loop.


Avars

Avars are time dependent, "articulated", variables. They not only allow you to specify the value of a given variable at a certain time, they also automatically interpolate between the key values you provide (linearly, or along bezier curves).

Using Avars

Avars are used just like functions. The value the avar returns is simply dependent on the current value of "time".

As an example, you might have an avar called, "squash" which controls the flattening of a ball. To find the amount of "squash" at the current time you just need to call "squash" like a function:

  ox --> (squash)
  0.5
To find out the value of "squash" at some arbitrary time, you just give squash the desired time as an argument:
  ox --> (squash 30)
  1.5

Setting Avar Values

Avars get their values from their set of "keys". These keys are, in general, set using either the interactive programs, "aardvark" and "cuesheet". Both are still under development, but their workings (this week) will be discussed below.


Models

"Model" is a construct that lets you create avars hierarchically. "Model" accepts a name, a list of avars, and an expression body. The avars can then be used anywhere inside the body. The name can be any string. Model functions like a separator in that the effects of gops inside the model body will not escape the model.

Below, the robot arm example from the hierarchy section is used in a model, to make use of avars:

(load "robot-arm.al")
(world
 (model "arm" (elbow-bend wrist-bend)
   (robot-arm (* 90 (elbow-bend)) (* 90 (wrist-bend)))
  )
 )
This will create a model called "arm" with two avars, elbow-bend and wrist-bend. I have multiplied both by ninety so that the avar values can be normalized to a range of zero and one, which is easier to work with, and change later.

The values of elbow-bend and wrist-bend are passed to the function robot arm which creates an arm with the wrist and elbow bend accordingly.

Once this model has been created in ox, two other programs can be started, "hview", and "aardvark". The first, "hview", allows the user to examine the hierarchy of models and avars that have been created in ox, and to select them for editing. The editing is done in "aardvark".


If we load the above model into ox, and start hview, in the hview window we should see:


If we press the blue arrow next to "world" we are shown all of the models currently existing in the world:


Currently, there is just the arm. Note that "arm" is the name we gave when we defined the model. If we press on the blue arrow next to "arm", we are now shown all of arm's avars:


We can press the red arrows to "select" one or more of the avars.

Here elbow-bend has been selected. Usually an avar is selected when you wish to edit it. This editing takes place in the program "aardvark" which looks like this:

Aardvark was finished yesterday. Documentation will be arriving soon. For now, the accadman manual for xavar, a previous incarnation of aardvark should suffice, for the most part.


We have currently selected "elbow-bend" to be our current avar, in hview. We can fill in some key values for "elbow-bend" in aardvark by clicking with the left mouse button:


We can then select the other avar "wrist-bend" and enter different points for it. Note, elbow bend will still be faintly visible:


By sliding the red time bar, simple animations can be previewed in icam. The model can be called from inside and animation loop which updates time, and the animation can be rendered:
  (load "robot-arm.al")

  (define (make-arm-model)
    (model "arm" (elbow-bend wrist-bend)
	   (color '(1 0 0))
	   (surface "matte")
	   (robot-arm (* 90 (elbow-bend)) (* 90 (wrist-bend)))
	   ))

  (define (ground)
    (separator
      (color '(.1 .3 .2))
      (rotate 90 x-axis)
      (surface "matte")
      (disk 'radius 100)))

  (load-avars "double-sneeze.adb")
  (set-time! 0)
  (while (< time 90)
    (begin
      (world
       (light "spotlight" 'from '(-5.5 3 1) 'to '(0 3 0) 'intensity 50)
       (camera "main" "perspective" 'from '(0 2.5 4.5) 'to '(-.5 1.25 0) 'fov 45)
       (ground)
       (make-arm-model))
      ((render 'reset))
      ((render 'to-file) (string-append "Frames/frame." 
					(number->string time)))
      ((render 'set-option!) '(ri-format 320 242 1))
      (render "main")
      (set-time! (+ time 1))
      ))
  

Animation:

(Crummy mpeg, needs much tweaking...)


To save the keys of a set of avars into an avar database, use the function "save-avars" in ox:
  ox --> (save-avars "myAvars.adb")
To reload a set of avars that have been previously saved, use:
  ox --> (load-avars "myAvars.adb")


Return to Schedule Information
mrl