
extern struct PointInfo {
 SHORT scrx;               /* these are points screen x & y coords */
 SHORT scry;
 struct PolygonInfo *poly;                        /* polygon number */
    /* may be type cast for special objects that use this structure */
 struct PointInfo *next;        /* address of next point in polygon */
 struct PointInfo *prev;        /* address of prev point in polygon */
 LONG x;                                       /* present 3d coords */
 LONG y;                                       /* present 3d coords */
 LONG z;                                       /* present 3d coords */
 LONG oldx;                                        /* old 3d coords */
 LONG oldy;                                        /* old 3d coords */
 LONG oldz;                                        /* old 3d coords */
 struct defpnt *dpt;         /* first deform point location if used */
 BYTE id;                     /* bit packed for point editing modes */
};

/* reminders:
typedef float vector[3];
typedef double dvector[3];
typedef LONG lvector[3];
*/

/* 2.11 change: removed linked list */
typedef struct Ivector {
 float a[2]; /* only holds screen x and y coords */
} ivector;

/* 2.11 change: removed linked list and typedef'd */
typedef struct RPvect { /* for rotated coords for complex polys */
 vector rpos;
} rpvect;

extern struct procobject {
 struct procobject *next;                                /* next object */
 struct procobject *prev;                                /* prev object */
 ULONG special;               /* special info structure for object type */
 USHORT in;                           /* type of object,0 to max ushort */
 /* alad.library, when freeing all procobjects checks this id and calls
    the appropriate library/function to free the special structures, then
    removes the object.
 */
 USHORT id;                   /* bit packed, selected, renderable, etc. */
                         /* NOTE that the upper bit of id is kept fluid */
                   /* you may use it freely as a temporary tracking bit */
 USHORT group[7];                                      /* grouping info */
};

extern struct splineobject {
 struct procobject *obj;              /* the procobject this belongs to */
 struct PointInfo *controlpnt;         /* first control point in spline */
 struct PointInfo *firstpoint;                 /* first point in spline */
 /* note that there are always twice as many control points as points   */
 /* point 0 uses controlpnt 0,1, point 1 uses 2,3 point 2 uses 4,5, etc */
 /* if spline is not closed, first and last control points are not used */
 USHORT points;                         /* how many points in splineobj */
 USHORT id;                            /* an ID holder for various uses */
 struct PathInfo *path;                        /* animation information */
             /* note that the path is not used and is not saved to file */
};

extern struct csplineseg {            /* these are control splines, 2D */
 struct csplineseg *next;
 struct csplineseg *prev;
 double x[2],y[2],cx[2],cy[2];
};

extern struct cspline {
 struct cspline *next;
 struct csplineseg *first;
 char name[80];
 long count;
 SHORT dpos;
 SHORT dsel;
 /* these are used for editing the csplines so always get a
    grid snap (and mag, etc) suited to the cspline
 */
 LONG gr[4]; /* snap and grid paint */
 double rm[4]; /* reticle,magmult,offsetx,offsety */
};

extern struct defpnt { /* this is for deforming poly for animations */
 struct defpnt *next;  /* allows multiple levels of deform */
 LONG x;               /* x,y,z coord of point at this level of deform */
 LONG y;
 LONG z;
};

extern struct BMResource {
 struct BMResource *next;
 char *path;          /* directory to save*/
 char *fn;            /* filename to save, and use for requester */
 struct RastPort rp;  /* rastport, full structure */
 struct BitMap bm;    /* bitmap, full structure, only used with old iff code */
 SHORT fx,lx;         /* special info for bitmaps with goobers */
 SHORT fy,ly;         /* special info for bitmaps with goobers */
                  /* note that these are saved and read with file! why? */
 SHORT wi;            /* its width */
 SHORT hi;            /* its height */
 LONG ba;             /* the number of colors in image, 2 to 16 mil */
 UBYTE planes;        /* if 6, assume ham */
 USHORT *pa;          /* 4 bit palette */
 ULONG *lpa;          /* 8 bit palette */
 UBYTE dpos;          /* directory position */
 UBYTE dsel;          /* directory select */
 USHORT available;    /* number of frames on the disk or in the anim */
 BYTE animtype;       /* 0-none, 1-individual, 2-opcode 5 */
 USHORT current;      /* if anim, frame number currently accessed */
 FLOAT init;          /* initial time to start play, frame 1 previous */
 FLOAT end;           /* end time of play, last frame after */
 FLOAT cycles;        /* number of times to play */
 UBYTE type;          /* cyclic or periodic play, forward or reverse */
 USHORT frames;       /* the extension number of the first frame loaded by user */
 struct DCTVCvtHandle *Handle; /* if non-null, this is a dctv image */
 ULONG DCTVError;     /* error report area */
 ULONG ptr;           /* pointer for ilbminfo structs ?? */
 struct cspline *animspline; /* spline rate control for anim textures */
};

