--- ray/src/rt/rview.c 1993/02/10 14:03:01 2.10 +++ ray/src/rt/rview.c 2004/03/28 16:31:14 2.25 @@ -1,30 +1,38 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: rview.c,v 2.25 2004/03/28 16:31:14 greg Exp $"; #endif - /* * rview.c - routines and variables for interactive view generation. * - * 3/24/87 + * External symbols declared in rpaint.h */ -#include "ray.h" +#include "copyright.h" -#include "rpaint.h" - #include - #include -VIEW ourview = STDVIEW; /* viewing parameters */ -int hresolu, vresolu; /* image resolution */ +#include "ray.h" +#include "rpaint.h" + +CUBE thescene; /* our scene */ +OBJECT nsceneobjs; /* number of objects in our scene */ + int dimlist[MAXDIM]; /* sampling dimensions */ int ndims = 0; /* number of sampling dimensions */ int samplendx = 0; /* index for this sample */ +extern void ambnotify(); +void (*addobjnotify[])() = {ambnotify, NULL}; + +VIEW ourview = STDVIEW; /* viewing parameters */ +int hresolu, vresolu; /* image resolution */ + +void (*trace)() = NULL; /* trace call */ + +int do_irrad = 0; /* compute irradiance? */ + int psample = 8; /* pixel sample size */ double maxdiff = .15; /* max. sample difference */ @@ -38,26 +46,37 @@ int vspretest = 128; /* virtual source pretest dens int directvis = 1; /* sources visible? */ double srcsizerat = 0.; /* maximum ratio source size/dist. */ +COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ +COLOR salbedo = BLKCOLOR; /* 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 maxdepth = 4; /* maximum recursion depth */ +int backvis = 1; /* back face visibility */ + +int maxdepth = 6; /* maximum recursion depth */ double minweight = 1e-2; /* minimum ray weight */ +char *ambfile = NULL; /* ambient file name */ COLOR ambval = BLKCOLOR; /* ambient value */ -double ambacc = 0.2; /* ambient accuracy */ -int ambres = 8; /* ambient resolution */ -int ambdiv = 32; /* ambient divisions */ -int ambssamp = 0; /* ambient super-samples */ +int ambvwt = 0; /* initial weight for ambient value */ +double ambacc = 0.3; /* ambient accuracy */ +int ambres = 32; /* ambient resolution */ +int ambdiv = 256; /* ambient divisions */ +int ambssamp = 64; /* ambient super-samples */ int ambounce = 0; /* ambient bounces */ char *amblist[128]; /* ambient include/exclude list */ int ambincl = -1; /* include == 1, exclude == 0 */ int greyscale = 0; /* map colors to brightness? */ -char *devname = dev_default; /* output device name */ +char *dvcname = 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 */ @@ -71,6 +90,7 @@ static char *reserve_mem = NULL; /* pre-allocated res #define CTRL(c) ((c)-'@') +void quit(code) /* quit program */ int code; { @@ -83,6 +103,7 @@ int code; } +void devopen(dname) /* open device driver */ char *dname; { @@ -93,22 +114,22 @@ char *dname; id = octname!=NULL ? octname : progname; /* check device table */ for (i = 0; devtable[i].name; i++) - if (!strcmp(dname, devtable[i].name)) + if (!strcmp(dname, devtable[i].name)) { if ((dev = (*devtable[i].init)(dname, id)) == NULL) { sprintf(errmsg, "cannot initialize %s", 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 } +void devclose() /* close our device */ { if (dev != NULL) @@ -117,6 +138,7 @@ devclose() /* close our device */ } +void printdevices() /* print list of output devices */ { register int i; @@ -126,11 +148,12 @@ printdevices() /* print list of output devices */ } +void rview() /* do a view */ { char buf[32]; - devopen(devname); /* open device */ + devopen(dvcname); /* open device */ newimage(); /* start image (calls fillreserves) */ for ( ; ; ) { /* quit in command() */ @@ -158,14 +181,16 @@ rview() /* do a view */ } +void fillreserves() /* fill memory reserves */ { if (reserve_mem != NULL) return; - reserve_mem = malloc(RESERVE_AMT); + reserve_mem = (char *)malloc(RESERVE_AMT); } +void freereserves() /* free memory reserves */ { if (reserve_mem == NULL) @@ -175,6 +200,7 @@ freereserves() /* free memory reserves */ } +void command(prompt) /* get/execute command */ char *prompt; { @@ -208,14 +234,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 */ @@ -249,16 +290,23 @@ 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 */ @@ -276,11 +324,12 @@ again: case CTRL('C'): /* interrupt */ goto again; #ifdef SIGTSTP - case CTRL('Z'): /* stop */ + case CTRL('Z'):; /* stop */ +dostop: devclose(); kill(0, SIGTSTP); /* pc stops here */ - devopen(devname); + devopen(dvcname); redraw(); break; #endif @@ -300,6 +349,7 @@ commerr: } +void rsample() /* sample the image */ { int xsiz, ysiz, y; @@ -315,14 +365,14 @@ rsample() /* sample the image */ * difference, we subsample the super-pixels. The testing process * includes initialization of the next row. */ - xsiz = (((pframe.r-pframe.l)<