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

Comparing ray/src/rt/rv2.c (file contents):
Revision 2.1 by greg, Tue Nov 12 17:09:52 1991 UTC vs.
Revision 2.16 by greg, Wed Jun 2 21:04:02 1993 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1993 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 22 | Line 22 | static char SCCSid[] = "$SunId$ LBL";
22  
23   #include  <ctype.h>
24  
25 < #define  CTRL(c)        ('c'-'@')
25 > #define  CTRL(c)        ((c)-'@')
26  
27 + #ifdef  SMLFLT
28 + #define  sscanvec(s,v)  (sscanf(s,"%f %f %f",v,v+1,v+2)==3)
29 + #else
30 + #define  sscanvec(s,v)  (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3)
31 + #endif
32 +
33 +
34   extern char  VersionID[];
35   extern char  *progname;
36   extern char  *octname;
# Line 58 | Line 65 | char  *s;
65          int  change = 0;
66          VIEW  nv;
67  
68 +        while (isspace(*s))
69 +                s++;
70 +        if (*s == '-') {                        /* command line parameters */
71 +                copystruct(&nv, &ourview);
72 +                if (sscanview(&nv, s))
73 +                        newview(&nv);
74 +                else
75 +                        error(COMMAND, "bad view option(s)");
76 +                return;
77 +        }
78          if (sscanf(s, "%s", buf) == 1) {        /* write parameters to a file */
79                  if ((fname = getpath(buf, NULL, 0)) == NULL ||
80                                  (fp = fopen(fname, "a")) == NULL) {
# Line 75 | Line 92 | char  *s;
92          sprintf(buf, "view type (%c): ", ourview.type);
93          (*dev->comout)(buf);
94          (*dev->comin)(buf, NULL);
95 <        if (buf[0] == CTRL(C)) return;
95 >        if (buf[0] == CTRL('C')) return;
96          if (buf[0] && buf[0] != ourview.type) {
97                  nv.type = buf[0];
98                  change++;
# Line 85 | Line 102 | char  *s;
102                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);
103          (*dev->comout)(buf);
104          (*dev->comin)(buf, NULL);
105 <        if (buf[0] == CTRL(C)) return;
106 <        if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3)
105 >        if (buf[0] == CTRL('C')) return;
106 >        if (sscanvec(buf, nv.vp))
107                  change++;
108          else
109                  VCOPY(nv.vp, ourview.vp);
# Line 94 | Line 111 | char  *s;
111                          ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]);
112          (*dev->comout)(buf);
113          (*dev->comin)(buf, NULL);
114 <        if (buf[0] == CTRL(C)) return;
115 <        if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3)
114 >        if (buf[0] == CTRL('C')) return;
115 >        if (sscanvec(buf, nv.vdir))
116                  change++;
117          else
118                  VCOPY(nv.vdir, ourview.vdir);
# Line 103 | Line 120 | char  *s;
120                          ourview.vup[0], ourview.vup[1], ourview.vup[2]);
121          (*dev->comout)(buf);
122          (*dev->comin)(buf, NULL);
123 <        if (buf[0] == CTRL(C)) return;
124 <        if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3)
123 >        if (buf[0] == CTRL('C')) return;
124 >        if (sscanvec(buf, nv.vup))
125                  change++;
126          else
127                  VCOPY(nv.vup, ourview.vup);
# Line 112 | Line 129 | char  *s;
129                          ourview.horiz, ourview.vert);
130          (*dev->comout)(buf);
131          (*dev->comin)(buf, NULL);
132 <        if (buf[0] == CTRL(C)) return;
132 >        if (buf[0] == CTRL('C')) return;
133          if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2)
134                  change++;
135          else {
# Line 122 | Line 139 | char  *s;
139                          ourview.hoff, ourview.voff);
140          (*dev->comout)(buf);
141          (*dev->comin)(buf, NULL);
142 <        if (buf[0] == CTRL(C)) return;
142 >        if (buf[0] == CTRL('C')) return;
143          if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2)
144                  change++;
145          else {
# Line 169 | Line 186 | char  *s;
186   getaim(s)                               /* aim camera */
187   char  *s;
188   {
172        extern double  tan(), atan();
189          double  zfact;
190          VIEW  nv;
191  
# Line 200 | Line 216 | char  *s;
216   getrotate(s)                            /* rotate camera */
217   char  *s;
218   {
203        extern double  normalize(), tan(), atan();
219          VIEW  nv;
220          FVECT  v1;
221          double  angle, elev, zfact;
# Line 246 | Line 261 | register char  *s;
261   getexposure(s)                          /* get new exposure */
262   char  *s;
263   {
249        double  atof(), pow(), fabs();
264          char  buf[128];
265          register char  *cp;
252        register PNODE  *p;
266          RECT  r;
267          int  x, y;
268 <        double  e;
269 <
268 >        register PNODE  *p = &ptrunk;
269 >        int  adapt = 0;
270 >        double  e = 1.0;
271 > start:
272          for (cp = s; isspace(*cp); cp++)
273                  ;
274 +        if (*cp == '@') {
275 +                adapt++;
276 +                goto start;
277 +        }
278          if (*cp == '\0') {              /* normalize to point */
279                  if (dev->getcur == NULL)
280                          return;
# Line 265 | Line 284 | char  *s;
284                  r.l = r.d = 0;
285                  r.r = hresolu; r.u = vresolu;
286                  p = findrect(x, y, &ptrunk, &r, -1);
268                e = 1.0;
287          } else {
288                  if (*cp == '=') {       /* absolute setting */
289                          p = NULL;
# Line 273 | Line 291 | char  *s;
291                          for (cp++; isspace(*cp); cp++)
292                                  ;
293                          if (*cp == '\0') {      /* interactive */
294 <                                sprintf(buf, "exposure (%lf): ", exposure);
294 >                                sprintf(buf, "exposure (%f): ", exposure);
295                                  (*dev->comout)(buf);
296                                  (*dev->comin)(buf, NULL);
297                                  for (cp = buf; isspace(*cp); cp++)
# Line 281 | Line 299 | char  *s;
299                                  if (*cp == '\0')
300                                          return;
301                          }
284                } else {                /* normalize to average */
285                        p = &ptrunk;
286                        e = 1.0;
302                  }
303                  if (*cp == '+' || *cp == '-')   /* f-stops */
304                          e *= pow(2.0, atof(cp));
# Line 291 | Line 306 | char  *s;
306                          e *= atof(cp);
307          }
308          if (p != NULL) {                /* relative setting */
309 <                if (bright(p->v) <= FTINY) {
309 >                if (bright(p->v) < 1e-15) {
310                          error(COMMAND, "cannot normalize to zero");
311                          return;
312                  }
313 <                e *= 0.5 / bright(p->v);
313 >                if (adapt)
314 >                        e *= 106./pow(1.219+pow(luminance(p->v)/exposure,.4),2.5)/exposure;
315 >                else
316 >                        e *= 0.5 / bright(p->v);
317          }
318          if (e <= FTINY || fabs(1.0 - e) <= FTINY)
319                  return;
# Line 341 | Line 359 | register union {int i; double d; COLOR C;}  *ptr;
359          case 'b':                       /* boolean */
360                  if (sscanf(str, "%1s", buf) != 1) {
361                          (*dev->comout)(dsc);
362 <                        sprintf(buf, " (%c): ", ptr->i ? 'y' : 'n');
362 >                        sprintf(buf, "? (%c): ", ptr->i ? 'y' : 'n');
363                          (*dev->comout)(buf);
364                          (*dev->comin)(buf, NULL);
365                          if (buf[0] == '\0' ||
# Line 380 | Line 398 | register char  *s;
398          extern double  shadcert;
399          extern COLOR  ambval;
400          extern double  ambacc;
383        extern double  minarad;
401          extern int  ambres;
402          extern int  ambdiv;
403          extern int  ambssamp;
404          extern int  ambounce;
405 <        extern int  directinvis;
405 >        extern int  directvis;
406          extern double  srcsizerat;
407          extern int  do_irrad;
408 +        extern double  specjitter;
409 +        extern double  specthresh;
410          char  buf[128];
411          
412          if (s[0] == '\0') {
413                  (*dev->comout)(
414 <                        "aa ab ad ar as av b dc di dj ds dt i lr lw sp st: ");
414 >                "aa ab ad ar as av b dc di dj ds dt i lr lw ps pt sj st: ");
415                  (*dev->comin)(buf, NULL);
416                  s = buf;
417          }
# Line 420 | Line 439 | register char  *s;
439                  case 't':                       /* threshold */
440                          getparam(s+2, "direct threshold", 'r', &shadthresh);
441                          break;
442 <                case 'i':                       /* invisibility */
443 <                        getparam(s+2, "direct invisibility",
444 <                                        'b', &directinvis);
442 >                case 'v':                       /* visibility */
443 >                        getparam(s+2, "direct visibility",
444 >                                        'b', &directvis);
445                          break;
446                  case 's':                       /* sampling */
447                          getparam(s+2, "direct sampling", 'r', &srcsizerat);
# Line 440 | Line 459 | register char  *s;
459          case 'a':                       /* ambient */
460                  switch (s[1]) {
461                  case 'v':                       /* value */
462 <                        getparam(s+2, "ambient value", 'C', ambval);
462 >                        getparam(s+2, "ambient value", 'C', (COLOR *)ambval);
463                          break;
464                  case 'a':                       /* accuracy */
465                          getparam(s+2, "ambient accuracy", 'r', &ambacc);
# Line 456 | Line 475 | register char  *s;
475                          break;
476                  case 'r':
477                          if (getparam(s+2, "ambient resolution", 'i', &ambres))
478 <                                minarad = ambres > 0 ?
460 <                                                thescene.cusize/ambres : 0.0;
478 >                                setambres(ambres);
479                          break;
480                  default:
481                          goto badparam;
482                  }
483                  break;
484 <        case 's':                       /* sample */
484 >        case 'p':                       /* pixel */
485                  switch (s[1]) {
486 <                case 'p':                       /* pixel */
487 <                        if (getparam(s+2, "sample pixel", 'i', &psample))
486 >                case 's':                       /* sample */
487 >                        if (getparam(s+2, "pixel sample", 'i', &psample))
488                                  pdepth = 0;
489                          break;
490                  case 't':                       /* threshold */
491 <                        if (getparam(s+2, "sample threshold", 'r', &maxdiff))
491 >                        if (getparam(s+2, "pixel threshold", 'r', &maxdiff))
492                                  pdepth = 0;
493                          break;
494                  default:
495                          goto badparam;
496                  }
497                  break;
498 +        case 's':                       /* specular */
499 +                switch (s[1]) {
500 +                case 'j':                       /* jitter */
501 +                        getparam(s+2, "specular jitter", 'r', &specjitter);
502 +                        break;
503 +                case 't':                       /* threshold */
504 +                        getparam(s+2, "specular threshold", 'r', &specthresh);
505 +                        break;
506 +                default:
507 +                        goto badparam;
508 +                }
509 +                break;
510          case '\0':                      /* nothing */
511                  break;
512          default:;
# Line 496 | Line 526 | char  *s;
526          int  x, y;
527          RAY  thisray;
528  
529 <        if (sscanf(s, "%lf %lf %lf %lf %lf %lf",
530 <                &thisray.rorg[0], &thisray.rorg[1], &thisray.rorg[2],
501 <                &thisray.rdir[0], &thisray.rdir[1], &thisray.rdir[2]) != 6) {
529 >        if (!sscanvec(s, thisray.rorg) ||
530 >                        !sscanvec(sskip(sskip(sskip(s))), thisray.rdir)) {
531  
532                  if (dev->getcur == NULL)
533                          return;
# Line 568 | Line 597 | char  *s;
597                  error(COMMAND, errmsg);
598                  return;
599          }
600 + #ifdef MSDOS
601 +        setmode(fileno(fp), O_BINARY);
602 + #endif
603          (*dev->comout)("writing \"");
604          (*dev->comout)(fname);
605          (*dev->comout)("\"...\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines