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 |
|
|
58 |
|
int warnings = 1; /* print warnings? */ |
59 |
|
|
60 |
|
extern char *fgetline(), *fgetword(), *sskip(), |
61 |
< |
*atos(), *iskip(), *fskip(); |
61 |
> |
*atos(), *iskip(), *fskip(), *strcpy(); |
62 |
|
extern FILE *popen(); |
63 |
|
|
64 |
|
|
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 |
+ |
/* set up urand */ |
162 |
+ |
initurand(2048); |
163 |
|
} |
164 |
|
|
165 |
|
|
255 |
|
if (*++cp != '=') |
256 |
|
break; |
257 |
|
if (!*++cp) { |
258 |
+ |
strcpy(thisillum.datafile,thisillum.matname); |
259 |
|
thisillum.flags &= ~IL_DATCLB; |
260 |
|
continue; |
261 |
|
} |
266 |
|
continue; |
267 |
|
case 'i': /* include material */ |
268 |
|
case 'e': /* exclude material */ |
269 |
< |
matselect = (*cp == 'i') ? S_ELEM : S_COMPL; |
266 |
< |
if (*++cp != '=') |
269 |
> |
if (cp[1] != '=') |
270 |
|
break; |
271 |
< |
atos(matcheck, MAXSTR, ++cp); |
271 |
> |
matselect = (*cp == 'i') ? S_ELEM : S_COMPL; |
272 |
> |
cp += 2; |
273 |
> |
atos(matcheck, MAXSTR, cp); |
274 |
|
cp = sskip(cp); |
275 |
|
continue; |
276 |
|
case 'a': /* use everything */ |
286 |
|
break; |
287 |
|
switch (*++cp) { |
288 |
|
case 'a': /* average */ |
289 |
< |
thisillum.flags |= IL_COLAVG; |
290 |
< |
thisillum.flags &= ~IL_COLDST; |
289 |
> |
thisillum.flags = (thisillum.flags|IL_COLAVG) |
290 |
> |
& ~IL_COLDST; |
291 |
|
break; |
292 |
|
case 'd': /* distribution */ |
293 |
< |
thisillum.flags |= IL_COLDST; |
289 |
< |
thisillum.flags &= ~IL_COLAVG; |
293 |
> |
thisillum.flags |= (IL_COLDST|IL_COLAVG); |
294 |
|
break; |
295 |
|
case 'n': /* none */ |
296 |
|
thisillum.flags &= ~(IL_COLAVG|IL_COLDST); |
317 |
|
cp = sskip(cp); |
318 |
|
continue; |
319 |
|
case 'l': /* light sources */ |
320 |
< |
if (*++cp != '+' && *cp != '-') |
321 |
< |
break; |
318 |
< |
if (*cp++ == '+') |
320 |
> |
cp++; |
321 |
> |
if (*cp == '+') |
322 |
|
thisillum.flags |= IL_LIGHT; |
323 |
< |
else |
323 |
> |
else if (*cp == '-') |
324 |
|
thisillum.flags &= ~IL_LIGHT; |
325 |
+ |
else |
326 |
+ |
break; |
327 |
+ |
cp++; |
328 |
|
continue; |
329 |
|
case 'o': /* output file */ |
330 |
|
if (*++cp != '=') |
340 |
|
} |
341 |
|
doneheader = 0; |
342 |
|
continue; |
343 |
+ |
case '!': /* processed file! */ |
344 |
+ |
sprintf(errmsg, "(%s): already processed!", nm); |
345 |
+ |
error(WARNING, errmsg); |
346 |
+ |
matselect = S_NONE; |
347 |
+ |
return; |
348 |
|
} |
349 |
|
opterr: /* skip faulty option */ |
350 |
|
cp = sskip(cp); |
362 |
|
progname, nerrs); |
363 |
|
} |
364 |
|
/* print pure comment */ |
365 |
< |
putchar('#'); putchar(' '); fputs(s+2, stdout); |
365 |
> |
printf("# %s", s+2); |
366 |
|
} |
367 |
|
|
368 |
|
|
375 |
|
putchar(' '); |
376 |
|
fputs(*av++, stdout); |
377 |
|
} |
378 |
< |
putchar('\n'); |
378 |
> |
fputs("\n#@mkillum !\n", stdout); |
379 |
|
} |
380 |
|
|
381 |
|
|
398 |
|
printf("\n%s %s %s", thisillum.altmat, ALIASID, str); |
399 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
400 |
|
goto readerr; |
401 |
< |
printf(" %s\n", str); |
401 |
> |
printf("\t%s\n", str); |
402 |
|
return; |
403 |
|
} |
404 |
< |
thisobj.omod = OVOID; |
404 |
> |
thisobj.omod = OVOID; /* unused field */ |
405 |
|
if ((thisobj.otype = otype(str)) < 0) { |
406 |
|
sprintf(errmsg, "(%s): unknown type \"%s\"", nm, str); |
407 |
|
error(USER, errmsg); |
418 |
|
doit = 0; |
419 |
|
break; |
420 |
|
case S_ALL: |
421 |
< |
doit = issurface(thisobj.otype); |
421 |
> |
doit = 1; |
422 |
|
break; |
423 |
|
case S_ELEM: |
424 |
|
doit = !strcmp(thisillum.altmat, matcheck); |
427 |
|
doit = strcmp(thisillum.altmat, matcheck); |
428 |
|
break; |
429 |
|
} |
430 |
< |
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 |
< |
} |
430 |
> |
doit = doit && issurface(thisobj.otype); |
431 |
|
/* print header? */ |
432 |
|
checkhead(); |
433 |
|
/* process object */ |
434 |
|
if (doit) |
435 |
< |
(*ofun[thisobj.otype].funp)(&thisobj, &thisillum, &rt); |
435 |
> |
(*ofun[thisobj.otype].funp)(&thisobj, &thisillum, &rt, nm); |
436 |
|
else |
437 |
|
printobj(thisillum.altmat, &thisobj); |
438 |
|
/* free arguments */ |
442 |
|
sprintf(errmsg, "(%s): error reading scene", nm); |
443 |
|
error(USER, errmsg); |
444 |
|
} |
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() {} |