ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rview.c
(Generate patch)

Comparing ray/src/rt/rview.c (file contents):
Revision 2.8 by greg, Mon Sep 21 12:08:00 1992 UTC vs.
Revision 2.28 by greg, Mon Jun 13 20:07:56 2005 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 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   *  rview.c - routines and variables for interactive view generation.
6   *
7 < *     3/24/87
7 > *  External symbols declared in rpaint.h
8   */
9  
10 < #include  "ray.h"
10 > #include "copyright.h"
11  
15 #include  "rpaint.h"
16
12   #include  <signal.h>
18
13   #include  <ctype.h>
14  
15 < VIEW  ourview = STDVIEW;                /* viewing parameters */
16 < int  hresolu, vresolu;                  /* image resolution */
15 > #include  "ray.h"
16 > #include  "rpaint.h"
17  
18 +
19 + CUBE  thescene;                         /* our scene */
20 + OBJECT  nsceneobjs;                     /* number of objects in our scene */
21 +
22   int  dimlist[MAXDIM];                   /* sampling dimensions */
23   int  ndims = 0;                         /* number of sampling dimensions */
24   int  samplendx = 0;                     /* index for this sample */
25  
26 + extern void  ambnotify();
27 + void  (*addobjnotify[])() = {ambnotify, NULL};
28 +
29 + VIEW  ourview = STDVIEW;                /* viewing parameters */
30 + int  hresolu, vresolu;                  /* image resolution */
31 +
32 + void  (*trace)() = NULL;                /* trace call */
33 +
34 + int  do_irrad = 0;                      /* compute irradiance? */
35 +
36 + int  rand_samp = 0;                     /* pure Monte Carlo sampling? */
37 +
38   int  psample = 8;                       /* pixel sample size */
39   double  maxdiff = .15;                  /* max. sample difference */
40  
# Line 35 | Line 45 | double shadthresh = .1;                /* shadow threshold */
45   double  shadcert = .25;                 /* shadow certainty */
46   int  directrelay = 0;                   /* number of source relays */
47   int  vspretest = 128;                   /* virtual source pretest density */
48 < int  directinvis = 0;                   /* sources invisible? */
48 > int  directvis = 1;                     /* sources visible? */
49   double  srcsizerat = 0.;                /* maximum ratio source size/dist. */
50  
51 + COLOR  cextinction = BLKCOLOR;          /* global extinction coefficient */
52 + COLOR  salbedo = BLKCOLOR;              /* global scattering albedo */
53 + double  seccg = 0.;                     /* global scattering eccentricity */
54 + double  ssampdist = 0.;                 /* scatter sampling distance */
55 +
56   double  specthresh = .3;                /* specular sampling threshold */
57   double  specjitter = 1.;                /* specular sampling jitter */
58  
59 < int  maxdepth = 4;                      /* maximum recursion depth */
59 > int  backvis = 1;                       /* back face visibility */
60 >
61 > int  maxdepth = 6;                      /* maximum recursion depth */
62   double  minweight = 1e-2;               /* minimum ray weight */
63  
64 + char  *ambfile = NULL;                  /* ambient file name */
65   COLOR  ambval = BLKCOLOR;               /* ambient value */
66 < double  ambacc = 0.2;                   /* ambient accuracy */
67 < int  ambres = 8;                        /* ambient resolution */
68 < int  ambdiv = 32;                       /* ambient divisions */
69 < int  ambssamp = 0;                      /* ambient super-samples */
66 > int  ambvwt = 0;                        /* initial weight for ambient value */
67 > double  ambacc = 0.3;                   /* ambient accuracy */
68 > int  ambres = 32;                       /* ambient resolution */
69 > int  ambdiv = 256;                      /* ambient divisions */
70 > int  ambssamp = 64;                     /* ambient super-samples */
71   int  ambounce = 0;                      /* ambient bounces */
72 < char  *amblist[128];                    /* ambient include/exclude list */
72 > char  *amblist[AMBLLEN];                /* ambient include/exclude list */
73   int  ambincl = -1;                      /* include == 1, exclude == 0 */
74  
75   int  greyscale = 0;                     /* map colors to brightness? */
76 < char  *devname = dev_default;           /* output device name */
76 > char  *dvcname = dev_default;           /* output device name */
77  
78   struct driver  *dev = NULL;             /* driver functions */
79  
80 + char  rifname[128];                     /* rad input file name */
81 +
82   VIEW  oldview;                          /* previous view parameters */
83  
84   PNODE  ptrunk;                          /* the base of our image */
# Line 71 | Line 92 | static char  *reserve_mem = NULL;      /* pre-allocated res
92   #define  CTRL(c)        ((c)-'@')
93  
94  
95 + void
96   quit(code)                      /* quit program */
97   int  code;
98   {
99 + #ifdef MSTATS
100 +        if (code == 2 && errno == ENOMEM)
101 +                printmemstats(stderr);
102 + #endif
103          devclose();
104          exit(code);
105   }
106  
107  
108 + void
109   devopen(dname)                          /* open device driver */
110   char  *dname;
111   {
# Line 89 | Line 116 | char  *dname;
116          id = octname!=NULL ? octname : progname;
117                                                  /* check device table */
118          for (i = 0; devtable[i].name; i++)
119 <                if (!strcmp(dname, devtable[i].name))
119 >                if (!strcmp(dname, devtable[i].name)) {
120                          if ((dev = (*devtable[i].init)(dname, id)) == NULL) {
121                                  sprintf(errmsg, "cannot initialize %s", dname);
122                                  error(USER, errmsg);
123                          } else
124                                  return;
125 < #ifndef NIX                                                
125 >                }
126                                                  /* not there, try exec */
127          if ((dev = comm_init(dname, id)) == NULL) {
128                  sprintf(errmsg, "cannot start device \"%s\"", dname);
129                  error(USER, errmsg);
130          }
104 #endif
131   }
132  
133  
134 + void
135   devclose()                              /* close our device */
136   {
137          if (dev != NULL)
# Line 113 | Line 140 | devclose()                             /* close our device */
140   }
141  
142  
143 + void
144   printdevices()                          /* print list of output devices */
145   {
146          register int  i;
# Line 122 | Line 150 | printdevices()                         /* print list of output devices */
150   }
151  
152  
153 + void
154   rview()                         /* do a view */
155   {
156          char  buf[32];
157  
158 <        devopen(devname);               /* open device */
158 >        devopen(dvcname);               /* open device */
159          newimage();                     /* start image (calls fillreserves) */
160  
161          for ( ; ; ) {                   /* quit in command() */
# Line 154 | Line 183 | rview()                                /* do a view */
183   }
184  
185  
186 + void
187   fillreserves()                  /* fill memory reserves */
188   {
189          if (reserve_mem != NULL)
190                  return;
191 <        reserve_mem = malloc(RESERVE_AMT);
191 >        reserve_mem = (char *)malloc(RESERVE_AMT);
192   }
193  
194  
195 + void
196   freereserves()                  /* free memory reserves */
197   {
198          if (reserve_mem == NULL)
# Line 171 | Line 202 | freereserves()                 /* free memory reserves */
202   }
203  
204  
205 + void
206   command(prompt)                 /* get/execute command */
207   char  *prompt;
208   {
# Line 185 | Line 217 | again:
217          else *++args = '\0';
218          
219          switch (inpbuf[0]) {
220 <        case 'f':                               /* new frame */
221 <                if (badcom("frame"))
222 <                        goto commerr;
220 >        case 'f':                               /* new frame (|focus|free) */
221 >                if (badcom("frame")) {
222 >                        if (badcom("focus")) {
223 >                                if (badcom("free"))
224 >                                        goto commerr;
225 >                                free_objmem();
226 >                                break;
227 >                        }
228 >                        getfocus(args);
229 >                        break;
230 >                }
231                  getframe(args);
232                  break;
233          case 'v':                               /* view */
# Line 200 | Line 240 | again:
240                          goto commerr;
241                  lastview(args);
242                  break;
243 +        case 'V':                               /* save view */
244 +                if (badcom("V"))
245 +                        goto commerr;
246 +                saveview(args);
247 +                break;
248 +        case 'L':                               /* load view */
249 +                if (badcom("L"))
250 +                        goto commerr;
251 +                loadview(args);
252 +                break;
253          case 'e':                               /* exposure */
254                  if (badcom("exposure"))
255                          goto commerr;
256                  getexposure(args);
257                  break;
258          case 's':                               /* set a parameter */
259 <                if (badcom("set"))
259 >                if (badcom("set")) {
260 > #ifdef  SIGTSTP
261 >                        if (!badcom("stop"))
262 >                                goto dostop;
263 > #endif
264                          goto commerr;
265 +                }
266                  setparam(args);
267                  break;
268          case 'n':                               /* new picture */
# Line 225 | Line 280 | again:
280                          goto commerr;
281                  getaim(args);
282                  break;
283 <        case 'm':                               /* move camera */
283 >        case 'm':                               /* move camera (or memstats) */
284                  if (badcom("move"))
285   #ifdef  MSTATS
286                  {
# Line 241 | Line 296 | again:
296                  break;
297          case 'r':                               /* rotate/repaint */
298                  if (badcom("rotate")) {
299 <                        if (badcom("repaint"))
300 <                                goto commerr;
299 >                        if (badcom("repaint")) {
300 >                                if (badcom("redraw"))
301 >                                        goto commerr;
302 >                                redraw();
303 >                                break;
304 >                        }
305                          getrepaint(args);
306                          break;
307                  }
308                  getrotate(args);
309                  break;
310          case 'p':                               /* pivot view */
311 <                if (badcom("pivot"))
312 <                        goto commerr;
311 >                if (badcom("pivot")) {
312 >                        if (badcom("pause"))
313 >                                goto commerr;
314 >                        goto again;
315 >                }
316                  getpivot(args);
317                  break;
318          case CTRL('R'):                         /* redraw */
# Line 268 | Line 330 | again:
330          case CTRL('C'):                         /* interrupt */
331                  goto again;
332   #ifdef  SIGTSTP
333 <        case CTRL('Z'):                         /* stop */
333 >        case CTRL('Z'):;                        /* stop */
334 > dostop:
335                  devclose();
336                  kill(0, SIGTSTP);
337                  /* pc stops here */
338 <                devopen(devname);
338 >                devopen(dvcname);
339                  redraw();
340                  break;
341   #endif
# Line 292 | Line 355 | commerr:
355   }
356  
357  
358 + void
359   rsample()                       /* sample the image */
360   {
361          int  xsiz, ysiz, y;
# Line 307 | Line 371 | rsample()                      /* sample the image */
371           * difference, we subsample the super-pixels.  The testing process
372           * includes initialization of the next row.
373           */
374 <        xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
375 <        ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
374 >        xsiz = (((long)(pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
375 >        ysiz = (((long)(pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
376          rl = (RECT *)malloc(xsiz*sizeof(RECT));
377          if (rl == NULL)
378                  return;
379          pl = (PNODE **)malloc(xsiz*sizeof(PNODE *));
380          if (pl == NULL) {
381 <                free((char *)rl);
381 >                free((void *)rl);
382                  return;
383          }
384          /*
# Line 375 | Line 439 | rsample()                      /* sample the image */
439                  }
440          }
441   escape:
442 <        free((char *)rl);
443 <        free((char *)pl);
442 >        free((void *)rl);
443 >        free((void *)pl);
444   }
445  
446  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines