25 |
|
#define S_ALL 3 /* select all */ |
26 |
|
|
27 |
|
/* rtrace command and defaults */ |
28 |
< |
char *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-ab", "2", |
29 |
< |
"-ad", "256", "-as", "128", "-aa", ".15" }; |
30 |
< |
int rtargc = 13; |
28 |
> |
char *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-di+", |
29 |
> |
"-ab", "2", "-ad", "256", "-as", "128", "-aa", ".15", }; |
30 |
> |
int rtargc = 14; |
31 |
|
/* overriding rtrace options */ |
32 |
< |
char *myrtopts[] = { "-I-", "-i-", "-di+", "-ov", "-h-", "-fff", NULL }; |
32 |
> |
char *myrtopts[] = { "-I-", "-i-", "-ov", "-h-", "-fff", NULL }; |
33 |
|
|
34 |
|
struct rtproc rt; /* our rtrace process */ |
35 |
|
|
103 |
|
init(); |
104 |
|
if (gargc+1 < argc) |
105 |
|
for (i = gargc+1; i < argc; i++) { |
106 |
< |
if ((fp = fopen(argv[i], "r")) == NULL { |
106 |
> |
if ((fp = fopen(argv[i], "r")) == NULL) { |
107 |
|
sprintf(errmsg, |
108 |
|
"cannot open scene file \"%s\"", argv[i]); |
109 |
|
error(SYSTEM, errmsg); |
135 |
|
|
136 |
|
init() /* start rtrace and set up buffers */ |
137 |
|
{ |
138 |
< |
extern int o_face(), o_ring(); |
138 |
> |
extern int o_face(), o_sphere(), o_ring(); |
139 |
|
int maxbytes; |
140 |
|
/* set up object functions */ |
141 |
|
ofun[OBJ_FACE].funp = o_face; |
142 |
+ |
ofun[OBJ_SPHERE].funp = o_sphere; |
143 |
|
ofun[OBJ_RING].funp = o_ring; |
144 |
|
/* set up signal handling */ |
145 |
|
signal(SIGPIPE, quit); |
153 |
|
if (maxbytes < 0) |
154 |
|
error(SYSTEM, "cannot start rtrace process"); |
155 |
|
rt.bsiz = maxbytes/(6*sizeof(float)); |
156 |
< |
rt.buf = (float *)malloc(rt.bsiz*(6*sizeof(float))); |
157 |
< |
if (rt.buf == NULL) |
156 |
> |
rt.buf = (float *)malloc(6*sizeof(float)*rt.bsiz--); |
157 |
> |
rt.dest = (float **)malloc(sizeof(float *)*rt.bsiz); |
158 |
> |
if (rt.buf == NULL || rt.dest == NULL) |
159 |
|
error(SYSTEM, "out of memory in init"); |
158 |
– |
rt.bsiz--; /* allow for flush ray */ |
160 |
|
rt.nrays = 0; |
161 |
|
} |
162 |
|
|
286 |
|
thisillum.flags &= ~IL_COLDST; |
287 |
|
break; |
288 |
|
case 'd': /* distribution */ |
289 |
< |
thisillum.flags |= IL_COLDST; |
289 |
< |
thisillum.flags &= ~IL_COLAVG; |
289 |
> |
thisillum.flags |= (IL_COLDST|IL_COLAVG); |
290 |
|
break; |
291 |
|
case 'n': /* none */ |
292 |
|
thisillum.flags &= ~(IL_COLAVG|IL_COLDST); |
313 |
|
cp = sskip(cp); |
314 |
|
continue; |
315 |
|
case 'l': /* light sources */ |
316 |
< |
if (*++cp != '+' && *cp != '-') |
317 |
< |
break; |
318 |
< |
if (*cp++ == '+') |
316 |
> |
cp++; |
317 |
> |
if (*cp == '+') |
318 |
|
thisillum.flags |= IL_LIGHT; |
319 |
< |
else |
319 |
> |
else if (*cp == '-') |
320 |
|
thisillum.flags &= ~IL_LIGHT; |
321 |
+ |
else |
322 |
+ |
break; |
323 |
+ |
cp++; |
324 |
|
continue; |
325 |
|
case 'o': /* output file */ |
326 |
|
if (*++cp != '=') |
353 |
|
progname, nerrs); |
354 |
|
} |
355 |
|
/* print pure comment */ |
356 |
< |
putchar('#'); putchar(' '); fputs(s+2, stdout); |
356 |
> |
printf("# %s", s+2); |
357 |
|
} |
358 |
|
|
359 |
|
|
389 |
|
printf("\n%s %s %s", thisillum.altmat, ALIASID, str); |
390 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
391 |
|
goto readerr; |
392 |
< |
printf(" %s\n", str); |
392 |
> |
printf("\t%s\n", str); |
393 |
|
return; |
394 |
|
} |
395 |
< |
thisobj.omod = OVOID; |
395 |
> |
thisobj.omod = OVOID; /* unused field */ |
396 |
|
if ((thisobj.otype = otype(str)) < 0) { |
397 |
|
sprintf(errmsg, "(%s): unknown type \"%s\"", nm, str); |
398 |
|
error(USER, errmsg); |
409 |
|
doit = 0; |
410 |
|
break; |
411 |
|
case S_ALL: |
412 |
< |
doit = issurface(thisobj.otype); |
412 |
> |
doit = 1; |
413 |
|
break; |
414 |
|
case S_ELEM: |
415 |
|
doit = !strcmp(thisillum.altmat, matcheck); |
418 |
|
doit = strcmp(thisillum.altmat, matcheck); |
419 |
|
break; |
420 |
|
} |
421 |
< |
if (doit && ofun[thisobj.otype].funp == o_default) { |
420 |
< |
sprintf(errmsg, "(%s): cannot make illum for %s \"%s\"", |
421 |
< |
nm, ofun[thisobj.otype].funame, thisobj.oname); |
422 |
< |
error(WARNING, errmsg); |
423 |
< |
doit = 0; |
424 |
< |
} |
421 |
> |
doit = doit && issurface(thisobj.otype); |
422 |
|
/* print header? */ |
423 |
|
checkhead(); |
424 |
|
/* process object */ |
425 |
|
if (doit) |
426 |
< |
(*ofun[thisobj.otype].funp)(&thisobj, &thisillum, &rt); |
426 |
> |
(*ofun[thisobj.otype].funp)(&thisobj, &thisillum, &rt, nm); |
427 |
|
else |
428 |
|
printobj(thisillum.altmat, &thisobj); |
429 |
|
/* free arguments */ |
433 |
|
sprintf(errmsg, "(%s): error reading scene", nm); |
434 |
|
error(USER, errmsg); |
435 |
|
} |
439 |
– |
|
440 |
– |
|
441 |
– |
int |
442 |
– |
otype(ofname) /* get object function number from its name */ |
443 |
– |
char *ofname; |
444 |
– |
{ |
445 |
– |
register int i; |
446 |
– |
|
447 |
– |
for (i = 0; i < NUMOTYPE; i++) |
448 |
– |
if (!strcmp(ofun[i].funame, ofname)) |
449 |
– |
return(i); |
450 |
– |
|
451 |
– |
return(-1); /* not found */ |
452 |
– |
} |
453 |
– |
|
454 |
– |
|
455 |
– |
o_default() {} |