--- ray/src/cv/rad2mgf.c 1994/07/09 09:42:48 2.4 +++ ray/src/cv/rad2mgf.c 1994/12/12 12:09:28 2.8 @@ -15,6 +15,8 @@ static char SCCSid[] = "$SunId$ LBL"; #include "color.h" #include "lookup.h" +#define PI 3.14159265358979323846 + int o_face(), o_cone(), o_sphere(), o_ring(), o_cylinder(); int o_instance(), o_source(), o_illum(); int o_plastic(), o_metal(), o_glass(), o_mirror(), o_trans(), o_light(); @@ -44,7 +46,7 @@ char VKFMT[] = "%+1.9e %+1.9e %+1.9e"; #define NVERTS 256 -long clock; /* incremented at each vertex request */ +long vclock; /* incremented at each vertex request */ struct vert { long lused; /* when last used (0 if unassigned) */ @@ -80,6 +82,8 @@ char **argv; goto unkopt; } break; + default: + goto unkopt; } init(); if (i >= argc) @@ -306,6 +310,17 @@ uninit() /* mark end of MGF file */ } +clrverts() /* clear vertex table */ +{ + register int i; + + lu_done(&vertab); + for (i = 0; i < NVERTS; i++) + vert[i].lused = 0; + lu_init(&vertab, NVERTS); +} + + add2dispatch(name, func) /* add function to dispatch table */ char *name; int (*func)(); @@ -332,7 +347,7 @@ FVECT vp; register LUENT *lp; register int i, vndx; - clock++; /* increment counter */ + vclock++; /* increment counter */ mkvkey(vkey, vp); if ((lp = lu_find(&vertab, vkey)) == NULL) goto memerr; @@ -358,7 +373,7 @@ FVECT vp; lp->data = (char *)&vert[vndx]; /* set it */ } else vndx = (struct vert *)lp->data - vert; - vert[vndx].lused = clock; /* record this use */ + vert[vndx].lused = vclock; /* record this use */ sprintf(vname, "v%d", vndx); return(vname); memerr: @@ -511,6 +526,7 @@ FUNARGS *fa; fputs(fa->sarg[i], stdout); } putchar('\n'); + clrverts(); /* vertex id's no longer reliable */ return(0); } @@ -714,6 +730,6 @@ register FUNARGS *fa; puts("\tc"); if (d > FTINY) printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d); - printf("\ted %.4g\n", cxyz[1]*WHTEFFICACY); + printf("\ted %.4g\n", cxyz[1]*(PI*WHTEFFICACY)); return(0); }