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 "platform.h" |
12 |
+ |
#include "mkillum.h" |
13 |
+ |
#include "random.h" |
14 |
+ |
|
15 |
|
/* default parameters */ |
16 |
< |
#define SAMPDENS 128 /* points per projected steradian */ |
16 |
> |
#define SAMPDENS 48 /* points per projected steradian */ |
17 |
|
#define NSAMPS 32 /* samples per point */ |
18 |
|
#define DFLMAT "illum_mat" /* material name */ |
19 |
+ |
#define DFLDAT "illum" /* data file name */ |
20 |
|
/* selection options */ |
21 |
|
#define S_NONE 0 /* select none */ |
22 |
|
#define S_ELEM 1 /* select specified element */ |
24 |
|
#define S_ALL 3 /* select all */ |
25 |
|
|
26 |
|
/* rtrace command and defaults */ |
27 |
< |
char *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-ab", "2", |
28 |
< |
"-ad", "256", "-as", "128", "-aa", ".15" }; |
29 |
< |
int rtargc = 13; |
27 |
> |
char *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-dv-", |
28 |
> |
"-ab", "2", "-ad", "1024", "-as", "512", "-aa", ".1", }; |
29 |
> |
int rtargc = 14; |
30 |
|
/* overriding rtrace options */ |
31 |
< |
char *myrtopts[] = { "-I-", "-i-", "-di+", "-ov", "-h-", "-fff", NULL }; |
31 |
> |
char *myrtopts[] = { "-I-", "-i-", "-ld-", "-ov", "-h-", |
32 |
> |
"-fff", "-y", "0", NULL }; |
33 |
|
|
34 |
< |
struct rtproc rt; /* our rtrace process */ |
34 |
> |
struct rtproc rt0; /* head of rtrace process list */ |
35 |
|
|
36 |
|
struct illum_args thisillum = { /* our illum and default values */ |
37 |
|
0, |
38 |
|
DFLMAT, |
39 |
< |
DFLMAT, |
39 |
> |
DFLDAT, |
40 |
|
0, |
41 |
|
VOIDID, |
42 |
+ |
SAMPDENS, |
43 |
|
NSAMPS, |
44 |
+ |
0., |
45 |
|
}; |
46 |
|
|
43 |
– |
int sampdens = SAMPDENS; /* sample point density */ |
47 |
|
char matcheck[MAXSTR]; /* current material to include or exclude */ |
48 |
|
int matselect = S_ALL; /* selection criterion */ |
49 |
|
|
50 |
|
FUN ofun[NUMOTYPE] = INIT_OTYPE; /* object types */ |
51 |
|
|
52 |
+ |
char persistfn[] = "pfXXXXXX"; /* persist file name */ |
53 |
+ |
|
54 |
|
int gargc; /* global argc */ |
55 |
|
char **gargv; /* global argv */ |
56 |
|
#define progname gargv[0] |
60 |
|
|
61 |
|
int warnings = 1; /* print warnings? */ |
62 |
|
|
63 |
< |
extern char *fgetline(), *fgetword(), *sskip(), |
64 |
< |
*atos(), *iskip(), *fskip(); |
65 |
< |
extern FILE *popen(); |
63 |
> |
int done_rprocs(struct rtproc *rtp); |
64 |
> |
void init(int np); |
65 |
> |
void filter(register FILE *infp, char *name); |
66 |
> |
void xoptions(char *s, char *nm); |
67 |
> |
void printopts(void); |
68 |
> |
void printhead(register int ac, register char **av); |
69 |
> |
void xobject(FILE *fp, char *nm); |
70 |
|
|
71 |
|
|
72 |
< |
main(argc, argv) /* compute illum distributions using rtrace */ |
73 |
< |
int argc; |
74 |
< |
char *argv[]; |
72 |
> |
int |
73 |
> |
main( /* compute illum distributions using rtrace */ |
74 |
> |
int argc, |
75 |
> |
char *argv[] |
76 |
> |
) |
77 |
|
{ |
78 |
< |
extern char *getenv(), *getpath(); |
78 |
> |
int nprocs = 1; |
79 |
|
char *rtpath; |
80 |
+ |
FILE *fp; |
81 |
|
register int i; |
82 |
|
/* set global arguments */ |
83 |
< |
gargc = argc; gargv = argv; |
83 |
> |
gargv = argv; |
84 |
> |
/* check for -n option */ |
85 |
> |
if (!strcmp(argv[1], "-n")) { |
86 |
> |
nprocs = atoi(argv[2]); |
87 |
> |
if (nprocs <= 0) |
88 |
> |
error(USER, "illegal number of processes"); |
89 |
> |
i = 3; |
90 |
> |
} else |
91 |
> |
i = 1; |
92 |
|
/* set up rtrace command */ |
93 |
< |
if (argc < 2) |
94 |
< |
error(USER, "too few arguments"); |
95 |
< |
for (i = 1; i < argc-1; i++) { |
93 |
> |
for ( ; i < argc; i++) { |
94 |
> |
if (argv[i][0] == '<' && argv[i][1] == '\0') |
95 |
> |
break; |
96 |
|
rtargv[rtargc++] = argv[i]; |
97 |
|
if (argv[i][0] == '-' && argv[i][1] == 'w') |
98 |
< |
warnings = !warnings; |
98 |
> |
switch (argv[i][2]) { |
99 |
> |
case '\0': |
100 |
> |
warnings = !warnings; |
101 |
> |
break; |
102 |
> |
case '+': |
103 |
> |
case 'T': case 't': |
104 |
> |
case 'Y': case 'y': |
105 |
> |
case '1': |
106 |
> |
warnings = 1; |
107 |
> |
break; |
108 |
> |
case '-': |
109 |
> |
case 'F': case 'f': |
110 |
> |
case 'N': case 'n': |
111 |
> |
case '0': |
112 |
> |
warnings = 0; |
113 |
> |
break; |
114 |
> |
} |
115 |
|
} |
116 |
+ |
gargc = i; |
117 |
+ |
if (!strcmp(rtargv[--rtargc], "-defaults")) |
118 |
+ |
nprocs = 0; |
119 |
+ |
if (nprocs > 1) { /* add persist file if parallel invocation */ |
120 |
+ |
rtargv[rtargc++] = "-PP"; |
121 |
+ |
rtargv[rtargc++] = mktemp(persistfn); |
122 |
+ |
} |
123 |
+ |
/* add "mandatory" rtrace options */ |
124 |
|
for (i = 0; myrtopts[i] != NULL; i++) |
125 |
|
rtargv[rtargc++] = myrtopts[i]; |
126 |
< |
rtargv[rtargc++] = argv[argc-1]; |
126 |
> |
/* finally, put back final argument */ |
127 |
> |
rtargv[rtargc++] = argv[gargc-1]; |
128 |
|
rtargv[rtargc] = NULL; |
129 |
< |
/* just asking for defaults? */ |
130 |
< |
if (!strcmp(argv[argc-1], "-defaults")) { |
129 |
> |
if (!nprocs) { /* just asking for defaults? */ |
130 |
> |
printopts(); fflush(stdout); |
131 |
|
rtpath = getpath(rtargv[0], getenv("PATH"), X_OK); |
132 |
|
if (rtpath == NULL) { |
133 |
|
eputs(rtargv[0]); |
135 |
|
exit(1); |
136 |
|
} |
137 |
|
execv(rtpath, rtargv); |
138 |
< |
perror(rtpath); |
138 |
> |
perror(rtpath); /* execv() should not return */ |
139 |
|
exit(1); |
140 |
|
} |
141 |
+ |
if (gargc < 2 || argv[gargc-1][0] == '-') |
142 |
+ |
error(USER, "missing octree argument"); |
143 |
|
/* else initialize and run our calculation */ |
144 |
< |
init(); |
145 |
< |
filter(stdin, "standard input"); |
144 |
> |
init(nprocs); |
145 |
> |
if (gargc+1 < argc) |
146 |
> |
for (i = gargc+1; i < argc; i++) { |
147 |
> |
if ((fp = fopen(argv[i], "r")) == NULL) { |
148 |
> |
sprintf(errmsg, |
149 |
> |
"cannot open scene file \"%s\"", argv[i]); |
150 |
> |
error(SYSTEM, errmsg); |
151 |
> |
} |
152 |
> |
filter(fp, argv[i]); |
153 |
> |
fclose(fp); |
154 |
> |
} |
155 |
> |
else |
156 |
> |
filter(stdin, "standard input"); |
157 |
|
quit(0); |
158 |
|
} |
159 |
|
|
160 |
+ |
static void |
161 |
+ |
killpersist(void) /* kill persistent rtrace process */ |
162 |
+ |
{ |
163 |
+ |
FILE *fp = fopen(persistfn, "r"); |
164 |
+ |
int pid; |
165 |
|
|
166 |
< |
init() /* start rtrace and set up buffers */ |
166 |
> |
if (fp == NULL) |
167 |
> |
return; |
168 |
> |
if (fscanf(fp, "%*s %d", &pid) != 1 || kill(pid, SIGALRM) < 0) |
169 |
> |
unlink(persistfn); |
170 |
> |
fclose(fp); |
171 |
> |
} |
172 |
> |
|
173 |
> |
int |
174 |
> |
done_rprocs(struct rtproc *rtp) |
175 |
|
{ |
176 |
< |
int maxbytes; |
176 |
> |
int st0, st1 = 0; |
177 |
|
|
178 |
< |
maxbytes = open_process(rt.pd, rtargv); |
179 |
< |
if (maxbytes == 0) { |
180 |
< |
eputs(rtargv[0]); |
181 |
< |
eputs(": command not found\n"); |
111 |
< |
exit(1); |
178 |
> |
if (rtp->next != NULL) { /* close last opened first! */ |
179 |
> |
st1 = done_rprocs(rtp->next); |
180 |
> |
free((void *)rtp->next); |
181 |
> |
rtp->next = NULL; |
182 |
|
} |
183 |
< |
if (maxbytes < 0) |
184 |
< |
error(SYSTEM, "cannot start rtrace process"); |
185 |
< |
rt.bsiz = maxbytes/(6*sizeof(float)); |
186 |
< |
rt.buf = (float *)malloc(rt.bsiz*(6*sizeof(float))); |
187 |
< |
if (rt.buf == NULL) |
188 |
< |
error(SYSTEM, "out of memory in init"); |
119 |
< |
rt.bsiz--; /* allow for flush ray */ |
120 |
< |
rt.nrays = 0; |
183 |
> |
st0 = close_process(&rtp->pd); |
184 |
> |
if (st0 < 0) |
185 |
> |
error(WARNING, "unknown return status from rtrace process"); |
186 |
> |
else if (st0 > 0) |
187 |
> |
return(st0); |
188 |
> |
return(st1); |
189 |
|
} |
190 |
|
|
191 |
< |
|
192 |
< |
quit(status) /* exit with status */ |
125 |
< |
int status; |
191 |
> |
void |
192 |
> |
quit(int status) /* exit with status */ |
193 |
|
{ |
194 |
|
int rtstat; |
195 |
|
|
196 |
< |
rtstat = close_process(rt.pd); |
196 |
> |
if (rt0.next != NULL) /* terminate persistent rtrace */ |
197 |
> |
killpersist(); |
198 |
> |
/* clean up rtrace process(es) */ |
199 |
> |
rtstat = done_rprocs(&rt0); |
200 |
|
if (status == 0) |
201 |
< |
if (rtstat < 0) |
132 |
< |
error(WARNING, |
133 |
< |
"unknown return status from rtrace process"); |
134 |
< |
else |
135 |
< |
status = rtstat; |
201 |
> |
status = rtstat; |
202 |
|
exit(status); |
203 |
|
} |
204 |
|
|
205 |
+ |
void |
206 |
+ |
init(int np) /* start rtrace and set up buffers */ |
207 |
+ |
{ |
208 |
+ |
struct rtproc *rtp; |
209 |
+ |
int i; |
210 |
+ |
int maxbytes; |
211 |
+ |
/* set up object functions */ |
212 |
+ |
ofun[OBJ_FACE].funp = o_face; |
213 |
+ |
ofun[OBJ_SPHERE].funp = o_sphere; |
214 |
+ |
ofun[OBJ_RING].funp = o_ring; |
215 |
+ |
/* set up signal handling */ |
216 |
+ |
#ifdef SIGPIPE /* not present on Windows */ |
217 |
+ |
signal(SIGPIPE, quit); |
218 |
+ |
#endif |
219 |
+ |
rtp = &rt0; /* start rtrace process(es) */ |
220 |
+ |
for (i = 0; i++ < np; ) { |
221 |
+ |
errno = 0; |
222 |
+ |
maxbytes = open_process(&rtp->pd, rtargv); |
223 |
+ |
if (maxbytes == 0) { |
224 |
+ |
eputs(rtargv[0]); |
225 |
+ |
eputs(": command not found\n"); |
226 |
+ |
exit(1); |
227 |
+ |
} |
228 |
+ |
if (maxbytes < 0) |
229 |
+ |
error(SYSTEM, "cannot start rtrace process"); |
230 |
+ |
rtp->bsiz = maxbytes/(6*sizeof(float)); |
231 |
+ |
rtp->buf = (float *)malloc(6*sizeof(float)*rtp->bsiz--); |
232 |
+ |
rtp->dest = (float **)calloc(rtp->bsiz, sizeof(float *)); |
233 |
+ |
if (rtp->buf == NULL || rtp->dest == NULL) |
234 |
+ |
error(SYSTEM, "out of memory in init"); |
235 |
+ |
rtp->nrays = 0; |
236 |
+ |
if (i == np) /* last process? */ |
237 |
+ |
break; |
238 |
+ |
if (np > 1) |
239 |
+ |
sleep(2); /* wait for persist file */ |
240 |
+ |
rtp->next = (struct rtproc *)malloc(sizeof(struct rtproc)); |
241 |
+ |
if (rtp->next == NULL) |
242 |
+ |
error(SYSTEM, "out of memory in init"); |
243 |
+ |
rtp = rtp->next; |
244 |
+ |
} |
245 |
+ |
rtp->next = NULL; |
246 |
+ |
/* set up urand */ |
247 |
+ |
initurand(16384); |
248 |
+ |
} |
249 |
|
|
250 |
< |
eputs(s) /* put string to stderr */ |
251 |
< |
register char *s; |
250 |
> |
|
251 |
> |
void |
252 |
> |
eputs( /* put string to stderr */ |
253 |
> |
register char *s |
254 |
> |
) |
255 |
|
{ |
256 |
|
static int midline = 0; |
257 |
|
|
265 |
|
} |
266 |
|
|
267 |
|
|
268 |
+ |
void |
269 |
|
wputs(s) /* print warning if enabled */ |
270 |
|
char *s; |
271 |
|
{ |
274 |
|
} |
275 |
|
|
276 |
|
|
277 |
< |
filter(infp, name) /* process stream */ |
278 |
< |
register FILE *infp; |
279 |
< |
char *name; |
277 |
> |
void |
278 |
> |
filter( /* process stream */ |
279 |
> |
register FILE *infp, |
280 |
> |
char *name |
281 |
> |
) |
282 |
|
{ |
283 |
|
char buf[512]; |
284 |
|
FILE *pfp; |
308 |
|
} |
309 |
|
|
310 |
|
|
311 |
< |
xoptions(s, nm) /* process options in string s */ |
312 |
< |
char *s; |
313 |
< |
char *nm; |
311 |
> |
void |
312 |
> |
xoptions( /* process options in string s */ |
313 |
> |
char *s, |
314 |
> |
char *nm |
315 |
> |
) |
316 |
|
{ |
317 |
|
extern FILE *freopen(); |
318 |
|
char buf[64]; |
329 |
|
case ' ': |
330 |
|
case '\t': |
331 |
|
case '\n': |
332 |
+ |
case '\r': |
333 |
+ |
case '\f': |
334 |
|
cp++; |
335 |
|
continue; |
336 |
|
case 'm': /* material name */ |
337 |
|
if (*++cp != '=') |
338 |
|
break; |
339 |
< |
if (!*++cp) |
339 |
> |
if (!*++cp || isspace(*cp)) |
340 |
|
break; |
341 |
|
atos(thisillum.matname, MAXSTR, cp); |
342 |
|
cp = sskip(cp); |
348 |
|
case 'f': /* data file name */ |
349 |
|
if (*++cp != '=') |
350 |
|
break; |
351 |
< |
if (!*++cp) { |
351 |
> |
if (!*++cp || isspace(*cp)) { |
352 |
> |
strcpy(thisillum.datafile,thisillum.matname); |
353 |
> |
thisillum.dfnum = 0; |
354 |
|
thisillum.flags &= ~IL_DATCLB; |
355 |
|
continue; |
356 |
|
} |
361 |
|
continue; |
362 |
|
case 'i': /* include material */ |
363 |
|
case 'e': /* exclude material */ |
364 |
< |
matselect = (*cp == 'i') ? S_ELEM : S_COMPL; |
243 |
< |
if (*++cp != '=') |
364 |
> |
if (cp[1] != '=') |
365 |
|
break; |
366 |
< |
atos(matcheck, MAXSTR, ++cp); |
366 |
> |
matselect = (*cp == 'i') ? S_ELEM : S_COMPL; |
367 |
> |
cp += 2; |
368 |
> |
atos(matcheck, MAXSTR, cp); |
369 |
|
cp = sskip(cp); |
370 |
|
continue; |
371 |
|
case 'a': /* use everything */ |
381 |
|
break; |
382 |
|
switch (*++cp) { |
383 |
|
case 'a': /* average */ |
384 |
< |
thisillum.flags |= IL_COLAVG; |
385 |
< |
thisillum.flags &= ~IL_COLDST; |
384 |
> |
thisillum.flags = (thisillum.flags|IL_COLAVG) |
385 |
> |
& ~IL_COLDST; |
386 |
|
break; |
387 |
|
case 'd': /* distribution */ |
388 |
< |
thisillum.flags |= IL_COLDST; |
266 |
< |
thisillum.flags &= ~IL_COLAVG; |
388 |
> |
thisillum.flags |= (IL_COLDST|IL_COLAVG); |
389 |
|
break; |
390 |
|
case 'n': /* none */ |
391 |
|
thisillum.flags &= ~(IL_COLAVG|IL_COLDST); |
398 |
|
case 'd': /* point sample density */ |
399 |
|
if (*++cp != '=') |
400 |
|
break; |
401 |
< |
if (!isintd(++cp, " \t\n")) |
401 |
> |
if (!isintd(++cp, " \t\n\r")) |
402 |
|
break; |
403 |
< |
sampdens = atoi(cp); |
403 |
> |
thisillum.sampdens = atoi(cp); |
404 |
|
cp = sskip(cp); |
405 |
|
continue; |
406 |
|
case 's': /* point super-samples */ |
407 |
|
if (*++cp != '=') |
408 |
|
break; |
409 |
< |
if (!isintd(++cp, " \t\n")) |
409 |
> |
if (!isintd(++cp, " \t\n\r")) |
410 |
|
break; |
411 |
|
thisillum.nsamps = atoi(cp); |
412 |
|
cp = sskip(cp); |
413 |
|
continue; |
414 |
+ |
case 'l': /* light sources */ |
415 |
+ |
cp++; |
416 |
+ |
if (*cp == '+') |
417 |
+ |
thisillum.flags |= IL_LIGHT; |
418 |
+ |
else if (*cp == '-') |
419 |
+ |
thisillum.flags &= ~IL_LIGHT; |
420 |
+ |
else |
421 |
+ |
break; |
422 |
+ |
cp++; |
423 |
+ |
continue; |
424 |
+ |
case 'b': /* brightness */ |
425 |
+ |
if (*++cp != '=') |
426 |
+ |
break; |
427 |
+ |
if (!isfltd(++cp, " \t\n\r")) |
428 |
+ |
break; |
429 |
+ |
thisillum.minbrt = atof(cp); |
430 |
+ |
if (thisillum.minbrt < 0.) |
431 |
+ |
thisillum.minbrt = 0.; |
432 |
+ |
cp = sskip(cp); |
433 |
+ |
continue; |
434 |
|
case 'o': /* output file */ |
435 |
|
if (*++cp != '=') |
436 |
|
break; |
437 |
< |
if (!*++cp) |
437 |
> |
if (!*++cp || isspace(*cp)) |
438 |
|
break; |
439 |
|
atos(buf, sizeof(buf), cp); |
440 |
|
cp = sskip(cp); |
445 |
|
} |
446 |
|
doneheader = 0; |
447 |
|
continue; |
448 |
+ |
case '!': /* processed file! */ |
449 |
+ |
sprintf(errmsg, "(%s): already processed!", nm); |
450 |
+ |
error(WARNING, errmsg); |
451 |
+ |
matselect = S_NONE; |
452 |
+ |
return; |
453 |
|
} |
454 |
|
opterr: /* skip faulty option */ |
455 |
< |
cp = sskip(cp); |
455 |
> |
while (*cp && !isspace(*cp)) |
456 |
> |
cp++; |
457 |
|
nerrs++; |
458 |
|
} |
459 |
|
/* print header? */ |
468 |
|
progname, nerrs); |
469 |
|
} |
470 |
|
/* print pure comment */ |
471 |
< |
putchar('#'); putchar(' '); fputs(s+2, stdout); |
471 |
> |
printf("# %s", s+2); |
472 |
|
} |
473 |
|
|
474 |
+ |
void |
475 |
+ |
printopts(void) /* print out option default values */ |
476 |
+ |
{ |
477 |
+ |
printf("m=%-15s\t\t# material name\n", thisillum.matname); |
478 |
+ |
printf("f=%-15s\t\t# data file name\n", thisillum.datafile); |
479 |
+ |
if (thisillum.flags & IL_COLAVG) |
480 |
+ |
if (thisillum.flags & IL_COLDST) |
481 |
+ |
printf("c=d\t\t\t\t# color distribution\n"); |
482 |
+ |
else |
483 |
+ |
printf("c=a\t\t\t\t# color average\n"); |
484 |
+ |
else |
485 |
+ |
printf("c=n\t\t\t\t# color none\n"); |
486 |
+ |
if (thisillum.flags & IL_LIGHT) |
487 |
+ |
printf("l+\t\t\t\t# light type on\n"); |
488 |
+ |
else |
489 |
+ |
printf("l-\t\t\t\t# light type off\n"); |
490 |
+ |
printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens); |
491 |
+ |
printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps); |
492 |
+ |
printf("b=%f\t\t\t# minimum average brightness\n", thisillum.minbrt); |
493 |
+ |
} |
494 |
|
|
495 |
< |
printhead(ac, av) /* print out header */ |
496 |
< |
register int ac; |
497 |
< |
register char **av; |
495 |
> |
|
496 |
> |
void |
497 |
> |
printhead( /* print out header */ |
498 |
> |
register int ac, |
499 |
> |
register char **av |
500 |
> |
) |
501 |
|
{ |
502 |
|
putchar('#'); |
503 |
|
while (ac-- > 0) { |
504 |
|
putchar(' '); |
505 |
|
fputs(*av++, stdout); |
506 |
|
} |
507 |
< |
putchar('\n'); |
507 |
> |
fputs("\n#@mkillum !\n", stdout); |
508 |
|
} |
509 |
|
|
510 |
|
|
511 |
< |
xobject(fp, nm) /* translate an object from fp */ |
512 |
< |
FILE *fp; |
513 |
< |
char *nm; |
511 |
> |
void |
512 |
> |
xobject( /* translate an object from fp */ |
513 |
> |
FILE *fp, |
514 |
> |
char *nm |
515 |
> |
) |
516 |
|
{ |
517 |
|
OBJREC thisobj; |
518 |
|
char str[MAXSTR]; |
523 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
524 |
|
goto readerr; |
525 |
|
/* is it an alias? */ |
526 |
< |
if (!strcmp(str, ALIASID)) { |
526 |
> |
if (!strcmp(str, ALIASKEY)) { |
527 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
528 |
|
goto readerr; |
529 |
< |
printf("\n%s %s %s", thisillum.altmat, ALIASID, str); |
529 |
> |
printf("\n%s %s %s", thisillum.altmat, ALIASKEY, str); |
530 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
531 |
|
goto readerr; |
532 |
< |
printf(" %s\n", str); |
532 |
> |
printf("\t%s\n", str); |
533 |
|
return; |
534 |
|
} |
535 |
< |
thisobj.omod = OVOID; |
535 |
> |
thisobj.omod = OVOID; /* unused field */ |
536 |
|
if ((thisobj.otype = otype(str)) < 0) { |
537 |
|
sprintf(errmsg, "(%s): unknown type \"%s\"", nm, str); |
538 |
|
error(USER, errmsg); |
549 |
|
doit = 0; |
550 |
|
break; |
551 |
|
case S_ALL: |
552 |
< |
doit = issurface(thisobj.otype); |
552 |
> |
doit = 1; |
553 |
|
break; |
554 |
|
case S_ELEM: |
555 |
|
doit = !strcmp(thisillum.altmat, matcheck); |
558 |
|
doit = strcmp(thisillum.altmat, matcheck); |
559 |
|
break; |
560 |
|
} |
561 |
< |
if (doit) /* make sure we can do it */ |
389 |
< |
switch (thisobj.otype) { |
390 |
< |
case OBJ_SPHERE: |
391 |
< |
case OBJ_FACE: |
392 |
< |
case OBJ_RING: |
393 |
< |
break; |
394 |
< |
default: |
395 |
< |
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; |
401 |
< |
break; |
402 |
< |
} |
561 |
> |
doit = doit && issurface(thisobj.otype); |
562 |
|
/* print header? */ |
563 |
|
checkhead(); |
564 |
|
/* process object */ |
565 |
|
if (doit) |
566 |
< |
mkillum(&thisobj, &thisillum, &rt); |
566 |
> |
(*ofun[thisobj.otype].funp)(&thisobj, &thisillum, &rt0, nm); |
567 |
|
else |
568 |
|
printobj(thisillum.altmat, &thisobj); |
569 |
|
/* free arguments */ |
573 |
|
sprintf(errmsg, "(%s): error reading scene", nm); |
574 |
|
error(USER, errmsg); |
575 |
|
} |
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() {} |