extern struct BMLmemb {
 struct BMLmemb *next;
 struct BMResource *bmr; /* the bitmap this one uses */
                         /* if NULL, this is a procedural texture */
 UBYTE proc;             /* the procedural texture to apply */
                         /* if proc, some of these have other uses */
 ULONG info;             /* bitpacked information holder, see defines */
                         /* the entry values */
 FLOAT fstr;             /* Strength, range 0.0 to 1.0 */
 FLOAT fcol;             /* Color percentage to use range 0.0 to 1.0 */
                         /* for environ maps: */
 FLOAT fper;             /* amount of perspective division */
 FLOAT fsca;             /* scale of bitmap to use */
 FLOAT fscr;             /* amount of screen coordinate influence */
 FLOAT fnor;             /* amount of normal influence */
 FLOAT fpt1,fpt2,fpt3,fpt4,fpt5,fpt6,fpt7,fpt8; /* procedural */
 uvector fcolors[8];     /* first colors for proc textures */
 FLOAT fcolst[8];        /* first start percentage */
 FLOAT fcolen[8];        /* first end percentage */
 FLOAT frblend[8];       /* right blend for proc color */
 FLOAT flblend[8];       /* left blend for proc color */
                         /* the exit values */
 FLOAT lstr;             /* Strength, range 0.0 to 1.0 */
 FLOAT lcol;             /* Color percentage to use range 0.0 to 1.0 */
                         /* for environ maps: */
 FLOAT lper;             /* amount of perspective division */
 FLOAT lsca;             /* scale of bitmap to use */
 FLOAT lscr;             /* amount of screen coordinate influence */
 FLOAT lnor;             /* amount of normal influence */
 FLOAT lpt1,lpt2,lpt3,lpt4,lpt5,lpt6,lpt7,lpt8; /* procedural */
 uvector lcolors[8];     /* end colors for proc textures */
 FLOAT lcolst[8];        /* last start percentage */
 FLOAT lcolen[8];        /* last end percentage */
 FLOAT lrblend[8];       /* right blend for proc color */
 FLOAT llblend[8];       /* left blend for proc color */
 /* the constants */
 SHORT x;                /* remembered angles for free angle */
 SHORT y;
 SHORT z;
 FLOAT init;             /* % time begin */
 FLOAT end;              /* % time end */
 struct cspline *m;      /* spline rate control for this member */
 FLOAT cycles;           /* local cycles, inside this member */
 UBYTE type;             /* local type, bit packed periodic, etc */
 int numcol;             /* number of active colors in lower 8 bits */
         /* NOTE that the upper 24 bits are used for various other uses */
 int cpt[3];             /* center point of the procedural texture */
 /* the locals */
 SHORT wi;            /* useable width */
 SHORT hi;            /* useable height */
 FLOAT pocol;         /* rotation value */
 FLOAT chaxx;
 FLOAT chayy;
 FLOAT chazz;
 FLOAT firx;          /* span fir-end */
 FLOAT firy;
 FLOAT firz;
 FLOAT endx;
 FLOAT endy;
 FLOAT endz;
 FLOAT addx;          /* used for bitmap width/height, see setinten.c */
 FLOAT addy;          /* along with ostr */
 FLOAT addz;
 FLOAT str;   /* Strength, range 0.0 to 1.0 */
              /* note that if not in time range, set to 2? as flag! */
              /* now using colbufg as line of buffered strengths */
 FLOAT ostr;         /* old strength to make "clear" colors blend */
 FLOAT col;             /* Color percentage to use range 0.0 to 1.0 */
                         /* for environ maps: */
 FLOAT per;             /* amount of perspective division */
 FLOAT sca;             /* scale of bitmap to use */
 FLOAT scr;             /* amount of screen coordinate influence */
 FLOAT nor;             /* amount of normal influence */
 FLOAT pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8; /* procedural */
 FLOAT iper;             /* amount of perspective division */
 FLOAT isca;             /* scale of bitmap to use */
 FLOAT iscr;             /* amount of screen coordinate influence */
 FLOAT inor;             /* amount of normal influence */
 FLOAT ipt1,ipt2,ipt3,ipt4,ipt5,ipt6,ipt7,ipt8; /* procedural */
 uvector colors[8];      /* color array for procedural textures */
 FLOAT colst[8];         /* start percentage of color spacing */
 FLOAT colen[8];         /* end percentage of color spacing */
 FLOAT colctr[8];        /* center of color spacing */
 FLOAT rblend[8];        /* right blend for proc color */
 FLOAT lblend[8];        /* left blend for proc color */
 /* calculation vars */
 FLOAT irblend[8];
 FLOAT ilblend[8];
 SHORT spa;
 LONG *colbufr;  /* now packing rgb into longs here */
 LONG *colbufg;  /* and variable strengths as floats here */
 LONG *colbufb;  /* but using all three as position holders for procedurals */
                 /* and colbufb as packed rgb for bump maps */
};

