AnimLoaderHandler AnimUVHandler Classes Table of Contents


Availability  LightWave® 6.0
Component  Layout
Header  lwanimsav.h

Animation savers write out a sequence of rendered images as an animation file. Anim savers add frames to the animation file as each frame is rendered. The rendered image is passed to the saver in the same way it's passed to frame buffer display plug-ins, except that animation savers are given a filename, and there is no pause after each frame.

Handler Activation Function

   XCALL_( int ) MyAnimSaver( int version, GlobalFunc *global,
      LWAnimSaverHandler *local, void *serverData );

The local argument to an anim saver's activation function is an LWAnimSaverHandler.

   typedef struct st_LWAnimSaverHandler {
      LWInstanceFuncs *inst;
      LWItemFuncs     *item;
      int              type;
      LWError         (*open)  (LWInstance, int w, int h,
                                  const char *filename);
      void            (*close) (LWInstance);
      LWError         (*begin) (LWInstance);
      LWError         (*write) (LWInstance, const void *R, const void *G,
                                  const void *B, const void *alpha);
   } LWAnimSaverHandler;

The first two member of this structure point to the standard handler functions. In addition to these, an anim loader also provides functions for opening and closing the file and for writing a frame, and it specifies what type of data it wants to receive. The context argument to the inst->create function is currently unused.

The type of pixel data Layout should send to the write function. This can be either LWAST_UBYTE or LWAST_FLOAT.

error = open( instance, width, height, filename )
Open the file. This function receives the width and height of the frame in pixels, and the name of the file. Called when a rendering session begins. Returns an error message string if an error occurs, otherwise it returns NULL.

close( instance )
Close the file. This is called when rendering is complete.

error = begin( instance )
Prepare to receive the next frame. Returns an error message string if an error occurs, otherwise it returns NULL.

error = write( instance, R, G, B, alpha )
Write the next scanline of the current frame. The scanlines for each frame are sent in order from top to bottom. The buffer arguments point to arrays of color channel values. There are exactly width values for each channel, one for each pixel in a scanline, and the values are either unsigned bytes or floats, depending on the type code. Returns an error message string or NULL.

You'll need a way to know when you can write each frame. You can initialize a scanline index to 0 in your begin and then increment it in write until you've received the last scanline. Or you can save the last completed frame in begin (save frame 1 when begin is called for frame 2, and so on) and save the last frame in close.

Interface Activation Function

   XCALL_( int ) MyInterface( int version, GlobalFunc *global,
      LWInterface *local, void *serverData );

This is the standard interface activation for handlers. The saver's interface is invoked by Layout when the user selects the saver from the anim saver list on the Render panel.


The SDK avisave sample is an anim saver for Windows AVI files.