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 1.25 by greg, Fri Jul 19 15:22:02 1991 UTC vs.
Revision 2.5 by greg, Wed Jan 15 16:55:21 1992 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1987 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 18 | Line 18 | static char SCCSid[] = "$SunId$ LBL";
18  
19   #include  "rpaint.h"
20  
21 + #include  "resolu.h"
22 +
23   #include  <ctype.h>
24  
25 < #define  CTRL(c)        ('c'-'@')
25 > #define  CTRL(c)        ((c)-'@')
26  
27 + extern char  VersionID[];
28   extern char  *progname;
29 + extern char  *octname;
30  
31  
32   getframe(s)                             /* get a new frame */
# Line 71 | Line 75 | char  *s;
75          sprintf(buf, "view type (%c): ", ourview.type);
76          (*dev->comout)(buf);
77          (*dev->comin)(buf, NULL);
78 <        if (buf[0] == CTRL(C)) return;
78 >        if (buf[0] == CTRL('C')) return;
79          if (buf[0] && buf[0] != ourview.type) {
80                  nv.type = buf[0];
81                  change++;
# Line 81 | Line 85 | char  *s;
85                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);
86          (*dev->comout)(buf);
87          (*dev->comin)(buf, NULL);
88 <        if (buf[0] == CTRL(C)) return;
88 >        if (buf[0] == CTRL('C')) return;
89          if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3)
90                  change++;
91          else
# Line 90 | Line 94 | char  *s;
94                          ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]);
95          (*dev->comout)(buf);
96          (*dev->comin)(buf, NULL);
97 <        if (buf[0] == CTRL(C)) return;
97 >        if (buf[0] == CTRL('C')) return;
98          if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3)
99                  change++;
100          else
# Line 99 | Line 103 | char  *s;
103                          ourview.vup[0], ourview.vup[1], ourview.vup[2]);
104          (*dev->comout)(buf);
105          (*dev->comin)(buf, NULL);
106 <        if (buf[0] == CTRL(C)) return;
106 >        if (buf[0] == CTRL('C')) return;
107          if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3)
108                  change++;
109          else
# Line 108 | Line 112 | char  *s;
112                          ourview.horiz, ourview.vert);
113          (*dev->comout)(buf);
114          (*dev->comin)(buf, NULL);
115 <        if (buf[0] == CTRL(C)) return;
115 >        if (buf[0] == CTRL('C')) return;
116          if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2)
117                  change++;
118          else {
# Line 118 | Line 122 | char  *s;
122                          ourview.hoff, ourview.voff);
123          (*dev->comout)(buf);
124          (*dev->comin)(buf, NULL);
125 <        if (buf[0] == CTRL(C)) return;
125 >        if (buf[0] == CTRL('C')) return;
126          if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2)
127                  change++;
128          else {
# Line 140 | Line 144 | char  *s;
144          if (sscanf(s, "%s", buf) == 1) {        /* get parameters from a file */
145                  copystruct(&nv, &stdview);
146                  if ((fname = getpath(buf, NULL, 0)) == NULL ||
147 <                                (success = viewfile(fname, &nv, 0, 0)) == -1) {
147 >                                (success = viewfile(fname, &nv, NULL)) == -1) {
148                          sprintf(errmsg, "cannot open \"%s\"", buf);
149                          error(COMMAND, errmsg);
150                          return;
# Line 242 | Line 246 | register char  *s;
246   getexposure(s)                          /* get new exposure */
247   char  *s;
248   {
245        double  atof(), pow(), fabs();
249          char  buf[128];
250          register char  *cp;
251          register PNODE  *p;
# Line 319 | Line 322 | register union {int i; double d; COLOR C;}  *ptr;
322                          (*dev->comout)(buf);
323                          (*dev->comin)(buf, NULL);
324                          if (sscanf(buf, "%d", &i0) != 1)
325 <                                break;
325 >                                return(0);
326                  }
327                  ptr->i = i0;
328 <                break;
328 >                return(1);
329          case 'r':                       /* real */
330                  if (sscanf(str, "%lf", &d0) != 1) {
331                          (*dev->comout)(dsc);
# Line 330 | Line 333 | register union {int i; double d; COLOR C;}  *ptr;
333                          (*dev->comout)(buf);
334                          (*dev->comin)(buf, NULL);
335                          if (sscanf(buf, "%lf", &d0) != 1)
336 <                                break;
336 >                                return(0);
337                  }
338                  ptr->d = d0;
339 <                break;
339 >                return(1);
340          case 'b':                       /* boolean */
341                  if (sscanf(str, "%1s", buf) != 1) {
342                          (*dev->comout)(dsc);
343 <                        sprintf(buf, " (%c): ", ptr->i ? 'y' : 'n');
343 >                        sprintf(buf, "? (%c): ", ptr->i ? 'y' : 'n');
344                          (*dev->comout)(buf);
345                          (*dev->comin)(buf, NULL);
346                          if (buf[0] == '\0' ||
347                                          index("yY+1tTnN-0fF", buf[0]) == NULL)
348 <                                break;
348 >                                return(0);
349                  }
350                  ptr->i = index("yY+1tT", buf[0]) != NULL;
351 <                break;
351 >                return(1);
352          case 'C':                       /* color */
353                  if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) {
354                          (*dev->comout)(dsc);
# Line 356 | Line 359 | register union {int i; double d; COLOR C;}  *ptr;
359                          (*dev->comout)(buf);
360                          (*dev->comin)(buf, NULL);
361                          if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3)
362 <                                break;
362 >                                return(0);
363                  }
364                  setcolor(ptr->C, d0, d1, d2);
365 <                break;
365 >                return(1);
366          }
367   }
368  
# Line 382 | Line 385 | register char  *s;
385          extern int  ambssamp;
386          extern int  ambounce;
387          extern int  directinvis;
388 +        extern double  srcsizerat;
389          extern int  do_irrad;
390 +        extern double  specjitter;
391 +        extern double  specthresh;
392          char  buf[128];
393          
394          if (s[0] == '\0') {
395                  (*dev->comout)(
396 <                        "aa ab ad ar as av b dc di dj dt i lr lw sp st: ");
396 >                "aa ab ad ar as av b dc di dj ds dt i lr lw ps pt sj st: ");
397                  (*dev->comin)(buf, NULL);
398                  s = buf;
399          }
# Line 419 | Line 425 | register char  *s;
425                          getparam(s+2, "direct invisibility",
426                                          'b', &directinvis);
427                          break;
428 +                case 's':                       /* sampling */
429 +                        getparam(s+2, "direct sampling", 'r', &srcsizerat);
430 +                        break;
431                  default:
432                          goto badparam;
433                  }
# Line 447 | Line 456 | register char  *s;
456                          getparam(s+2, "ambient bounces", 'i', &ambounce);
457                          break;
458                  case 'r':
459 <                        getparam(s+2, "ambient resolution", 'i', &ambres);
460 <                        minarad = ambres > 0 ? thescene.cusize/ambres : 0.0;
459 >                        if (getparam(s+2, "ambient resolution", 'i', &ambres))
460 >                                minarad = ambres > 0 ?
461 >                                                thescene.cusize/ambres : 0.0;
462                          break;
463                  default:
464                          goto badparam;
465                  }
466                  break;
467 <        case 's':                       /* sample */
467 >        case 'p':                       /* pixel */
468                  switch (s[1]) {
469 <                case 'p':                       /* pixel */
470 <                        getparam(s+2, "sample pixel", 'i', &psample);
471 <                        pdepth = 0;
469 >                case 's':                       /* sample */
470 >                        if (getparam(s+2, "pixel sample", 'i', &psample))
471 >                                pdepth = 0;
472                          break;
473                  case 't':                       /* threshold */
474 <                        getparam(s+2, "sample threshold", 'r', &maxdiff);
475 <                        pdepth = 0;
474 >                        if (getparam(s+2, "pixel threshold", 'r', &maxdiff))
475 >                                pdepth = 0;
476                          break;
477                  default:
478                          goto badparam;
479                  }
480                  break;
481 +        case 's':                       /* specular */
482 +                switch (s[1]) {
483 +                case 'j':                       /* jitter */
484 +                        getparam(s+2, "specular jitter", 'r', &specjitter);
485 +                        break;
486 +                case 't':                       /* threshold */
487 +                        getparam(s+2, "specular threshold", 'r', &specthresh);
488 +                        break;
489 +                default:
490 +                        goto badparam;
491 +                }
492 +                break;
493          case '\0':                      /* nothing */
494                  break;
495          default:;
496   badparam:
497 +                *sskip(s) = '\0';
498                  sprintf(errmsg, "%s: unknown variable", s);
499                  error(COMMAND, errmsg);
500                  break;
# Line 528 | Line 551 | char  *s;
551                          (*dev->comout)(buf);
552                  }
553                  (*dev->comin)(buf, NULL);
554 <                sprintf(buf, "with value (%.6g %.6g %.6g)",
554 >                sprintf(buf, "value (%.5g %.5g %.5g) (%.1fL)",
555                                  colval(thisray.rcol,RED),
556                                  colval(thisray.rcol,GRN),
557 <                                colval(thisray.rcol,BLU));
557 >                                colval(thisray.rcol,BLU),
558 >                                luminance(thisray.rcol));
559                  (*dev->comout)(buf);
560          }
561          (*dev->comin)(buf, NULL);
# Line 563 | Line 587 | char  *s;
587                                                  /* write header */
588          fputs(progname, fp);
589          fprintview(&ourview, fp);
590 <        putc('\n', fp);
590 >        if (octname != NULL)
591 >                fprintf(fp, " %s\n", octname);
592 >        else
593 >                putc('\n', fp);
594 >        fprintf(fp, "SOFTWARE= %s\n", VersionID);
595          if (exposure != 1.0)
596                  fputexpos(exposure, fp);
597          if (dev->pixaspect != 1.0)
598                  fputaspect(dev->pixaspect, fp);
599          fputformat(COLRFMT, fp);
600          putc('\n', fp);
601 <        fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp);
601 >        fprtresolu(hresolu, vresolu, fp);
602  
603          scanline = (COLR *)malloc(hresolu*sizeof(COLR));
604 <        if (scanline == NULL)
605 <                error(SYSTEM, "out of memory in writepict");
604 >        if (scanline == NULL) {
605 >                error(COMMAND, "not enough memory!");
606 >                fclose(fp);
607 >                unlink(fname);
608 >                return;
609 >        }
610          for (y = vresolu-1; y >= 0; y--) {
611                  getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu);
612                  if (fwritecolrs(scanline, hresolu, fp) < 0)
613                          break;
614          }
615 +        free((char *)scanline);
616          if (fclose(fp) < 0)
617                  error(COMMAND, "write error");
585        free((char *)scanline);
618   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines