| 15 |
|
#include "color.h" |
| 16 |
|
#include "lookup.h" |
| 17 |
|
|
| 18 |
+ |
#define PI 3.14159265358979323846 |
| 19 |
+ |
|
| 20 |
|
int o_face(), o_cone(), o_sphere(), o_ring(), o_cylinder(); |
| 21 |
|
int o_instance(), o_source(), o_illum(); |
| 22 |
|
int o_plastic(), o_metal(), o_glass(), o_mirror(), o_trans(), o_light(); |
| 35 |
|
|
| 36 |
|
#define hasmult (unit_mult < .999 || unit_mult > 1.001) |
| 37 |
|
|
| 38 |
+ |
/* |
| 39 |
+ |
* Stuff for tracking and reusing vertices: |
| 40 |
+ |
*/ |
| 41 |
|
|
| 42 |
+ |
char VKFMT[] = "%+1.9e %+1.9e %+1.9e"; |
| 43 |
+ |
#define VKLEN 64 |
| 44 |
+ |
|
| 45 |
+ |
#define mkvkey(k,v) sprintf(k, VKFMT, (v)[0], (v)[1], (v)[2]) |
| 46 |
+ |
|
| 47 |
+ |
#define NVERTS 256 |
| 48 |
+ |
|
| 49 |
+ |
long clock; /* incremented at each vertex request */ |
| 50 |
+ |
|
| 51 |
+ |
struct vert { |
| 52 |
+ |
long lused; /* when last used (0 if unassigned) */ |
| 53 |
+ |
FVECT p; /* track point position only */ |
| 54 |
+ |
} vert[NVERTS]; /* our vertex cache */ |
| 55 |
+ |
|
| 56 |
+ |
LUTAB vertab = LU_SINIT(free,NULL); /* our vertex lookup table */ |
| 57 |
+ |
|
| 58 |
+ |
|
| 59 |
|
main(argc, argv) |
| 60 |
|
int argc; |
| 61 |
|
char **argv; |
| 82 |
|
goto unkopt; |
| 83 |
|
} |
| 84 |
|
break; |
| 85 |
+ |
default: |
| 86 |
+ |
goto unkopt; |
| 87 |
|
} |
| 88 |
|
init(); |
| 89 |
|
if (i >= argc) |
| 268 |
|
|
| 269 |
|
init() /* initialize dispatch table and output */ |
| 270 |
|
{ |
| 271 |
+ |
lu_init(&vertab, NVERTS); |
| 272 |
|
lu_init(&rdispatch, 22); |
| 273 |
|
add2dispatch("polygon", o_face); |
| 274 |
|
add2dispatch("cone", o_cone); |
| 306 |
|
puts("# End of data converted from Radiance scene input"); |
| 307 |
|
lu_done(&rdispatch); |
| 308 |
|
lu_done(&rmats); |
| 309 |
+ |
lu_done(&vertab); |
| 310 |
|
} |
| 311 |
|
|
| 312 |
|
|
| 313 |
+ |
clrverts() /* clear vertex table */ |
| 314 |
+ |
{ |
| 315 |
+ |
register int i; |
| 316 |
+ |
|
| 317 |
+ |
lu_done(&vertab); |
| 318 |
+ |
for (i = 0; i < NVERTS; i++) |
| 319 |
+ |
vert[i].lused = 0; |
| 320 |
+ |
lu_init(&vertab, NVERTS); |
| 321 |
+ |
} |
| 322 |
+ |
|
| 323 |
+ |
|
| 324 |
|
add2dispatch(name, func) /* add function to dispatch table */ |
| 325 |
|
char *name; |
| 326 |
|
int (*func)(); |
| 338 |
|
} |
| 339 |
|
|
| 340 |
|
|
| 304 |
– |
/* |
| 305 |
– |
* Stuff for tracking and reusing vertices: |
| 306 |
– |
*/ |
| 307 |
– |
|
| 308 |
– |
char VKFMT[] = "%+1.9e %+1.9e %+1.9e"; |
| 309 |
– |
#define VKLEN 64 |
| 310 |
– |
|
| 311 |
– |
#define mkvkey(k,v) sprintf(k, VKFMT, (v)[0], (v)[1], (v)[2]) |
| 312 |
– |
|
| 313 |
– |
#define NVERTS 256 |
| 314 |
– |
|
| 315 |
– |
long clock; /* incremented at each vertex request */ |
| 316 |
– |
|
| 317 |
– |
struct vert { |
| 318 |
– |
long lused; /* when last used (0 if unassigned) */ |
| 319 |
– |
FVECT p; /* track point position only */ |
| 320 |
– |
} vert[NVERTS]; |
| 321 |
– |
|
| 322 |
– |
LUTAB vertab = LU_SINIT(free,NULL); /* our vertex lookup table */ |
| 323 |
– |
|
| 324 |
– |
|
| 341 |
|
char * |
| 342 |
|
getvertid(vname, vp) /* get/set vertex ID for this point */ |
| 343 |
|
char *vname; |
| 347 |
|
register LUENT *lp; |
| 348 |
|
register int i, vndx; |
| 349 |
|
|
| 334 |
– |
if (!vertab.tsiz && !lu_init(&vertab, NVERTS)) |
| 335 |
– |
goto memerr; |
| 350 |
|
clock++; /* increment counter */ |
| 351 |
|
mkvkey(vkey, vp); |
| 352 |
|
if ((lp = lu_find(&vertab, vkey)) == NULL) |
| 526 |
|
fputs(fa->sarg[i], stdout); |
| 527 |
|
} |
| 528 |
|
putchar('\n'); |
| 529 |
+ |
clrverts(); /* vertex id's no longer reliable */ |
| 530 |
|
return(0); |
| 531 |
|
} |
| 532 |
|
|
| 730 |
|
puts("\tc"); |
| 731 |
|
if (d > FTINY) |
| 732 |
|
printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d); |
| 733 |
< |
printf("\ted %.4g\n", cxyz[1]*WHTEFFICACY); |
| 733 |
> |
printf("\ted %.4g\n", cxyz[1]*(PI*WHTEFFICACY)); |
| 734 |
|
return(0); |
| 735 |
|
} |