1 |
< |
/* Copyright (c) 1987 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
26 |
|
int samplendx = 0; /* index for this sample */ |
27 |
|
|
28 |
|
int psample = 8; /* pixel sample size */ |
29 |
< |
double maxdiff = .15; /* max. sample difference */ |
29 |
> |
double maxdiff = .15; /* max. sample difference */ |
30 |
|
|
31 |
< |
double exposure = 1.0; /* exposure for scene */ |
31 |
> |
double exposure = 1.0; /* exposure for scene */ |
32 |
|
|
33 |
< |
double dstrsrc = 0.0; /* square source distribution */ |
34 |
< |
double shadthresh = .1; /* shadow threshold */ |
35 |
< |
double shadcert = .25; /* shadow certainty */ |
33 |
> |
double dstrsrc = 0.0; /* square source distribution */ |
34 |
> |
double shadthresh = .1; /* shadow threshold */ |
35 |
> |
double shadcert = .25; /* shadow certainty */ |
36 |
|
int directrelay = 0; /* number of source relays */ |
37 |
|
int vspretest = 128; /* virtual source pretest density */ |
38 |
< |
int directinvis = 0; /* sources invisible? */ |
39 |
< |
double srcsizerat = 0.; /* maximum ratio source size/dist. */ |
38 |
> |
int directvis = 1; /* sources visible? */ |
39 |
> |
double srcsizerat = 0.; /* maximum ratio source size/dist. */ |
40 |
|
|
41 |
+ |
COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ |
42 |
+ |
double salbedo = 0.; /* global scattering albedo */ |
43 |
+ |
double seccg = 0.; /* global scattering eccentricity */ |
44 |
+ |
double ssampdist = 0.; /* scatter sampling distance */ |
45 |
+ |
|
46 |
+ |
double specthresh = .3; /* specular sampling threshold */ |
47 |
+ |
double specjitter = 1.; /* specular sampling jitter */ |
48 |
+ |
|
49 |
+ |
int backvis = 1; /* back face visibility */ |
50 |
+ |
|
51 |
|
int maxdepth = 4; /* maximum recursion depth */ |
52 |
< |
double minweight = 1e-2; /* minimum ray weight */ |
52 |
> |
double minweight = 1e-2; /* minimum ray weight */ |
53 |
|
|
54 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
55 |
< |
double ambacc = 0.2; /* ambient accuracy */ |
55 |
> |
double ambacc = 0.2; /* ambient accuracy */ |
56 |
|
int ambres = 8; /* ambient resolution */ |
57 |
|
int ambdiv = 32; /* ambient divisions */ |
58 |
|
int ambssamp = 0; /* ambient super-samples */ |
65 |
|
|
66 |
|
struct driver *dev = NULL; /* driver functions */ |
67 |
|
|
68 |
+ |
char rifname[128]; /* rad input file name */ |
69 |
+ |
|
70 |
|
VIEW oldview; /* previous view parameters */ |
71 |
|
|
72 |
|
PNODE ptrunk; /* the base of our image */ |
77 |
|
|
78 |
|
#define RESERVE_AMT 32768 /* amount of memory to reserve */ |
79 |
|
|
80 |
< |
#define CTRL(c) ((c)-'@') |
80 |
> |
#define CTRL(c) ((c)-'@') |
81 |
|
|
82 |
|
|
83 |
|
quit(code) /* quit program */ |
84 |
|
int code; |
85 |
|
{ |
86 |
+ |
#ifdef MSTATS |
87 |
+ |
if (code == 2 && errno == ENOMEM) |
88 |
+ |
printmemstats(stderr); |
89 |
+ |
#endif |
90 |
|
devclose(); |
91 |
|
exit(code); |
92 |
|
} |
108 |
|
error(USER, errmsg); |
109 |
|
} else |
110 |
|
return; |
111 |
+ |
#ifndef NIX |
112 |
|
/* not there, try exec */ |
113 |
|
if ((dev = comm_init(dname, id)) == NULL) { |
114 |
|
sprintf(errmsg, "cannot start device \"%s\"", dname); |
115 |
|
error(USER, errmsg); |
116 |
|
} |
117 |
+ |
#endif |
118 |
|
} |
119 |
|
|
120 |
|
|
187 |
|
command(prompt) /* get/execute command */ |
188 |
|
char *prompt; |
189 |
|
{ |
190 |
< |
#define badcom(s) strncmp(s, inpbuf, args-inpbuf-1) |
190 |
> |
#define badcom(s) strncmp(s, inpbuf, args-inpbuf-1) |
191 |
|
char inpbuf[256]; |
192 |
|
char *args; |
193 |
|
again: |
198 |
|
else *++args = '\0'; |
199 |
|
|
200 |
|
switch (inpbuf[0]) { |
201 |
< |
case 'f': /* new frame */ |
202 |
< |
if (badcom("frame")) |
203 |
< |
goto commerr; |
201 |
> |
case 'f': /* new frame (or free mem.) */ |
202 |
> |
if (badcom("frame")) { |
203 |
> |
if (badcom("free")) |
204 |
> |
goto commerr; |
205 |
> |
free_objmem(); |
206 |
> |
break; |
207 |
> |
} |
208 |
|
getframe(args); |
209 |
|
break; |
210 |
|
case 'v': /* view */ |
217 |
|
goto commerr; |
218 |
|
lastview(args); |
219 |
|
break; |
220 |
+ |
case 'V': /* save view */ |
221 |
+ |
if (badcom("V")) |
222 |
+ |
goto commerr; |
223 |
+ |
saveview(args); |
224 |
+ |
break; |
225 |
+ |
case 'L': /* load view */ |
226 |
+ |
if (badcom("L")) |
227 |
+ |
goto commerr; |
228 |
+ |
loadview(args); |
229 |
+ |
break; |
230 |
|
case 'e': /* exposure */ |
231 |
|
if (badcom("exposure")) |
232 |
|
goto commerr; |
233 |
|
getexposure(args); |
234 |
|
break; |
235 |
|
case 's': /* set a parameter */ |
236 |
< |
if (badcom("set")) |
236 |
> |
if (badcom("set")) { |
237 |
> |
#ifdef SIGTSTP |
238 |
> |
if (!badcom("stop")) |
239 |
> |
goto dostop; |
240 |
> |
#endif |
241 |
|
goto commerr; |
242 |
+ |
} |
243 |
|
setparam(args); |
244 |
|
break; |
245 |
|
case 'n': /* new picture */ |
257 |
|
goto commerr; |
258 |
|
getaim(args); |
259 |
|
break; |
260 |
< |
case 'm': /* move camera */ |
260 |
> |
case 'm': /* move camera (or memstats) */ |
261 |
|
if (badcom("move")) |
262 |
< |
#ifdef MSTATS |
262 |
> |
#ifdef MSTATS |
263 |
|
{ |
264 |
|
if (badcom("memory")) |
265 |
|
goto commerr; |
273 |
|
break; |
274 |
|
case 'r': /* rotate/repaint */ |
275 |
|
if (badcom("rotate")) { |
276 |
< |
if (badcom("repaint")) |
277 |
< |
goto commerr; |
276 |
> |
if (badcom("repaint")) { |
277 |
> |
if (badcom("redraw")) |
278 |
> |
goto commerr; |
279 |
> |
redraw(); |
280 |
> |
break; |
281 |
> |
} |
282 |
|
getrepaint(args); |
283 |
|
break; |
284 |
|
} |
285 |
|
getrotate(args); |
286 |
|
break; |
287 |
|
case 'p': /* pivot view */ |
288 |
< |
if (badcom("pivot")) |
289 |
< |
goto commerr; |
288 |
> |
if (badcom("pivot")) { |
289 |
> |
if (badcom("pause")) |
290 |
> |
goto commerr; |
291 |
> |
goto again; |
292 |
> |
} |
293 |
|
getpivot(args); |
294 |
|
break; |
295 |
|
case CTRL('R'): /* redraw */ |
306 |
|
quit(0); |
307 |
|
case CTRL('C'): /* interrupt */ |
308 |
|
goto again; |
309 |
< |
#ifdef SIGTSTP |
310 |
< |
case CTRL('Z'): /* stop */ |
309 |
> |
#ifdef SIGTSTP |
310 |
> |
case CTRL('Z'):; /* stop */ |
311 |
> |
dostop: |
312 |
|
devclose(); |
313 |
|
kill(0, SIGTSTP); |
314 |
|
/* pc stops here */ |
328 |
|
error(COMMAND, errmsg); |
329 |
|
break; |
330 |
|
} |
331 |
< |
#undef badcom |
331 |
> |
#undef badcom |
332 |
|
} |
333 |
|
|
334 |
|
|
338 |
|
RECT r; |
339 |
|
PNODE *p; |
340 |
|
register RECT *rl; |
341 |
< |
register PNODE **pl; |
341 |
> |
register PNODE **pl; |
342 |
|
register int x; |
343 |
|
/* |
344 |
|
* We initialize the bottom row in the image at our current |
345 |
< |
* resolution. During sampling, we check super-pixels to the |
345 |
> |
* resolution. During sampling, we check super-pixels to the |
346 |
|
* right and above by calling bigdiff(). If there is a significant |
347 |
|
* difference, we subsample the super-pixels. The testing process |
348 |
|
* includes initialization of the next row. |
349 |
|
*/ |
350 |
< |
xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu; |
351 |
< |
ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu; |
350 |
> |
xsiz = (((long)(pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu; |
351 |
> |
ysiz = (((long)(pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu; |
352 |
|
rl = (RECT *)malloc(xsiz*sizeof(RECT)); |
353 |
|
if (rl == NULL) |
354 |
|
return; |
355 |
|
pl = (PNODE **)malloc(xsiz*sizeof(PNODE *)); |
356 |
< |
if (pl == NULL) |
356 |
> |
if (pl == NULL) { |
357 |
> |
free((char *)rl); |
358 |
|
return; |
359 |
+ |
} |
360 |
|
/* |
361 |
|
* Initialize the bottom row. |
362 |
|
*/ |
422 |
|
|
423 |
|
int |
424 |
|
refine(p, xmin, ymin, xmax, ymax, pd) /* refine a node */ |
425 |
< |
register PNODE *p; |
425 |
> |
register PNODE *p; |
426 |
|
int xmin, ymin, xmax, ymax; |
427 |
|
int pd; |
428 |
|
{ |
446 |
|
return(0); |
447 |
|
/* |
448 |
|
* The following paint order can leave a black pixel |
449 |
< |
* when redraw() is called in (*dev->paintr)(). |
449 |
> |
* if redraw() is called in (*dev->paintr)(). |
450 |
|
*/ |
451 |
|
if (p->x >= mx && p->y >= my) |
452 |
|
pcopy(p, p->kid+UR); |