CAD-3D Animation file format by Tom Hudson This document is intended to give interested persons the ability to generate or read the animation data files used by the CAD-3D solid-modeling program. The animation files were created to be as compact as possible, while including all the information necessary to animate a wireframe or solid object quickly. The Files. Each CAD-3D animation file is resolution-specific to run in either monochrome or low-resolution mode. The coordinates are set to the appropriate resolution at the time of writing to reduce processing done by the animation program. The normal way to use a CAD-3D animation file is to read the entire file into a single RAM data structure and then use pointers to scan through the data, plotting the objects to the screen. The animation file structure is useful for other applications, as well. Since the animation images are stored as "frames", each frame can be processed as an independent image, and output to a printer or plotter for later use. The nice thing about this capability is that the user could record a number of images in the animation file and run them all off onto a printer in a single operation later, with the computer automatically advancing the paper after each image is printed. Each image in the animation file is termed a "frame". Within each frame is a list of faces or line segments that is to be plotted to reconstruct the 3-D object. For solid objects (with hidden faces removed), these faces are furnished in order from the farthest face to the nearest face and plotted in this order. In this way, the subsequent face plots erase the faces that are behind the face being plotted. Each line segment or face in a frame is plotted until a "frame" flag is found, at which time the program advances to the next frame, sheet of paper, etc. The file is structured as follows: WORD -- Animation resolution (0 -- 16-color low-res or 2 -- monochrome) WORD -- Animation mode (0 -- Wireframe, 1 -- Hidden, 2 -- Solid, 3 -- Outlined) 16 WORDS -- Color palette for the animation sequence The remainder of the file is a structure that gives data for the various triangular faces in the image. The structure repeats until the count flag is <= 0. If the flag is zero, there are no more faces to draw in the current frame, and you can show the frame just drawn. The next group of faces should be plotted on another screen in memory. When that frame is drawn, it is shown and plotting begins on the original screen. This repeats until the flag is -1, indicating the end of the animation file. BYTE -- Count flag, has the following values: 0: New frame. Clear screen and reread the count flag. -1: End of animation file. >0: A normal face to draw. BYTE -- Face color and line segment flags. Low nybble contains color to use for drawing the face in color modes or 0-15 for shading level in monochrome. High nybble contains the line segment draw flags. Bit 6 tells whether the first line segment is drawn, bit 5 tells whether the second line segment is drawn, and bit 4 tells whether the third line segment is drawn. In animation modes 1, 2 and 3, there are two WORDs at this point, the polygon minimum Y and maximum Y values for using line A to plot the polygons. The first is POLYMINY, the second is POLYMAXY. These values let you avoid having to find the minimum and maximum Y values yourself. These values are not needed in wireframe mode and are not present. Now come the Vertices for the object, stored as eight WORDS as follows: VERTEX1 X VERTEX1 Y VERTEX2 X VERTEX2 Y VERTEX3 X VERTEX3 Y VERTEX1 X VERTEX1 Y The first line segment is VERTEX1-VERTEX2, the second line segment is VERTEX2-VERTEX3, and the third line segment is VERTEX3-VERTEX1. For wireframe objects, the last two points are unnecessary, but for solid objects, you can simply point to the first value and execute the polygon fill operation. The last two values close the polygon by joining the last point to the first. ace are edges. Bits 0-3: Color of the face. COLOR 1 is 1-7 (where