--- ray/src/rt/rview.c 1991/12/19 14:54:46 2.3 +++ ray/src/rt/rview.c 1996/02/14 15:18:09 2.16 @@ -1,4 +1,4 @@ -/* Copyright (c) 1987 Regents of the University of California */ +/* Copyright (c) 1995 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -26,23 +26,34 @@ int ndims = 0; /* number of sampling dimensions */ int samplendx = 0; /* index for this sample */ int psample = 8; /* pixel sample size */ -double maxdiff = .15; /* max. sample difference */ +double maxdiff = .15; /* max. sample difference */ -double exposure = 1.0; /* exposure for scene */ +double exposure = 1.0; /* exposure for scene */ -double dstrsrc = 0.0; /* square source distribution */ -double shadthresh = .1; /* shadow threshold */ -double shadcert = .25; /* shadow certainty */ +double dstrsrc = 0.0; /* square source distribution */ +double shadthresh = .1; /* shadow threshold */ +double shadcert = .25; /* shadow certainty */ int directrelay = 0; /* number of source relays */ int vspretest = 128; /* virtual source pretest density */ -int directinvis = 0; /* sources invisible? */ -double srcsizerat = 0.; /* maximum ratio source size/dist. */ +int directvis = 1; /* sources visible? */ +double srcsizerat = 0.; /* maximum ratio source size/dist. */ +COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ +double salbedo = 0.; /* global scattering albedo */ +double seccg = 0.; /* global scattering eccentricity */ +double ssampdist = 0.; /* scatter sampling distance */ + +double specthresh = .3; /* specular sampling threshold */ +double specjitter = 1.; /* specular sampling jitter */ + +int backvis = 1; /* back face visibility */ + int maxdepth = 4; /* maximum recursion depth */ -double minweight = 1e-2; /* minimum ray weight */ +double minweight = 1e-2; /* minimum ray weight */ COLOR ambval = BLKCOLOR; /* ambient value */ -double ambacc = 0.2; /* ambient accuracy */ +int ambvwt = 0; /* initial weight for ambient value */ +double ambacc = 0.2; /* ambient accuracy */ int ambres = 8; /* ambient resolution */ int ambdiv = 32; /* ambient divisions */ int ambssamp = 0; /* ambient super-samples */ @@ -55,6 +66,8 @@ char *devname = dev_default; /* output device name * struct driver *dev = NULL; /* driver functions */ +char rifname[128]; /* rad input file name */ + VIEW oldview; /* previous view parameters */ PNODE ptrunk; /* the base of our image */ @@ -65,12 +78,16 @@ static char *reserve_mem = NULL; /* pre-allocated res #define RESERVE_AMT 32768 /* amount of memory to reserve */ -#define CTRL(c) ('c'-'@') +#define CTRL(c) ((c)-'@') quit(code) /* quit program */ int code; { +#ifdef MSTATS + if (code == 2 && errno == ENOMEM) + printmemstats(stderr); +#endif devclose(); exit(code); } @@ -92,11 +109,13 @@ char *dname; error(USER, errmsg); } else return; +#ifndef NIX /* not there, try exec */ if ((dev = comm_init(dname, id)) == NULL) { sprintf(errmsg, "cannot start device \"%s\"", dname); error(USER, errmsg); } +#endif } @@ -169,7 +188,7 @@ freereserves() /* free memory reserves */ command(prompt) /* get/execute command */ char *prompt; { -#define badcom(s) strncmp(s, inpbuf, args-inpbuf-1) +#define badcom(s) strncmp(s, inpbuf, args-inpbuf-1) char inpbuf[256]; char *args; again: @@ -180,9 +199,13 @@ again: else *++args = '\0'; switch (inpbuf[0]) { - case 'f': /* new frame */ - if (badcom("frame")) - goto commerr; + case 'f': /* new frame (or free mem.) */ + if (badcom("frame")) { + if (badcom("free")) + goto commerr; + free_objmem(); + break; + } getframe(args); break; case 'v': /* view */ @@ -195,14 +218,29 @@ again: goto commerr; lastview(args); break; + case 'V': /* save view */ + if (badcom("V")) + goto commerr; + saveview(args); + break; + case 'L': /* load view */ + if (badcom("L")) + goto commerr; + loadview(args); + break; case 'e': /* exposure */ if (badcom("exposure")) goto commerr; getexposure(args); break; case 's': /* set a parameter */ - if (badcom("set")) + if (badcom("set")) { +#ifdef SIGTSTP + if (!badcom("stop")) + goto dostop; +#endif goto commerr; + } setparam(args); break; case 'n': /* new picture */ @@ -220,9 +258,9 @@ again: goto commerr; getaim(args); break; - case 'm': /* move camera */ + case 'm': /* move camera (or memstats) */ if (badcom("move")) -#ifdef MSTATS +#ifdef MSTATS { if (badcom("memory")) goto commerr; @@ -236,19 +274,26 @@ again: break; case 'r': /* rotate/repaint */ if (badcom("rotate")) { - if (badcom("repaint")) - goto commerr; + if (badcom("repaint")) { + if (badcom("redraw")) + goto commerr; + redraw(); + break; + } getrepaint(args); break; } getrotate(args); break; case 'p': /* pivot view */ - if (badcom("pivot")) - goto commerr; + if (badcom("pivot")) { + if (badcom("pause")) + goto commerr; + goto again; + } getpivot(args); break; - case CTRL(R): /* redraw */ + case CTRL('R'): /* redraw */ redraw(); break; case 'w': /* write */ @@ -260,10 +305,11 @@ again: if (badcom("quit")) goto commerr; quit(0); - case CTRL(C): /* interrupt */ + case CTRL('C'): /* interrupt */ goto again; -#ifdef SIGTSTP - case CTRL(Z): /* stop */ +#ifdef SIGTSTP + case CTRL('Z'):; /* stop */ +dostop: devclose(); kill(0, SIGTSTP); /* pc stops here */ @@ -283,7 +329,7 @@ commerr: error(COMMAND, errmsg); break; } -#undef badcom +#undef badcom } @@ -293,23 +339,25 @@ rsample() /* sample the image */ RECT r; PNODE *p; register RECT *rl; - register PNODE **pl; + register PNODE **pl; register int x; /* * We initialize the bottom row in the image at our current - * resolution. During sampling, we check super-pixels to the + * resolution. During sampling, we check super-pixels to the * right and above by calling bigdiff(). If there is a significant * difference, we subsample the super-pixels. The testing process * includes initialization of the next row. */ - xsiz = (((pframe.r-pframe.l)<paintr)(). + * if redraw() is called in (*dev->paintr)(). */ if (p->x >= mx && p->y >= my) pcopy(p, p->kid+UR);