next up previous contents
Next: Cel Coordinate System Up: AM_SoundTrack Previous: AM_SoundTrack   Contents

Buffering Scheme

In order to understand the sequence of events that goes on between the resource file and the output on screen, consider the following diagram of the buffering scheme:



\resizebox*{1\textwidth}{!}{\includegraphics{am.buffers.eps}}



First, the XML animation resource file is loaded (or it may be encapsulated in a larger XML file). The file may contain embedded SVG code to describe vector graphic cels, or it may reference external PNG or JPG files (in fact any file format supported by SDL_Image will probably be supported, but we specifically want to encourage the use of PNG and JPG for reason that they are open formats).

For SVG cels, the data will be rendered to an SDL surface using code adapted from Raph Levien's rsvg renderer (originally written for Gnome), while PNG or JPG files can simply be loaded by SDL_Image and then converted to the correct internal surface format.

This load process is relatively slow, so it will have to be done somewhat carefully to avoid noticeable delays.

As the pre-scripted animation is played, or as information driving the animation is received from the game engine, commands are generated to place cels into the animation layup and update the display accordingly.

These will specify particular ``placements'' of the cels which include procedurally alterable information: the position, rotation, and scale of the cel as it will appear in the layup as well as lighting and special effects information.

Unfortunately, the rotation step is relatively slow -- just a little too slow to run on every frame on the lower end computers we are supporting (including the Pentium 90 that I'm developing the game engine on). In order to cope with this, the design incorporates a cache to hold recently rotated cel surfaces. So the first thing the rotation code does is check to see if it has already computed the desired rotation (or one that matches within a specified tolerance). If so, it uses that copy instead of recomputing it. Otherwise, the new copy is computed and put into the least-accessed element of the cache (see the AutoManga rotations source code for the actual caching algorithm).

After this is done, the less expensive operation of blitting is used to put the cel at the correct location on the LayUp.


next up previous contents
Next: Cel Coordinate System Up: AM_SoundTrack Previous: AM_SoundTrack   Contents
Terry Hancock 2001-04-01