extern struct BMList {
 struct BMList *next;
 struct BMLmemb *first; /* first member pointer */
 SHORT dpos;            /* for selection */
 SHORT dsel;            /* for selection */
                        /* note that this var is also used
                           (low 2 bits, temporary storage)
                           to record bump or genlock textures for render
                        */
 LONG count;            /* members in this list */
 UBYTE name[64];        /* editable by user */
 FLOAT cycles;          /* number of times to repeat */
 UBYTE type;            /* cyclic, periodic */
};

extern struct SmPoint {
 struct SmPoint *next;
 struct PointInfo *pnt;
};

extern struct currentnodevalues {
 UBYTE v;
 UBYTE r;
 UBYTE g;
 UBYTE b;
 UBYTE t;
 vector lnormal;
};

/* why not just put a currentnodevalues structure in each SHNode, memory? */
/* normal could be calculated for poly net before render and
   inverted if needed??? */

extern struct SHNode {
 ULONG flag; /* for file saves */
 USHORT count;
 ULONG *po; /* allocation area for pointers to polys */
};

extern struct BMCoords {
 struct BMCoords *next;
 FLOAT x;
 FLOAT y;
 FLOAT z;
};

extern struct BMPoint {
 struct BMCoords *first;
 struct SHNode *sn; /* pointers to adjacent polygons */
 vector rpos;       /* actual rotated positions for fill */
                    /* complex polys use the poly->rpnts */
 float len;         /* precalculated length of side for % calculations */
};

extern struct PolyBMpoint { /* for polys that have more than 4 points */
 float x[4];    /* real space temporary location */
 float y[4];    /* assigned at time of bitmap assignment */
 float z[4];    /* representing a bounding poly to reg poly */
 float oldx[4];    /* real space permanent location */
 float oldy[4];    /* assigned at time of bitmap assignment */
 float oldz[4];    /* representing a bounding poly to reg poly */
};

extern struct PolyBMInfo {   /* never drawn, just for textures, Gouraud */
 struct PolyBMpoint *pnt;    /* only if poly has more than 4 points */
 struct BMPoint bpt[4];      /* for texture coords */
 UBYTE init;                 /* unset just before painting a new frame */
 UBYTE flip;                 /* for phong, etc. */
};

/* the temptation is strong to index bitmaps for complex polys based on
   their edges, but think hard! the intersection tests that set the
   firstside and endside would be defeated by a poly that had several
   edges on the same scanline, or would it? a rectangle can have
   4 edges on the same line, and they work!
   Well, I just tried it and they don't!
   rectangles cannot be concave to render properly!
*/

extern struct PolygonInfo {
 struct PolygonInfo *next;                              /* next polygon */
 struct PolygonInfo *prev;                          /* previous polygon */
 struct PointInfo *firstpoint;                /* first point in polygon */
 UBYTE id;        /* bits: emp,emp,emp,texture,light,path,selected,show */
 UBYTE in;                         /* similar to id, information holder */
 USHORT points;                 /* maintained count of points for speed */
 USHORT group[7];           /* 0 to 4 if member of group, set to number */
                              /* group[5] is shading group, for reshade */
                               /* group[6] is shadow group, for shadows */
 struct BMList *bml;
 struct attlist *atl;                           /* polys attribute list */
 ULONG c;         /* current color 8 bits each, ?????, red, green, blue */
      /* note that this is used in non-render operations as a temporary */
 ULONG t;         /* current attr 8 bits each, ????, ?????, hard, trans */
 struct PathInfo *path;                                /* for animation */
 struct PolyBMInfo bmp;           /* for bitmap poly, textures, Gouraud */
 vector lnormal;                                          /* for lights */
 float planeconstant;                                    /* for shadows */
 vector rpos;       /* polys rotated/translated center for local lights */
 FLOAT nearz;                                     /* nearest z for poly */
 FLOAT lx,hx;                  /* screen bounding box for intersections */
 ivector *vertex;                /* used in fill mode for clipping clip */
                               /* examined in fill for NULL value which */
                              /* indicates that or clipped out of frame */
 struct PolygonInfo *special;            /* if meld, first poly in list */
                            /* or pointer light, gas, or wave structure */
 rpvect *rpnts;          /* if complex, records rotated coord in render */
 UBYTE pshow;                 /* bits 00111111 show, 01000000 meld flag */
 SHORT vertexcount;              /* when clipped, point count different */
                                    /* needed for increment and freeing */
 LONG *li;                                    /* light elimination bits */
};

