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.10 by greg, Wed Feb 10 14:03:01 1993 UTC vs.
Revision 2.22 by greg, Thu Jul 3 15:00:19 2003 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  psample = 8;                       /* pixel sample size */
37   double  maxdiff = .15;                  /* max. sample difference */
38  
# Line 38 | Line 46 | int  vspretest = 128;                  /* virtual source pretest dens
46   int  directvis = 1;                     /* sources visible? */
47   double  srcsizerat = 0.;                /* maximum ratio source size/dist. */
48  
49 + COLOR  cextinction = BLKCOLOR;          /* global extinction coefficient */
50 + COLOR  salbedo = BLKCOLOR;              /* global scattering albedo */
51 + double  seccg = 0.;                     /* global scattering eccentricity */
52 + double  ssampdist = 0.;                 /* scatter sampling distance */
53 +
54   double  specthresh = .3;                /* specular sampling threshold */
55   double  specjitter = 1.;                /* specular sampling jitter */
56  
57 + int  backvis = 1;                       /* back face visibility */
58 +
59   int  maxdepth = 4;                      /* maximum recursion depth */
60   double  minweight = 1e-2;               /* minimum ray weight */
61  
62 + char  *ambfile = NULL;                  /* ambient file name */
63   COLOR  ambval = BLKCOLOR;               /* ambient value */
64 + int  ambvwt = 0;                        /* initial weight for ambient value */
65   double  ambacc = 0.2;                   /* ambient accuracy */
66   int  ambres = 8;                        /* ambient resolution */
67   int  ambdiv = 32;                       /* ambient divisions */
# Line 54 | Line 71 | char  *amblist[128];                   /* ambient include/exclude list
71   int  ambincl = -1;                      /* include == 1, exclude == 0 */
72  
73   int  greyscale = 0;                     /* map colors to brightness? */
74 < char  *devname = dev_default;           /* output device name */
74 > char  *dvcname = dev_default;           /* output device name */
75  
76   struct driver  *dev = NULL;             /* driver functions */
77  
78 + char  rifname[128];                     /* rad input file name */
79 +
80   VIEW  oldview;                          /* previous view parameters */
81  
82   PNODE  ptrunk;                          /* the base of our image */
# Line 71 | Line 90 | static char  *reserve_mem = NULL;      /* pre-allocated res
90   #define  CTRL(c)        ((c)-'@')
91  
92  
93 + void
94   quit(code)                      /* quit program */
95   int  code;
96   {
# Line 83 | Line 103 | int  code;
103   }
104  
105  
106 + void
107   devopen(dname)                          /* open device driver */
108   char  *dname;
109   {
# Line 99 | Line 120 | char  *dname;
120                                  error(USER, errmsg);
121                          } else
122                                  return;
102 #ifndef NIX                                                
123                                                  /* not there, try exec */
124          if ((dev = comm_init(dname, id)) == NULL) {
125                  sprintf(errmsg, "cannot start device \"%s\"", dname);
126                  error(USER, errmsg);
127          }
108 #endif
128   }
129  
130  
131 + void
132   devclose()                              /* close our device */
133   {
134          if (dev != NULL)
# Line 117 | Line 137 | devclose()                             /* close our device */
137   }
138  
139  
140 + void
141   printdevices()                          /* print list of output devices */
142   {
143          register int  i;
# Line 126 | Line 147 | printdevices()                         /* print list of output devices */
147   }
148  
149  
150 + void
151   rview()                         /* do a view */
152   {
153          char  buf[32];
154  
155 <        devopen(devname);               /* open device */
155 >        devopen(dvcname);               /* open device */
156          newimage();                     /* start image (calls fillreserves) */
157  
158          for ( ; ; ) {                   /* quit in command() */
# Line 158 | Line 180 | rview()                                /* do a view */
180   }
181  
182  
183 + void
184   fillreserves()                  /* fill memory reserves */
185   {
186          if (reserve_mem != NULL)
187                  return;
188 <        reserve_mem = malloc(RESERVE_AMT);
188 >        reserve_mem = (char *)malloc(RESERVE_AMT);
189   }
190  
191  
192 + void
193   freereserves()                  /* free memory reserves */
194   {
195          if (reserve_mem == NULL)
# Line 175 | Line 199 | freereserves()                 /* free memory reserves */
199   }
200  
201  
202 + void
203   command(prompt)                 /* get/execute command */
204   char  *prompt;
205   {
# Line 208 | Line 233 | again:
233                          goto commerr;
234                  lastview(args);
235                  break;
236 +        case 'V':                               /* save view */
237 +                if (badcom("V"))
238 +                        goto commerr;
239 +                saveview(args);
240 +                break;
241 +        case 'L':                               /* load view */
242 +                if (badcom("L"))
243 +                        goto commerr;
244 +                loadview(args);
245 +                break;
246          case 'e':                               /* exposure */
247                  if (badcom("exposure"))
248                          goto commerr;
249                  getexposure(args);
250                  break;
251          case 's':                               /* set a parameter */
252 <                if (badcom("set"))
252 >                if (badcom("set")) {
253 > #ifdef  SIGTSTP
254 >                        if (!badcom("stop"))
255 >                                goto dostop;
256 > #endif
257                          goto commerr;
258 +                }
259                  setparam(args);
260                  break;
261          case 'n':                               /* new picture */
# Line 249 | Line 289 | again:
289                  break;
290          case 'r':                               /* rotate/repaint */
291                  if (badcom("rotate")) {
292 <                        if (badcom("repaint"))
293 <                                goto commerr;
292 >                        if (badcom("repaint")) {
293 >                                if (badcom("redraw"))
294 >                                        goto commerr;
295 >                                redraw();
296 >                                break;
297 >                        }
298                          getrepaint(args);
299                          break;
300                  }
301                  getrotate(args);
302                  break;
303          case 'p':                               /* pivot view */
304 <                if (badcom("pivot"))
305 <                        goto commerr;
304 >                if (badcom("pivot")) {
305 >                        if (badcom("pause"))
306 >                                goto commerr;
307 >                        goto again;
308 >                }
309                  getpivot(args);
310                  break;
311          case CTRL('R'):                         /* redraw */
# Line 276 | Line 323 | again:
323          case CTRL('C'):                         /* interrupt */
324                  goto again;
325   #ifdef  SIGTSTP
326 <        case CTRL('Z'):                         /* stop */
326 >        case CTRL('Z'):;                        /* stop */
327 > dostop:
328                  devclose();
329                  kill(0, SIGTSTP);
330                  /* pc stops here */
331 <                devopen(devname);
331 >                devopen(dvcname);
332                  redraw();
333                  break;
334   #endif
# Line 300 | Line 348 | commerr:
348   }
349  
350  
351 + void
352   rsample()                       /* sample the image */
353   {
354          int  xsiz, ysiz, y;
# Line 315 | Line 364 | rsample()                      /* sample the image */
364           * difference, we subsample the super-pixels.  The testing process
365           * includes initialization of the next row.
366           */
367 <        xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
368 <        ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
367 >        xsiz = (((long)(pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
368 >        ysiz = (((long)(pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
369          rl = (RECT *)malloc(xsiz*sizeof(RECT));
370          if (rl == NULL)
371                  return;
372          pl = (PNODE **)malloc(xsiz*sizeof(PNODE *));
373          if (pl == NULL) {
374 <                free((char *)rl);
374 >                free((void *)rl);
375                  return;
376          }
377          /*
# Line 383 | Line 432 | rsample()                      /* sample the image */
432                  }
433          }
434   escape:
435 <        free((char *)rl);
436 <        free((char *)pl);
435 >        free((void *)rl);
436 >        free((void *)pl);
437   }
438  
439  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines