1 |
– |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Make illum sources for optimizing rendering process |
6 |
|
*/ |
7 |
|
|
8 |
< |
#include "mkillum.h" |
12 |
< |
|
8 |
> |
#include <signal.h> |
9 |
|
#include <ctype.h> |
10 |
|
|
11 |
+ |
#include "mkillum.h" |
12 |
+ |
|
13 |
|
/* default parameters */ |
14 |
< |
#define SAMPDENS 128 /* points per projected steradian */ |
14 |
> |
#define SAMPDENS 48 /* points per projected steradian */ |
15 |
|
#define NSAMPS 32 /* samples per point */ |
16 |
|
#define DFLMAT "illum_mat" /* material name */ |
17 |
+ |
#define DFLDAT "illum" /* data file name */ |
18 |
|
/* selection options */ |
19 |
|
#define S_NONE 0 /* select none */ |
20 |
|
#define S_ELEM 1 /* select specified element */ |
21 |
|
#define S_COMPL 2 /* select all but element */ |
22 |
|
#define S_ALL 3 /* select all */ |
23 |
|
|
25 |
– |
/* rtrace command and defaults */ |
26 |
– |
char *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-ab", "2", |
27 |
– |
"-ad", "256", "-as", "128", "-aa", ".15" }; |
28 |
– |
int rtargc = 13; |
29 |
– |
/* overriding rtrace options */ |
30 |
– |
char *myrtopts[] = { "-I-", "-i-", "-di+", "-ov", "-h-", "-fff", NULL }; |
31 |
– |
|
32 |
– |
struct rtproc rt; /* our rtrace process */ |
33 |
– |
|
24 |
|
struct illum_args thisillum = { /* our illum and default values */ |
25 |
|
0, |
26 |
+ |
UDzpos, |
27 |
+ |
0., |
28 |
|
DFLMAT, |
29 |
< |
DFLMAT, |
29 |
> |
DFLDAT, |
30 |
|
0, |
31 |
|
VOIDID, |
32 |
+ |
SAMPDENS, |
33 |
|
NSAMPS, |
34 |
+ |
NULL, |
35 |
+ |
0., |
36 |
|
}; |
37 |
|
|
43 |
– |
int sampdens = SAMPDENS; /* sample point density */ |
38 |
|
char matcheck[MAXSTR]; /* current material to include or exclude */ |
39 |
|
int matselect = S_ALL; /* selection criterion */ |
40 |
|
|
47 |
– |
FUN ofun[NUMOTYPE] = INIT_OTYPE; /* object types */ |
48 |
– |
|
41 |
|
int gargc; /* global argc */ |
42 |
|
char **gargv; /* global argv */ |
51 |
– |
#define progname gargv[0] |
43 |
|
|
44 |
|
int doneheader = 0; /* printed header yet? */ |
45 |
|
#define checkhead() if (!doneheader++) printhead(gargc,gargv) |
46 |
|
|
47 |
|
int warnings = 1; /* print warnings? */ |
48 |
|
|
49 |
< |
extern char *fgetline(), *fgetword(), *sskip(), |
50 |
< |
*atos(), *iskip(), *fskip(); |
51 |
< |
extern FILE *popen(); |
49 |
> |
void init(char *octnm, int np); |
50 |
> |
void filter(register FILE *infp, char *name); |
51 |
> |
void xoptions(char *s, char *nm); |
52 |
> |
void printopts(void); |
53 |
> |
void printhead(register int ac, register char **av); |
54 |
> |
void xobject(FILE *fp, char *nm); |
55 |
|
|
56 |
|
|
57 |
< |
main(argc, argv) /* compute illum distributions using rtrace */ |
58 |
< |
int argc; |
59 |
< |
char *argv[]; |
57 |
> |
int |
58 |
> |
main( /* compute illum distributions using rtrace */ |
59 |
> |
int argc, |
60 |
> |
char *argv[] |
61 |
> |
) |
62 |
|
{ |
63 |
< |
extern char *getenv(), *getpath(); |
64 |
< |
char *rtpath; |
63 |
> |
int nprocs = 1; |
64 |
> |
FILE *fp; |
65 |
> |
int rval; |
66 |
|
register int i; |
67 |
|
/* set global arguments */ |
68 |
< |
gargc = argc; gargv = argv; |
69 |
< |
/* set up rtrace command */ |
70 |
< |
if (argc < 2) |
71 |
< |
error(USER, "too few arguments"); |
72 |
< |
for (i = 1; i < argc-1; i++) { |
73 |
< |
rtargv[rtargc++] = argv[i]; |
74 |
< |
if (argv[i][0] == '-' && argv[i][1] == 'w') |
75 |
< |
warnings = !warnings; |
76 |
< |
} |
77 |
< |
for (i = 0; myrtopts[i] != NULL; i++) |
78 |
< |
rtargv[rtargc++] = myrtopts[i]; |
79 |
< |
rtargv[rtargc++] = argv[argc-1]; |
80 |
< |
rtargv[rtargc] = NULL; |
81 |
< |
/* just asking for defaults? */ |
85 |
< |
if (!strcmp(argv[argc-1], "-defaults")) { |
86 |
< |
rtpath = getpath(rtargv[0], getenv("PATH"), X_OK); |
87 |
< |
if (rtpath == NULL) { |
88 |
< |
eputs(rtargv[0]); |
89 |
< |
eputs(": command not found\n"); |
90 |
< |
exit(1); |
68 |
> |
gargv = argv; |
69 |
> |
progname = gargv[0]; |
70 |
> |
/* set up rendering defaults */ |
71 |
> |
dstrsrc = 0.25; |
72 |
> |
directrelay = 3; |
73 |
> |
directvis = 0; |
74 |
> |
ambounce = 2; |
75 |
> |
/* get options from command line */ |
76 |
> |
for (i = 1; i < argc; i++) { |
77 |
> |
while ((rval = expandarg(&argc, &argv, i)) > 0) |
78 |
> |
; |
79 |
> |
if (rval < 0) { |
80 |
> |
sprintf(errmsg, "cannot expand '%s'", argv[i]); |
81 |
> |
error(SYSTEM, errmsg); |
82 |
|
} |
83 |
< |
execv(rtpath, rtargv); |
84 |
< |
perror(rtpath); |
85 |
< |
exit(1); |
83 |
> |
if (argv[i][0] != '-') |
84 |
> |
break; |
85 |
> |
if (!strcmp(argv[i], "-w")) { |
86 |
> |
warnings = 0; |
87 |
> |
continue; |
88 |
> |
} |
89 |
> |
if (!strcmp(argv[i], "-n")) { |
90 |
> |
nprocs = atoi(argv[++i]); |
91 |
> |
if (nprocs <= 0) |
92 |
> |
error(USER, "illegal number of processes"); |
93 |
> |
continue; |
94 |
> |
} |
95 |
> |
if (!strcmp(argv[i], "-defaults")) { |
96 |
> |
printopts(); |
97 |
> |
print_rdefaults(); |
98 |
> |
quit(0); |
99 |
> |
} |
100 |
> |
rval = getrenderopt(argc-i, argv+i); |
101 |
> |
if (rval < 0) { |
102 |
> |
sprintf(errmsg, "bad render option at '%s'", argv[i]); |
103 |
> |
error(USER, errmsg); |
104 |
> |
} |
105 |
> |
i += rval; |
106 |
|
} |
107 |
+ |
gargc = ++i; |
108 |
+ |
/* add "mandatory" render options */ |
109 |
+ |
do_irrad = 0; |
110 |
+ |
if (gargc > argc || argv[gargc-1][0] == '-') |
111 |
+ |
error(USER, "missing octree argument"); |
112 |
|
/* else initialize and run our calculation */ |
113 |
< |
init(); |
114 |
< |
filter(stdin, "standard input"); |
113 |
> |
init(argv[gargc-1], nprocs); |
114 |
> |
if (gargc < argc) { |
115 |
> |
if (gargc == argc-1 || argv[gargc][0] != '<' || argv[gargc][1]) |
116 |
> |
error(USER, "use '< file1 file2 ..' for multiple inputs"); |
117 |
> |
for (i = gargc+1; i < argc; i++) { |
118 |
> |
if ((fp = fopen(argv[i], "r")) == NULL) { |
119 |
> |
sprintf(errmsg, |
120 |
> |
"cannot open scene file \"%s\"", argv[i]); |
121 |
> |
error(SYSTEM, errmsg); |
122 |
> |
} |
123 |
> |
filter(fp, argv[i]); |
124 |
> |
fclose(fp); |
125 |
> |
} |
126 |
> |
} else |
127 |
> |
filter(stdin, "standard input"); |
128 |
|
quit(0); |
129 |
+ |
return 0; /* pro forma return */ |
130 |
|
} |
131 |
|
|
132 |
|
|
133 |
< |
init() /* start rtrace and set up buffers */ |
133 |
> |
void |
134 |
> |
init(char *octnm, int np) /* start rendering process(es) */ |
135 |
|
{ |
136 |
< |
int maxbytes; |
137 |
< |
|
138 |
< |
maxbytes = open_process(rt.pd, rtargv); |
139 |
< |
if (maxbytes == 0) { |
140 |
< |
eputs(rtargv[0]); |
141 |
< |
eputs(": command not found\n"); |
142 |
< |
exit(1); |
143 |
< |
} |
144 |
< |
if (maxbytes < 0) |
145 |
< |
error(SYSTEM, "cannot start rtrace process"); |
146 |
< |
rt.bsiz = maxbytes/(6*sizeof(float)); |
147 |
< |
rt.buf = (float *)malloc(rt.bsiz*(6*sizeof(float))); |
148 |
< |
if (rt.buf == NULL) |
118 |
< |
error(SYSTEM, "out of memory in init"); |
119 |
< |
rt.bsiz--; /* allow for flush ray */ |
120 |
< |
rt.nrays = 0; |
136 |
> |
/* set up signal handling */ |
137 |
> |
signal(SIGINT, quit); |
138 |
> |
#ifdef SIGHUP |
139 |
> |
signal(SIGHUP, quit); |
140 |
> |
#endif |
141 |
> |
#ifdef SIGTERM |
142 |
> |
signal(SIGTERM, quit); |
143 |
> |
#endif |
144 |
> |
#ifdef SIGPIPE |
145 |
> |
signal(SIGPIPE, quit); |
146 |
> |
#endif |
147 |
> |
/* start rendering process(es) */ |
148 |
> |
ray_pinit(octnm, np); |
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
< |
quit(status) /* exit with status */ |
153 |
< |
int status; |
152 |
> |
void |
153 |
> |
eputs( /* put string to stderr */ |
154 |
> |
register char *s |
155 |
> |
) |
156 |
|
{ |
127 |
– |
int rtstat; |
128 |
– |
|
129 |
– |
rtstat = close_process(rt.pd); |
130 |
– |
if (status == 0) |
131 |
– |
if (rtstat < 0) |
132 |
– |
error(WARNING, |
133 |
– |
"unknown return status from rtrace process"); |
134 |
– |
else |
135 |
– |
status = rtstat; |
136 |
– |
exit(status); |
137 |
– |
} |
138 |
– |
|
139 |
– |
|
140 |
– |
eputs(s) /* put string to stderr */ |
141 |
– |
register char *s; |
142 |
– |
{ |
157 |
|
static int midline = 0; |
158 |
|
|
159 |
|
if (!*s) return; |
166 |
|
} |
167 |
|
|
168 |
|
|
169 |
+ |
void |
170 |
|
wputs(s) /* print warning if enabled */ |
171 |
|
char *s; |
172 |
|
{ |
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
< |
filter(infp, name) /* process stream */ |
179 |
< |
register FILE *infp; |
180 |
< |
char *name; |
178 |
> |
void |
179 |
> |
filter( /* process stream */ |
180 |
> |
register FILE *infp, |
181 |
> |
char *name |
182 |
> |
) |
183 |
|
{ |
184 |
|
char buf[512]; |
185 |
|
FILE *pfp; |
209 |
|
} |
210 |
|
|
211 |
|
|
212 |
< |
xoptions(s, nm) /* process options in string s */ |
213 |
< |
char *s; |
214 |
< |
char *nm; |
212 |
> |
void |
213 |
> |
xoptions( /* process options in string s */ |
214 |
> |
char *s, |
215 |
> |
char *nm |
216 |
> |
) |
217 |
|
{ |
218 |
|
extern FILE *freopen(); |
219 |
|
char buf[64]; |
220 |
+ |
int negax; |
221 |
|
int nerrs = 0; |
222 |
|
register char *cp; |
223 |
|
|
231 |
|
case ' ': |
232 |
|
case '\t': |
233 |
|
case '\n': |
234 |
+ |
case '\r': |
235 |
+ |
case '\f': |
236 |
|
cp++; |
237 |
|
continue; |
238 |
|
case 'm': /* material name */ |
239 |
|
if (*++cp != '=') |
240 |
|
break; |
241 |
< |
if (!*++cp) |
241 |
> |
if (!*++cp || isspace(*cp)) |
242 |
|
break; |
243 |
|
atos(thisillum.matname, MAXSTR, cp); |
244 |
|
cp = sskip(cp); |
250 |
|
case 'f': /* data file name */ |
251 |
|
if (*++cp != '=') |
252 |
|
break; |
253 |
< |
if (!*++cp) { |
253 |
> |
if (!*++cp || isspace(*cp)) { |
254 |
> |
strcpy(thisillum.datafile,thisillum.matname); |
255 |
> |
thisillum.dfnum = 0; |
256 |
|
thisillum.flags &= ~IL_DATCLB; |
257 |
|
continue; |
258 |
|
} |
263 |
|
continue; |
264 |
|
case 'i': /* include material */ |
265 |
|
case 'e': /* exclude material */ |
266 |
< |
matselect = (*cp == 'i') ? S_ELEM : S_COMPL; |
243 |
< |
if (*++cp != '=') |
266 |
> |
if (cp[1] != '=') |
267 |
|
break; |
268 |
< |
atos(matcheck, MAXSTR, ++cp); |
268 |
> |
matselect = (*cp == 'i') ? S_ELEM : S_COMPL; |
269 |
> |
cp += 2; |
270 |
> |
atos(matcheck, MAXSTR, cp); |
271 |
|
cp = sskip(cp); |
272 |
|
continue; |
273 |
|
case 'a': /* use everything */ |
283 |
|
break; |
284 |
|
switch (*++cp) { |
285 |
|
case 'a': /* average */ |
286 |
< |
thisillum.flags |= IL_COLAVG; |
287 |
< |
thisillum.flags &= ~IL_COLDST; |
286 |
> |
thisillum.flags = (thisillum.flags|IL_COLAVG) |
287 |
> |
& ~IL_COLDST; |
288 |
|
break; |
289 |
|
case 'd': /* distribution */ |
290 |
< |
thisillum.flags |= IL_COLDST; |
266 |
< |
thisillum.flags &= ~IL_COLAVG; |
290 |
> |
thisillum.flags |= (IL_COLDST|IL_COLAVG); |
291 |
|
break; |
292 |
|
case 'n': /* none */ |
293 |
|
thisillum.flags &= ~(IL_COLAVG|IL_COLDST); |
297 |
|
} |
298 |
|
cp = sskip(cp); |
299 |
|
continue; |
300 |
< |
case 'd': /* point sample density */ |
300 |
> |
case 'd': /* sample density / BSDF data */ |
301 |
|
if (*++cp != '=') |
302 |
|
break; |
303 |
< |
if (!isintd(++cp, " \t\n")) |
304 |
< |
break; |
305 |
< |
sampdens = atoi(cp); |
303 |
> |
if (thisillum.sd != NULL) { |
304 |
> |
free_BSDF(thisillum.sd); |
305 |
> |
thisillum.sd = NULL; |
306 |
> |
} |
307 |
> |
if (!*++cp || isspace(*cp)) |
308 |
> |
continue; |
309 |
> |
if (isintd(++cp, " \t\n\r")) { |
310 |
> |
thisillum.sampdens = atoi(cp); |
311 |
> |
} else { |
312 |
> |
atos(buf, sizeof(buf), cp); |
313 |
> |
thisillum.sd = load_BSDF(buf); |
314 |
> |
if (thisillum.sd == NULL) |
315 |
> |
break; |
316 |
> |
} |
317 |
|
cp = sskip(cp); |
318 |
|
continue; |
319 |
< |
case 's': /* point super-samples */ |
319 |
> |
case 's': /* surface super-samples */ |
320 |
|
if (*++cp != '=') |
321 |
|
break; |
322 |
< |
if (!isintd(++cp, " \t\n")) |
322 |
> |
if (!isintd(++cp, " \t\n\r")) |
323 |
|
break; |
324 |
|
thisillum.nsamps = atoi(cp); |
325 |
|
cp = sskip(cp); |
326 |
|
continue; |
327 |
+ |
case 'l': /* light sources */ |
328 |
+ |
cp++; |
329 |
+ |
if (*cp == '+') |
330 |
+ |
thisillum.flags |= IL_LIGHT; |
331 |
+ |
else if (*cp == '-') |
332 |
+ |
thisillum.flags &= ~IL_LIGHT; |
333 |
+ |
else |
334 |
+ |
break; |
335 |
+ |
cp++; |
336 |
+ |
continue; |
337 |
+ |
case 'b': /* brightness */ |
338 |
+ |
if (*++cp != '=') |
339 |
+ |
break; |
340 |
+ |
if (!isfltd(++cp, " \t\n\r")) |
341 |
+ |
break; |
342 |
+ |
thisillum.minbrt = atof(cp); |
343 |
+ |
if (thisillum.minbrt < 0.) |
344 |
+ |
thisillum.minbrt = 0.; |
345 |
+ |
cp = sskip(cp); |
346 |
+ |
continue; |
347 |
|
case 'o': /* output file */ |
348 |
|
if (*++cp != '=') |
349 |
|
break; |
350 |
< |
if (!*++cp) |
350 |
> |
if (!*++cp || isspace(*cp)) |
351 |
|
break; |
352 |
|
atos(buf, sizeof(buf), cp); |
353 |
|
cp = sskip(cp); |
358 |
|
} |
359 |
|
doneheader = 0; |
360 |
|
continue; |
361 |
+ |
case 'u': /* up direction */ |
362 |
+ |
if (*++cp != '=') |
363 |
+ |
break; |
364 |
+ |
if (!*++cp || isspace(*cp)) { |
365 |
+ |
thisillum.udir = UDunknown; |
366 |
+ |
continue; |
367 |
+ |
} |
368 |
+ |
negax = 0; |
369 |
+ |
if (*cp == '+') |
370 |
+ |
cp++; |
371 |
+ |
else if (*cp == '-') { |
372 |
+ |
negax++; |
373 |
+ |
cp++; |
374 |
+ |
} |
375 |
+ |
switch (*cp++) { |
376 |
+ |
case 'x': |
377 |
+ |
case 'X': |
378 |
+ |
thisillum.udir = negax ? UDxneg : UDxpos; |
379 |
+ |
break; |
380 |
+ |
case 'y': |
381 |
+ |
case 'Y': |
382 |
+ |
thisillum.udir = negax ? UDyneg : UDypos; |
383 |
+ |
break; |
384 |
+ |
case 'z': |
385 |
+ |
case 'Z': |
386 |
+ |
thisillum.udir = negax ? UDxneg : UDxpos; |
387 |
+ |
break; |
388 |
+ |
default: |
389 |
+ |
thisillum.udir = UDunknown; |
390 |
+ |
break; |
391 |
+ |
} |
392 |
+ |
if (thisillum.udir == UDunknown || !isspace(*cp)) |
393 |
+ |
break; |
394 |
+ |
continue; |
395 |
+ |
case 't': /* object thickness */ |
396 |
+ |
if (*++cp != '=') |
397 |
+ |
break; |
398 |
+ |
if (!isfltd(++cp, " \t\n\r")) |
399 |
+ |
break; |
400 |
+ |
thisillum.thick = atof(cp); |
401 |
+ |
if (thisillum.thick < .0) |
402 |
+ |
thisillum.thick = .0; |
403 |
+ |
cp = sskip(cp); |
404 |
+ |
continue; |
405 |
+ |
case '!': /* processed file! */ |
406 |
+ |
sprintf(errmsg, "(%s): already processed!", nm); |
407 |
+ |
error(WARNING, errmsg); |
408 |
+ |
matselect = S_NONE; |
409 |
+ |
return; |
410 |
|
} |
411 |
|
opterr: /* skip faulty option */ |
412 |
< |
cp = sskip(cp); |
412 |
> |
while (*cp && !isspace(*cp)) |
413 |
> |
cp++; |
414 |
|
nerrs++; |
415 |
|
} |
416 |
|
/* print header? */ |
425 |
|
progname, nerrs); |
426 |
|
} |
427 |
|
/* print pure comment */ |
428 |
< |
putchar('#'); putchar(' '); fputs(s+2, stdout); |
428 |
> |
printf("# %s", s+2); |
429 |
|
} |
430 |
|
|
431 |
+ |
void |
432 |
+ |
printopts(void) /* print out option default values */ |
433 |
+ |
{ |
434 |
+ |
printf("m=%-15s\t\t# material name\n", thisillum.matname); |
435 |
+ |
printf("f=%-15s\t\t# data file name\n", thisillum.datafile); |
436 |
+ |
if (thisillum.flags & IL_COLAVG) |
437 |
+ |
if (thisillum.flags & IL_COLDST) |
438 |
+ |
printf("c=d\t\t\t\t# color distribution\n"); |
439 |
+ |
else |
440 |
+ |
printf("c=a\t\t\t\t# color average\n"); |
441 |
+ |
else |
442 |
+ |
printf("c=n\t\t\t\t# color none\n"); |
443 |
+ |
if (thisillum.flags & IL_LIGHT) |
444 |
+ |
printf("l+\t\t\t\t# light type on\n"); |
445 |
+ |
else |
446 |
+ |
printf("l-\t\t\t\t# light type off\n"); |
447 |
+ |
printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens); |
448 |
+ |
printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps); |
449 |
+ |
printf("b=%f\t\t\t# minimum average brightness\n", thisillum.minbrt); |
450 |
+ |
switch (thisillum.udir) { |
451 |
+ |
case UDzneg: |
452 |
+ |
fputs("u=-Z\t\t\t\t# up is negative Z\n", stdout); |
453 |
+ |
break; |
454 |
+ |
case UDyneg: |
455 |
+ |
fputs("u=-Y\t\t\t\t# up is negative Y\n", stdout); |
456 |
+ |
break; |
457 |
+ |
case UDxneg: |
458 |
+ |
fputs("u=-X\t\t\t\t# up is negative X\n", stdout); |
459 |
+ |
break; |
460 |
+ |
case UDxpos: |
461 |
+ |
fputs("u=+X\t\t\t\t# up is positive X\n", stdout); |
462 |
+ |
break; |
463 |
+ |
case UDypos: |
464 |
+ |
fputs("u=+Y\t\t\t\t# up is positive Y\n", stdout); |
465 |
+ |
break; |
466 |
+ |
case UDzpos: |
467 |
+ |
fputs("u=+Z\t\t\t\t# up is positive Z\n", stdout); |
468 |
+ |
break; |
469 |
+ |
case UDunknown: |
470 |
+ |
break; |
471 |
+ |
} |
472 |
+ |
printf("t=%f\t\t\t# object thickness\n", thisillum.thick); |
473 |
+ |
} |
474 |
|
|
475 |
< |
printhead(ac, av) /* print out header */ |
476 |
< |
register int ac; |
477 |
< |
register char **av; |
475 |
> |
|
476 |
> |
void |
477 |
> |
printhead( /* print out header */ |
478 |
> |
register int ac, |
479 |
> |
register char **av |
480 |
> |
) |
481 |
|
{ |
482 |
|
putchar('#'); |
483 |
|
while (ac-- > 0) { |
484 |
|
putchar(' '); |
485 |
|
fputs(*av++, stdout); |
486 |
|
} |
487 |
< |
putchar('\n'); |
487 |
> |
fputs("\n#@mkillum !\n", stdout); |
488 |
|
} |
489 |
|
|
490 |
|
|
491 |
< |
xobject(fp, nm) /* translate an object from fp */ |
492 |
< |
FILE *fp; |
493 |
< |
char *nm; |
491 |
> |
void |
492 |
> |
xobject( /* translate an object from fp */ |
493 |
> |
FILE *fp, |
494 |
> |
char *nm |
495 |
> |
) |
496 |
|
{ |
497 |
|
OBJREC thisobj; |
498 |
|
char str[MAXSTR]; |
503 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
504 |
|
goto readerr; |
505 |
|
/* is it an alias? */ |
506 |
< |
if (!strcmp(str, ALIASID)) { |
506 |
> |
if (!strcmp(str, ALIASKEY)) { |
507 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
508 |
|
goto readerr; |
509 |
< |
printf("\n%s %s %s", thisillum.altmat, ALIASID, str); |
509 |
> |
printf("\n%s %s %s", thisillum.altmat, ALIASKEY, str); |
510 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
511 |
|
goto readerr; |
512 |
< |
printf(" %s\n", str); |
512 |
> |
printf("\t%s\n", str); |
513 |
|
return; |
514 |
|
} |
515 |
< |
thisobj.omod = OVOID; |
515 |
> |
thisobj.omod = OVOID; /* unused field */ |
516 |
|
if ((thisobj.otype = otype(str)) < 0) { |
517 |
|
sprintf(errmsg, "(%s): unknown type \"%s\"", nm, str); |
518 |
|
error(USER, errmsg); |
529 |
|
doit = 0; |
530 |
|
break; |
531 |
|
case S_ALL: |
532 |
< |
doit = issurface(thisobj.otype); |
532 |
> |
doit = 1; |
533 |
|
break; |
534 |
|
case S_ELEM: |
535 |
|
doit = !strcmp(thisillum.altmat, matcheck); |
538 |
|
doit = strcmp(thisillum.altmat, matcheck); |
539 |
|
break; |
540 |
|
} |
541 |
< |
if (doit) /* make sure we can do it */ |
541 |
> |
doit = doit && issurface(thisobj.otype); |
542 |
> |
/* print header? */ |
543 |
> |
checkhead(); |
544 |
> |
/* process object */ |
545 |
> |
if (doit) |
546 |
|
switch (thisobj.otype) { |
390 |
– |
case OBJ_SPHERE: |
547 |
|
case OBJ_FACE: |
548 |
+ |
my_face(&thisobj, &thisillum, nm); |
549 |
+ |
break; |
550 |
+ |
case OBJ_SPHERE: |
551 |
+ |
my_sphere(&thisobj, &thisillum, nm); |
552 |
+ |
break; |
553 |
|
case OBJ_RING: |
554 |
+ |
my_ring(&thisobj, &thisillum, nm); |
555 |
|
break; |
556 |
|
default: |
557 |
< |
sprintf(errmsg, |
396 |
< |
"(%s): cannot make illum for %s \"%s\"", |
397 |
< |
nm, ofun[thisobj.otype].funame, |
398 |
< |
thisobj.oname); |
399 |
< |
error(WARNING, errmsg); |
400 |
< |
doit = 0; |
557 |
> |
my_default(&thisobj, &thisillum, nm); |
558 |
|
break; |
559 |
|
} |
403 |
– |
/* print header? */ |
404 |
– |
checkhead(); |
405 |
– |
/* process object */ |
406 |
– |
if (doit) |
407 |
– |
mkillum(&thisobj, &thisillum, &rt); |
560 |
|
else |
561 |
|
printobj(thisillum.altmat, &thisobj); |
562 |
|
/* free arguments */ |
563 |
|
freefargs(&thisobj.oargs); |
564 |
|
return; |
565 |
|
readerr: |
566 |
< |
sprintf(errmsg, "(%s): error reading scene", nm); |
566 |
> |
sprintf(errmsg, "(%s): error reading input", nm); |
567 |
|
error(USER, errmsg); |
568 |
|
} |
417 |
– |
|
418 |
– |
|
419 |
– |
int |
420 |
– |
otype(ofname) /* get object function number from its name */ |
421 |
– |
char *ofname; |
422 |
– |
{ |
423 |
– |
register int i; |
424 |
– |
|
425 |
– |
for (i = 0; i < NUMOTYPE; i++) |
426 |
– |
if (!strcmp(ofun[i].funame, ofname)) |
427 |
– |
return(i); |
428 |
– |
|
429 |
– |
return(-1); /* not found */ |
430 |
– |
} |
431 |
– |
|
432 |
– |
|
433 |
– |
o_default() {} |