extern struct wavlist {
 struct PolygonInfo *poly; /* pointer to the poly that is this wave poly */
 struct wavlist *next;    /* pointer to the next wavlist */
 struct wavmemb *first; /* first member of list */
 LONG count; /* how many members in list */
 FLOAT cycles; /* how many times to repeat the list */
 UBYTE fixed; /* reference static or moving position */
 UBYTE type; /* bit packed for periodic, etc. */
 UBYTE wavtype; /* sin or log type wave */
 UBYTE secoff; /* secondary offset */
 SHORT nwa; /* number of waves */
 FLOAT secspace; /* secondary offset spacing */
 LONG mir; /* minimum range */
 LONG mar; /* maximum range */
 FLOAT pha; /* phase */
 FLOAT fre; /* frequency */
 FLOAT amp; /* amplitude */
 LONG xspa; /* x spacing */
 LONG yspa; /* y spacing */
 LONG zspa; /* z spacing */
 LONG xrad; /* x radius */
 LONG yrad; /* y radius */
 LONG zrad; /* z radius */
 float inwa; /* inverse of nwa */
 float mirsq,marsq; /* squares of mir and mar */
 float marplusmir; /* (double)(wavl->mar+wavl->mir)>>1 */
 float imarminmir; /* 1.0/(double)(wavl->mar-wavl->mir)>>1) */
 float ixradsq; /* 1.0/(double)(wavl->xrad*wavl->xrad) */
 float iyradsq; /* 1.0/(double)(wavl->xrad*wavl->xrad) */
 float izradsq; /* 1.0/(double)(wavl->xrad*wavl->xrad) */
 float ixrad; /* inverse xrad */
 float iyrad; /* inverse yrad */
 float izrad; /* inverse zrad */
 float sxspa; /* (int)cwav->xspa*cwav->secspace; local x spacing */
 float syspa; /* (int)cwav->yspa*cwav->secspace; local y spacing */
 float szspa; /* (int)cwav->zspa*cwav->secspace; local z spacing */
 float sxxrad; /* 1.0/(cwav->xrad*cwav->xrad*cwav->secspace*cwav->secspace); x radius */
 float syyrad; /* 1.0/(cwav->yrad*cwav->yrad*cwav->secspace*cwav->secspace); y radius */
 float szzrad; /* 1.0/(cwav->zrad*cwav->zrad*cwav->secspace*cwav->secspace); z radius */
};

extern struct wavmemb {
 struct wavmemb *next;
 /* the entry values */
 UBYTE fnwa; /* number of waves */
 LONG fmir; /* minimum range */
 LONG fmar; /* maximum range */
 FLOAT fpha; /* phase */
 FLOAT ffre; /* frequency */
 FLOAT famp; /* amplitude */
 LONG fxspa; /* x spacing */
 LONG fyspa; /* y spacing */
 LONG fzspa; /* z spacing */
 LONG fxrad; /* x radius */
 LONG fyrad; /* y radius */
 LONG fzrad; /* z radius */
 /* the exit values */
 UBYTE lnwa; /* number of waves */
 LONG lmir; /* minimum range */
 LONG lmar; /* maximum range */
 FLOAT lpha; /* phase */
 FLOAT lfre; /* frequency */
 FLOAT lamp; /* amplitude */
 LONG lxspa; /* x spacing */
 LONG lyspa; /* y spacing */
 LONG lzspa; /* z spacing */
 LONG lxrad; /* x radius */
 LONG lyrad; /* y radius */
 LONG lzrad; /* z radius */
 /* the constants */
 FLOAT init; /* % time begin */
 FLOAT end;  /* % time end */
 struct cspline *mspline; /* spline rate control */
 FLOAT cycles; /* local cycles, inside this member */
 UBYTE type; /* local type, bit packed periodic, etc */
 UBYTE fixed; /* reference static or moving position */
 UBYTE wavtype; /* sin or log type wave */
 UBYTE secoff; /* secondary offset */
 FLOAT secspace; /* secondary offset spacing */
};

extern struct attlist {
 struct attlist *next;
 struct attmemb *first; /* first member of list */
 SHORT dpos;
 SHORT dsel;
 LONG count; /* low word: how many members in list up to 65000 */
             /* upper word:
                low byte: shadow acceleration 0 to 255
                upper byte: unused
             */
 UBYTE name[64]; /* the users name for this list */
 FLOAT cycles; /* how many times to repeat the list */
 UBYTE type; /* bit packed for periodic, etc. */
 UBYTE vi; /* visible */
 UBYTE bk; /* background */
 UBYTE nr; /* red */
 UBYTE ng; /* green */
 UBYTE nb; /* blue */
 UBYTE nv; /* reflectivity */
 UBYTE si; /* self illumination */
 UBYTE sv; /* specular reflectivity (hardness) */
 UBYTE hs; /* hardfactor (highlight size ) */
 UBYTE rr; /* red reflective */
 UBYTE rg; /* green reflective */
 UBYTE rb; /* blue reflective */
 UBYTE tr; /* transparency */
 UBYTE tt; /* transparency thick */
 UBYTE tl; /* transparency light */
 UBYTE ws; /* wave sensitivity */
 UBYTE di; /* diffusion */
 UBYTE ev; /* environment reflectivity */
 /* these are for speed, double 0.0 to 1.0 equivalents */
 /* can be figured once, then used when needed, eliminating multiplies */
 FLOAT dnr; /* red */
 FLOAT dng; /* green */
 FLOAT dnb; /* blue */
 FLOAT dnv; /* reflectivity */
 FLOAT dsi; /* self illumination */
 FLOAT dsv; /* specular reflectivity (hardness) */
 FLOAT dhs; /* hardfactor (highlight size ) */
 UBYTE drr; /* red reflective */
 UBYTE drg; /* green reflective */
 UBYTE drb; /* blue reflective */
 FLOAT dtr; /* transparency */
 FLOAT dtt; /* transparency thick */
 FLOAT dtl; /* transparency light */
 FLOAT dws; /* wave sensitivity */
 FLOAT ddi; /* diffusion */
 FLOAT dev; /* environment reflectivity */
 /* these are linetypes, added for version 2.1 */
 UBYTE linetype; /* not bitpacked, incremented */
 FLOAT linedistance; /* for line types not normal */
};

extern struct attmemb {
 struct attmemb *next;
 /* the entry values */
 UBYTE fnr; /* red */
 UBYTE fng; /* green */
 UBYTE fnb; /* blue */
 UBYTE fnv; /* reflectivity */
 UBYTE fsi; /* self illumination */
 UBYTE fsv; /* specular reflectivity (hardness) */
 UBYTE fhs; /* hardfactor (highlight size ) */
 UBYTE frr; /* red reflective */
 UBYTE frg; /* green reflective */
 UBYTE frb; /* blue reflective */
 UBYTE ftr; /* transparency */
 UBYTE ftt; /* transparency thick */
 UBYTE ftl; /* transparency light */
 UBYTE fws; /* wave sensitivity */
 UBYTE fdi; /* diffusion */
 UBYTE fev; /* environment reflectivity */
 /* the exit values */
 UBYTE lnr; /* red */
 UBYTE lng; /* green */
 UBYTE lnb; /* blue */
 UBYTE lnv; /* reflectivity */
 UBYTE lsi; /* self illumination */
 UBYTE lsv; /* specular reflectivity (hardness) */
 UBYTE lhs; /* hardfactor (highlight size ) */
 UBYTE lrr; /* red reflective */
 UBYTE lrg; /* green reflective */
 UBYTE lrb; /* blue reflective */
 UBYTE ltr; /* transparency */
 UBYTE ltt; /* transparency thick */
 UBYTE ltl; /* transparency light */
 UBYTE lws; /* wave sensitivity */
 UBYTE ldi; /* diffusion */
 UBYTE lev; /* environment reflectivity */
 /* the constants */
 FLOAT init; /* % time begin */
 FLOAT end;  /* % time end */
 struct cspline *g; /* spline rate control */
 FLOAT cycles; /* local cycles, inside this member */
 UBYTE type; /* local type, bit packed periodic, etc */
 UBYTE vis; /* visible during this member? */
 UBYTE bk; /* background if front poly */
 UBYTE linetype; /* normal, outline, centers, points, INCREMENTED, not bitpacked */
 FLOAT flinedistance; /* entry width if not normal */
 FLOAT llinedistance; /* exit width */
};

extern struct DeformInfo {
 struct DeformInfo *next; /* one for each level of deform */
 FLOAT init;              /* % of time that this one begins */
 FLOAT end;               /* % of time that this one ends */
 struct cspline *m;       /* spline rate control */
};

/* the path has combination types, for example, each one has a
   global periodic
   member periodic
   angle periodic (3)
   movement periodic
   the path holds the variables for global type and movement type
   the member holds the variables for membertype and angle types
   when the member calculations are done,
   the pcntdone is calculated for the path, and is
   affected by the global type
   then this is used to determine the local time and the
   member types are used
   the final angles are stored in the pathinfo

   for movement, the globaltype is used to determine the local
   percentdone, and this is used to determine the movement
   time, based on the movement type

   instancing, which is global, is performed similarly
*/

extern struct PathInfo {
 struct PolygonInfo *pathpoly;            /* poly for movement direction */
 struct PointInfo *guidepoint;         /* current location of guidepoint */
 struct PathInfo *guidepath;            /* may be following another path */
 struct DeformInfo *dft;            /* beginning of list of deform times */
 struct pathmemb *first;                  /* first rotation instructions */
 USHORT count;                                     /* number of pathmemb */
 /* these are the main globals to the path */
 FLOAT cycles;
 struct cspline *g;                          /* time alteration for path */
 LONG type;       /*  modified at time of member calculation, KEEP FLUID */
 /* these are translation, globals to the path! */
 FLOAT initm;                                          /* offset in time */
 FLOAT cyclesm;                /* number of times to repeat in animation */
 struct cspline *m;                        /* translation spline control */
 LONG movetype;   /* bit packed info on direction of rotate and movement */
 /* these are angles are set from pathmemb in effect */
 FLOAT aax,aay,aaz;                                  /* current rotation */
 SHORT deform;  /* if not 0, number of deform positions present in polys */
 FLOAT cyclesd;                                         /* deform cycles */
 FLOAT deformdone; /* this path's deform time */
 LONG deformlevel; /* and it's level */
 FLOAT sx,sy,sz;                                      /* current scaling */
 FLOAT chax,chay,chaz;                            /* current translation */
 /* these are mechanical wave displacement, set from pathmemb in effect */
 FLOAT wd,wf,wp;            /* current wave displacement,frequency,phase */
 FLOAT mar,mir;                            /* current wave max/min range */
 FLOAT wang;                                       /* current wave angle */
 FLOAT wnum;                        /* current wave number, type of wave */
 /* these are for instancing */
 LONG inum;                                           /* instance number */
 LONG itype;                               /* instance types, bit packed */
 struct cspline *ig;                  /* instance global spline adjuster */
 FLOAT ift,ilt;                                          /* time offsets */
 FLOAT ifpx,ifpy,ifpz,ilpx,ilpy,ilpz;                /* position offsets */
 FLOAT ifrx,ifry,ifrz,ilrx,ilry,ilrz;                /* rotation offsets */
 struct cspline *ict,*icpx,*icpy,*icpz,*icrx,*icry,*icrz;  /* spline adj */
 LONG ipl;                                 /* instance polys (per level) */
 struct PolygonInfo *ipf;                  /* first and poly in instance */
 FLOAT pathdone;             /* calculated and altered pcntdone for path */
 FLOAT itm,ipx,ipy,ipz,irx,iry,irz;       /* current values for instance */
 LONG ilevel;       /* paths created by instancing need to remember this */
 LONG *pathbuf;           /* temporary space for instances of this paths */
 /* these are required to track aligns */
 FLOAT obsegpct;
 struct PointInfo *obpt1,*obpt2,*obpt3;
};

extern struct pathmemb {
 struct pathmemb *next;                  /* next rotation instructions */
 /* these are main */
 FLOAT init;                                /* time this member starts */
 FLOAT end;                                   /* time this member ends */
 struct cspline *g;                     /* global time adjusting spline */
 FLOAT cycles;                       /* number of times member repeats */
 /* these are rotation, x,y,z dependent */
 FLOAT initx,inity,initz;          /* start%, rotation offsets in time */
 FLOAT fx,fy,fz;                                   /* first angles */
 FLOAT lx,ly,lz;                                   /* last angles */
 FLOAT cyclesx,cyclesy,cyclesz;   /* number of times to repeat */
 struct cspline *rx,*ry,*rz;       /* rotation spline controls */
 /* this type holds main and x,y,z periodic flags */
 LONG type;
 /* these are scaling, x,y,z dependent */
 FLOAT sinitx,sinity,sinitz;      /* start%, scaling offsets in time */
 FLOAT fsx,fsy,fsz;                                   /* first percents */
 FLOAT lsx,lsy,lsz;                                   /* last percents */
 FLOAT scyclesx,scyclesy,scyclesz;   /* number of times to repeat */
 struct cspline *sx,*sy,*sz;       /* rotation spline controls */
 /* this type holds scaling x,y,z periodic flags */
 LONG stype;
 /* these are for mechanical wave displacement */
 FLOAT initw; /* start%, wave offset in time */
 FLOAT cyclesw; /* number of times to repeat */
 FLOAT fwd,lwd; /* displacement */
 FLOAT fwf,lwf; /* frequency, or distance crest to crest */
 FLOAT fwp,lwp; /* phase, how crests are positioned and moved */
 FLOAT fwmar,lwmar,fwmir,lwmir; /* ranges for circular waves */
 FLOAT fwang,lwang; /* rotation of wave effect */
 LONG wnum; /* type wave, linear, cylinder, sphere, etc */
            /* also holds axis reference */
 LONG wtype; /* bit packed periodic flags */
 struct cspline *wspl;   /* wave spline control */
};

extern struct FacePoint {
 struct PointInfo *pnt;
 struct FacePoint *next;
};

extern struct space {
 struct space *next;
 struct space *prev;
 struct PolygonInfo *firstpoly;
 struct PolygonInfo *lastpoly;
 struct procobject *firstprocobject;
 struct procobject *lastprocobject;
 int numberpoly;
 SHORT ax;
 SHORT ay;
 SHORT az;
 SHORT xtilt;
 SHORT ytilt;
 SHORT ztilt;
 int xchange;
 int ychange;
 int zchange;
 int dw;
 int di;
 SHORT axis;
 SHORT quickmove;
 SHORT isometric;
 SHORT canon;
 SHORT trackpoint;
 float atpoint[3];
 struct PolygonInfo *which; /* chosenpoly */
 struct procobject *chosenprocobject;
 struct PointInfo *nearpoint;
 struct lights *firstlight;
 struct cameraobject *cam; /* a space can only have one camera */
 struct gaslist *firstgaslist;
 struct wavlist *firstwavlist;
 /* next time add:
  QMpolys QMpnts gnumber atpaxislen
 */
};

