The data used to construct a 3-D display under Skandha4 consists in general of instances of the various 3D classes (Camera, Light, Light-Model, Matrix44, Graphic-Relation, Float-Array, Int32-Array ...) together with the variables and properties attached to those objects.
Saving such a collection of objects to disk is a nontrivial proposition, particularly if it is desired to distribute the objects between several diskfiles, and to preserve references between such objects.
XFIL provides a set of tools to help perform such save/restores.
Every instance of CLASS-3D or a subclass thereof (which is to say, essentially all the 3D classes) contains an internal record recording which diskfile it 'belongs' in, and a unique integer distinguishing that object from all other objects in the diskfile.
XFIL maintains a list of loaded files, and also a 'current file' pointer. All 3D objects created are placed in the 'current file'.
XFIL-SAVE-GRAPHICS-FILE will all write all objects "in" the indicated XFIL instance to the appropriate diskfile. It returns the stream used to write the file, so that the caller can add further code before closing the file. This code will normally update the lisp variables used by the application to find the objects in the file.
The file format consists simply of lisp code which will be executed by the normal lispreader when the file is loaded. A few special lisp functions and messages are defined for this purpose.
For the sake of efficiency, internal values of the 3D objects are stored in binary form in a separate file.
When loading a graphics file, if the lispreader encounters a reference to an object in another file, it will currently recursively load that other file. (Future versions of the code may wait until the object is actually used before loading the file it is in.)