Animator

Work > Programming > Animator
A Brief History: A few years ago I bought a Maya book, downloaded Maya PLE and excitedly began working on an animation. After about half an hour of fighting with it's complex user interface I realized that my 500MHz iBook G3, with a 1204x768 display, was just not up to the challenge. It couldn't handle the multi-view system, the menus didn't fit on the screen... the list of problems went on and on.

It kind of ticked me off.

So I wrote Animator. Animator is a fully functional 3D animation tool. It's user interface is simple to say the least, and will run at blazing speed on a 500MHz machine. To create an animation, you write a script which defines all of the 3DMF models and their movements. The scripting language is quite powerful, and allows you to do everything from basic movement and rotation of models, to adjustment of lighting and complex model morphs. When you Render the animation, Animator runs the script and produces a Quicktime movie to your specs. It generates a log when the render is complete, allowing you to debug your animation and check for problems. Interested? Below is a complete list of the commands in the scripting language. You'll also find a few sample scripts and the accompanying movies. Enjoy! (Please see system requirements at the bottom before downloading)

Let's Get Scripting: The scripting language built into Animator is what you use to create animations. It allows you to perform a wide range of operations and won't require any haggling with a fancy UI. Let's look at a very simple script and movie.

This script uses one of the more advanced animation techniques in Animator to make a ball fall on a nail and pop. Take a look at the final movie over here. The first two lines of the script define the models within the animation. The statement "Define Ball as :Models:Ball-Inflated:" simply means, "there's a model file at this location, and I'm gonna call it Ball from now on". The next line, "camera z 1000" is just as simple. It sets the Z value of the camera to 1000. This essentially "zooms out" the camera so we can see the scene. The next two lines do the same thing, but with the Ball and Nail models. Once those models are in place, we can begin animating. The line "DefineLoop BallMove as Ball moveY -350 step 24" creates the first part of the animation. It creates a loop, which is an operation which will happen over multiple frames. This loop moves the ball a total of -350 on the Y axis, over a period of 24 frames. This will put the ball just above the nail - ready to be popped. The next line in the animation tells the compiler to go ahead and render those first 24 frames. There isn't anything else we need to do to prepare those. The next line is another loop. This time, we're doing a morph from the Ball model to another model, "Ball-Deflate4". Animator is capable of doing vertex-by-vertex deformation on models, providing that both models have the same number of vertices. Ball-Deflate4 is the completely deflated ball. We will change the original ball into this ball over 48 frames.

Sound relatively straightforward? I hope so. Mastering the language can take a little time, but I think you'll find that it's very convenient once you understand how it works. Let's look at what happens when we go to compile the script. A window allows us to choose a location for the final movie as well as change the fps and resolution. Rendering large movies can take a long, long time on a slow machine, so Animator brings up a window showing you the current frame as it progresses through the script.

Once the render is complete, we'll get a render log window, which displays any errors or notable events that took place during the execution of the script. This can be convenient when something isn't working. Here, it looks like there was one model it couldn't find, called LonelyFlowerBase. It couldn't create it, and then couldn't perform any of the animations on it. It also caused two loops to fail before I cancelled the render.

And Now the Gritty Details: So we've seen one script and how it is rendered. But there are a lot more commands than the few I used in that script. Here's a full list of them, along with the parameters they take and a brief description. Global functions are exactly as written below. Object functions must be preceded by the object name.

 
Global Functions Description
Define ObjectName as ObjectPath Creates the object in the scene.
DefineLoop LoopName as Function step value Creates a loop. Function can be any object function and is performed over value steps.
StopLoop LoopName Kills the loop with the name LoopName
AmbientLight value Sets theamount of ambient light in the scene. value must be0-100
FloodLight value Sets theamount of flood light in the scene. value must be0-100
FogStart value Sets the distance at which fog begins to appear.
StartFog turns on distance fog.
StopFog turns off distance fog.
FOV value Sets the field of view. Should be between 40 and 100. (degrees)

Functions of Models
Preceded by model name: ex. ModelObject MoveX 100

Functions Description
Yaw radians Rotates by radianson the X plane
Pitch radians Rotates by radianson the Y plane
Roll radians Rotates by radianson the Z plane
MoveX value Adds value toX
MoveY value Adds value toY
MoveZ value Adds value toZ
X value Sets X to value
Y value Sets Y to value
Z value Sets Z to value
RotateAroundAxis X,Y,Z,Radians Rotates the object around the axis X,Y,Z by Radians
Scale value Sets the scale of the object to value
Close Destroys the object and removes it from the scene.
PointAt objectName Orients the object so it's face is pointing toward objectName
MoveForward value Moves the object "forwards" in the direction it's face is pointing.
Model path Exchanges the model for the model at path
Morph topath USED ONLY IN LOOPS. Morphs the model into another model at path.

The download includes the source, and a few more complicated sample scripts. To see a few more movies created with Animator, use the download link above and look in the Movies folder. Animator is of course, a very simplistic system, and you probably won't think much of the animations. But for a 15 year old on a 500MHz iBook with Quesa and RealBasic, I think it's pretty good.

System Requirements: This application requires Mac OS X, or at least CarbonLib. It also requires Quesa, an alternative to OpenGL that provides the framework for the 3D environment used in Animator. You can get it from http://www.quesa.org/ for free. Aside from that, well, it ran beautifully on my 500MHz iBook with 576MB or memory. The faster, the better, but it should run on about anything.

Disclaimer: I am now a proud user of Maya 6.0 Unlimited. Maya boasts its own scripting language which can take some of the pain out of creating models and performing basic operations, and on my new Powerbook, it's a beautiful sight. So it's really not as bad as I make it sound...

Version History:

  • 2.0 = You don't want to see version 1. This application did everything I need it too, and will probably never be updated now that I have maya. Feel free to mess around though. If you do anything cool with it, let me know!

- J. Benjamin Gotow