extern struct lights {
 struct PolygonInfo *li; /* pointer to the poly that is this light */
 struct lights *next;    /* pointer to the next poly that is a light */
 /* lights use attlist for color, and the
    reflectivity setting of the attlist for strength
 */
 LONG range;           /* radius of influence */
 UBYTE type;           /* periodic & highlight &shadow flags */
 struct PolygonInfo *lastshadowpoly; /* for optimizing shadows */
 LONG *shadowbuf;  /* buffer for last scanline for shadows */
 float aconst,adist,adistsq; /* attenuation factors */
 /* added these for 2.2, no change to file format */
 double sqrange; /* range squared for faster compare */
 double irange; /* range inverse for faster divide */
};

extern struct dplines { unsigned char *r, *g, *b; };
extern struct dpimage {
   int wi, hi;
   struct dplines *dprgb;
};


extern struct flareobject { /* this is the head of a list */
 struct procobject *obj;  /* the procobject this belongs to */
 struct flarememb *first;
 struct BMList *bml;      /* the bmlist to be used */
 struct attlist *atl;     /* visible (and color to blend?) */
 struct PolygonInfo *po;  /* triangle? user's handle */
 struct PathInfo *path;   /* animation control */
 struct cspline *g;       /* change control */
 LONG count;              /* number of members */
 SHORT type;              /* periodic, etc */
 ULONG in;                /* bit packed information holder */
 FLOAT cycles;            /* times to repeat */
/* from here, volatile, calculated, (some are file saved?) */
 FLOAT wpct,hpct;         /* apparent size of flare as % of render size */
 FLOAT rot;               /* current rotation of flare image */
 FLOAT bmlcol;            /* amount of color to get from bml (rest from atl) */
 FLOAT reldist;           /* relative distance for sizing & dropoff */
 FLOAT offx,offy;         /* offsets from center */
/* these for future development */
 FLOAT dropoff;           /* amount of dropoff to apply, or min value? */
 FLOAT strnear;           /* strength range, closer than near, 1.0 */
 FLOAT strfar;            /* further than far, 0.0 */
};

extern struct flarememb {
 struct flarememb *next;
 struct cspline *m;       /* change control */
 FLOAT init;              /* % time begin */
 FLOAT end;               /* % time end */
 FLOAT cycles;            /* local cycles, inside this member */
 USHORT type;             /* local type, bit packed periodic, etc */
 USHORT in;               /* info holder */
 FLOAT fwpct,lwpct;
 FLOAT fhpct,lhpct;
 FLOAT frot,lrot;
 FLOAT fbmlcol,lbmlcol;
 FLOAT freldist,lreldist;
 FLOAT foffx,loffx;
 FLOAT foffy,loffy;
/* these for future development */
 FLOAT fdropoff,ldropoff;           /* amount of dropoff to apply, or min value? */
 FLOAT fstrnear,lstrnear;           /* strength range, closer than near, 1.0 */
 FLOAT fstrfar,lstrfar;             /* further than far, 0.0 */
};

extern struct gaslist {
 struct gaslist *next;   /* next gaseous object */
 struct gasmemb *first;  /* first member of list */
 struct PolygonInfo *p[6]; /* polygons that bound this gas */
 float sam;           /* number of samples to take */
 float str;           /* strength of gas */
 float noi;           /* strength of noise to use */
 float nsc;           /* scale of noise, typ. 0.0001, show x1000 */
 int att;              /* how to attenuate the gas, sphere, top-bot, etc */
 SHORT sides;          /* bits: top,bot,bak,frt,lft,rgt, color/dens */
 float scax,scay,scaz; /* scalers to equivocate sizes */
 float six,siy,siz;    /* sizes, x,y,z */
 float largest;        /* max size */
 float cex,cey,cez;    /* centers */
 float max,may,maz;    /* maximum values */
 float mix,miy,miz;    /* minimum values */
 float ra;             /* minimum radius of sphere (squared) */
 float fac;            /* density falloff power */
 SHORT ntn;            /* number of noise samples */
 float ndf;            /* noise definition power */
 FLOAT cycles; /* how many times to repeat the list */
 UBYTE type; /* bit packed for periodic, roll, etc. */
 float res;            /* (hirz-lorz)/div, size of steps in space */
 float lorz,hirz;      /* current frame TOTAL lo and hi rotated z */
 float avestr;         /* averaged strength per sample */
 float currentz;       /* the current distance after adding steps */
 float rollamt;        /* the current amount of roll */
 SHORT sub;            /* FREE was subdivisions, no longer used */
 SHORT count;          /* how many members */
 UBYTE r,g,b,d;        /* blending secondary color for noise */
 float isix,isiy,isiz; /* inverted sizes for speed */
 float cbal,dbal;      /* color/density balancers */
 float isam;           /* inverted samples */
 float strdsam;        /* strength divided by samples */
 float iglobalsize;    /* 1.0/(ga->hirz - ga->lorz) */
 float hglobalsize;    /* ga->lorz + ((ga->hirz - ga->lorz)*0.5) */
 float ofx,ofy,ofz;    /* noise translation, calculated */
 float rcx,rcy,rcz;    /* noise rotation centers, calculated */
 float rox,roy,roz;    /* noise rotation, additive from prev member */
 float srx,sry,srz,crx,cry,crz; /* noise calculated sines,cosines */
 UBYTE init;           /* used to announce participation */
 UBYTE rot;            /* noise announce rotation, 1,2,4 is x,y,z */
 /* these are to allow gas deforms (resizing only */
 float omix,omiy,omiz;
 float osix,osiy,osiz;
};

extern struct gasmemb {
 struct gasmemb *next;
 float fsam;           /* number of samples to take */
 float fstr;           /* strength of gas */
 float fnoi;           /* strength of noise to use */
 float fnsc;           /* scale of noise to use */
 float fndf;           /* definition of noise */
 float ffac;           /* density falloff power */
 float fofx,fofy,fofz; /* noise positioning */
 float frcx,frcy,frcz; /* noise rotation positioning */
 float lsam;           /* number of samples to take */
 float lstr;           /* strength of gas */
 float lnoi;           /* strength of noise to use */
 float lnsc;           /* scale of noise to use */
 float lndf;           /* definition of noise */
 float lfac;           /* density falloff power */
 float lofx,lofy,lofz; /* noise positioning */
 float lrcx,lrcy,lrcz; /* noise rotation positioning */
 float rox,roy,roz;    /* noise rotation, additive from prev member */
 SHORT sides;
 UBYTE fr,fg,fb,ft;       /* blending secondary color for noise */
 UBYTE lr,lg,lb,lt;
 FLOAT init;           /* % time begin */
 FLOAT end;            /* % time end */
 struct cspline *mspline; /* spline rate control */
 FLOAT cycles;         /* local cycles, inside this member */
 UBYTE type;           /* local type, bit packed periodic, etc */
};

extern struct target {
 struct target *next;    /* next in list */
 struct PolygonInfo *po; /* the target poly */
 FLOAT init,end;         /* % time begin, end */
 struct cspline *tspline; /* spline rate control (internal changes) */
 float trans;            /* percentage of time for transition to next */
 struct cspline *transspline; /* spline rate control (transition changes) */
 float ftilt;            /* tilt of camera */
 float fdw,fdi;          /* each target can have different lens */
 float ltilt;
 float ldw,ldi;          /* allows zoom during animation! */
 float x,y,z;            /* target position in space derived from poly */
 FLOAT cycles;           /* local cycles, inside this member */
 UBYTE type;             /* local type, bit packed periodic, etc */
};

extern struct cameraobject {
 struct cameraobject *next; /* for future multiple cameras */
 struct PolygonInfo *po;    /* the camera poly */
 struct target *targ;       /* first target in list */
 SHORT count;               /* track of count of targets */
 float dw,di;               /* lens specifications */
 float tilt;                /* tilt of camera */
 float x,y,z;               /* camera's position in space */
 float tx,ty,tz;            /* "target" position in space */
 float rx,ry,rz;            /* rotation angles of camera to center target */
 struct cspline *g;         /* spline rate control */
 FLOAT cycles;              /* global cycles */
 UBYTE type;                /* global type */
 LONG nearplane,farplane;   /* clipping planes for this camera */ 
};

extern struct fpinfo {
 float x; /* screen x */
 float y; /* screen y */
 double rx; /* real space */
 double ry;
 double rz;
 float prx; /* modified perspective space */
 float pry;
};

typedef struct EDGE {
 struct EDGE *next;
 SHORT len;
 FLOAT x;
 FLOAT x_add;
 struct PolygonInfo *poly;
} edge;

extern struct trans {       /* the first one is just a dummy head to the list */
 struct trans *next; /* pointer to the next level */
 FLOAT *z;        /* pointer to the memory allocated for the z buffer */
 FLOAT *x;        /* pointer to the memory allocated for the x buffer */
 FLOAT *y;        /* pointer to the memory allocated for the y buffer */
 LONG *p;        /* pointer to the memory allocated for the poly buffer */
 LONG *c;        /* pointer to the memory allocated for the color buffer */
};

extern struct Pair { struct PolygonInfo *po; FLOAT d; };

/* this is the structure for buffering poly attributes pixel-pixel */
extern struct patbuf {
 SHORT co[5]; /* r,g,b,tr,gen */
 float hs[2]; /* hrd, sil */
 float nor[3]; /* normal */
};

/* and this one for buffering lights */
extern struct litbuf {
 SHORT co[7]; /* r,g,b,hr,hg,hb,shadow */
 float dm[2]; /* dist,mag */
 float ray[3]; /* normalized ray */
};

/* the structure for our tools */
extern struct aladtool {
 struct aladtool *next;
 struct aladtool *prev;
 char name[80];  /* the tool name as found */
 short sync;     /* is the tool synchronous? */
};

/* a structure for screen polys to be overlayed on editor
   the poly is drawn for full number of points, or until one of
   the points has a negative x
*/
extern struct aladscreenpoly {
 struct aladscreenpoly *next;
 USHORT pen; /* pen number for poly */
 USHORT count; /* number of point pairs */
 SHORT *pnts; /* point pairs */
};
