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.12 by greg, Thu Oct 15 21:13:14 1992 UTC vs.
Revision 2.43 by schorsch, Tue Mar 30 16:13:01 2004 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   *  rv2.c - command routines used in tracing a view.
6   *
7 < *     3/24/87
7 > *  External symbols declared in rpaint.h
8   */
9  
10 < #include  "ray.h"
10 > #include "copyright.h"
11  
12 < #include  "octree.h"
12 > #include  <ctype.h>
13 > #include  <string.h>
14  
15 + #include  "platform.h"
16 + #include  "ray.h"
17 + #include  "ambient.h"
18   #include  "otypes.h"
18
19   #include  "rpaint.h"
20  
21 < #include  "resolu.h"
21 > extern int  psample;                    /* pixel sample size */
22 > extern double  maxdiff;                 /* max. sample difference */
23  
23 #include  <ctype.h>
24
24   #define  CTRL(c)        ((c)-'@')
25  
26   #ifdef  SMLFLT
# Line 30 | Line 29 | static char SCCSid[] = "$SunId$ LBL";
29   #define  sscanvec(s,v)  (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3)
30   #endif
31  
32 + extern char  rifname[128];              /* rad input file name */
33  
34 extern char  VersionID[];
34   extern char  *progname;
35   extern char  *octname;
36  
37  
38 < getframe(s)                             /* get a new frame */
39 < char  *s;
38 > extern void
39 > getframe(                               /* get a new frame */
40 >        char  *s
41 > )
42   {
43          if (getrect(s, &pframe) < 0)
44                  return;
# Line 45 | Line 46 | char  *s;
46   }
47  
48  
49 < getrepaint(s)                           /* get area and repaint */
50 < char  *s;
49 > extern void
50 > getrepaint(                             /* get area and repaint */
51 >        char  *s
52 > )
53   {
54          RECT  box;
55  
# Line 56 | Line 59 | char  *s;
59   }
60  
61  
62 < getview(s)                              /* get/show view parameters */
63 < char  *s;
62 > extern void
63 > getview(                                /* get/show view parameters */
64 >        char  *s
65 > )
66   {
67          FILE  *fp;
68          char  buf[128];
# Line 68 | Line 73 | char  *s;
73          while (isspace(*s))
74                  s++;
75          if (*s == '-') {                        /* command line parameters */
76 <                copystruct(&nv, &ourview);
76 >                nv = ourview;
77                  if (sscanview(&nv, s))
78                          newview(&nv);
79                  else
# Line 85 | Line 90 | char  *s;
90                  fputs(progname, fp);
91                  fprintview(&ourview, fp);
92                  fputs(sskip(s), fp);
93 <                fputs("\n", fp);
93 >                putc('\n', fp);
94                  fclose(fp);
95                  return;
96          }
# Line 135 | Line 140 | char  *s;
140          else {
141                  nv.horiz = ourview.horiz; nv.vert = ourview.vert;
142          }
143 +        sprintf(buf, "fore and aft clipping plane (%.6g %.6g): ",
144 +                        ourview.vfore, ourview.vaft);
145 +        (*dev->comout)(buf);
146 +        (*dev->comin)(buf, NULL);
147 +        if (buf[0] == CTRL('C')) return;
148 +        if (sscanf(buf, "%lf %lf", &nv.vfore, &nv.vaft) == 2)
149 +                change++;
150 +        else {
151 +                nv.vfore = ourview.vfore; nv.vaft = ourview.vaft;
152 +        }
153          sprintf(buf, "view shift and lift (%.6g %.6g): ",
154                          ourview.hoff, ourview.voff);
155          (*dev->comout)(buf);
# Line 150 | Line 165 | char  *s;
165   }
166  
167  
168 < lastview(s)                             /* return to a previous view */
169 < char  *s;
168 > extern void
169 > lastview(                               /* return to a previous view */
170 >        char  *s
171 > )
172   {
173          char  buf[128];
174          char  *fname;
# Line 159 | Line 176 | char  *s;
176          VIEW  nv;
177  
178          if (sscanf(s, "%s", buf) == 1) {        /* get parameters from a file */
179 <                copystruct(&nv, &stdview);
180 <                if ((fname = getpath(buf, NULL, 0)) == NULL ||
179 >                nv = stdview;
180 >                if ((fname = getpath(buf, "", R_OK)) == NULL ||
181                                  (success = viewfile(fname, &nv, NULL)) == -1) {
182                          sprintf(errmsg, "cannot open \"%s\"", buf);
183                          error(COMMAND, errmsg);
# Line 176 | Line 193 | char  *s;
193                  error(COMMAND, "no previous view");
194                  return;
195          }
196 <        copystruct(&nv, &ourview);
197 <        copystruct(&ourview, &oldview);
198 <        copystruct(&oldview, &nv);
196 >        nv = ourview;
197 >        ourview = oldview;
198 >        oldview = nv;
199          newimage();
200   }
201  
202  
203 < getaim(s)                               /* aim camera */
204 < char  *s;
203 > extern void
204 > saveview(                               /* save view to rad file */
205 >        char  *s
206 > )
207   {
208 +        char  view[64];
209 +        char  *fname;
210 +        FILE  *fp;
211 +
212 +        if (*atos(view, sizeof(view), s)) {
213 +                if (isint(view)) {
214 +                        error(COMMAND, "cannot write view by number");
215 +                        return;
216 +                }
217 +                s = sskip(s);
218 +        }
219 +        while (isspace(*s))
220 +                s++;
221 +        if (*s)
222 +                atos(rifname, sizeof(rifname), s);
223 +        else if (rifname[0] == '\0') {
224 +                error(COMMAND, "no previous rad file");
225 +                return;
226 +        }
227 +        if ((fname = getpath(rifname, NULL, 0)) == NULL ||
228 +                        (fp = fopen(fname, "a")) == NULL) {
229 +                sprintf(errmsg, "cannot open \"%s\"", rifname);
230 +                error(COMMAND, errmsg);
231 +                return;
232 +        }
233 +        fputs("view= ", fp);
234 +        fputs(view, fp);
235 +        fprintview(&ourview, fp);
236 +        putc('\n', fp);
237 +        fclose(fp);
238 + }
239 +
240 +
241 + extern void
242 + loadview(                               /* load view from rad file */
243 +        char  *s
244 + )
245 + {
246 +        char  buf[512];
247 +        char  *fname;
248 +        FILE  *fp;
249 +        VIEW  nv;
250 +
251 +        strcpy(buf, "rad -n -s -V -v ");
252 +        if (sscanf(s, "%s", buf+strlen(buf)) == 1)
253 +                s = sskip(s);
254 +        else
255 +                strcat(buf, "1");
256 +        if (*s)
257 +                atos(rifname, sizeof(rifname), s);
258 +        else if (rifname[0] == '\0') {
259 +                error(COMMAND, "no previous rad file");
260 +                return;
261 +        }
262 +        if ((fname = getpath(rifname, "", R_OK)) == NULL) {
263 +                sprintf(errmsg, "cannot access \"%s\"", rifname);
264 +                error(COMMAND, errmsg);
265 +                return;
266 +        }
267 +        sprintf(buf+strlen(buf), " %s", fname);
268 +        if ((fp = popen(buf, "r")) == NULL) {
269 +                error(COMMAND, "cannot run rad");
270 +                return;
271 +        }
272 +        buf[0] = '\0';
273 +        fgets(buf, sizeof(buf), fp);
274 +        pclose(fp);
275 +        nv = stdview;
276 +        if (!sscanview(&nv, buf)) {
277 +                error(COMMAND, "rad error -- no such view?");
278 +                return;
279 +        }
280 +        newview(&nv);
281 + }
282 +
283 +
284 + extern void
285 + getaim(                         /* aim camera */
286 +        char  *s
287 + )
288 + {
289          double  zfact;
290          VIEW  nv;
291  
# Line 194 | Line 294 | char  *s;
294          nv.type = ourview.type;
295          VCOPY(nv.vp, ourview.vp);
296          VCOPY(nv.vup, ourview.vup);
197        nv.hoff = ourview.hoff; nv.voff = ourview.voff;
297          nv.horiz = ourview.horiz; nv.vert = ourview.vert;
298 +        nv.vfore = ourview.vfore; nv.vaft = ourview.vaft;
299 +        nv.hoff = ourview.hoff; nv.voff = ourview.voff;
300          zoomview(&nv, zfact);
301          newview(&nv);
302   }
303  
304  
305 < getmove(s)                              /* move camera */
306 < char  *s;
305 > extern void
306 > getmove(                                /* move camera */
307 >        char  *s
308 > )
309   {
310          FVECT  vc;
311          double  mag;
# Line 213 | Line 316 | char  *s;
316   }
317  
318  
319 < getrotate(s)                            /* rotate camera */
320 < char  *s;
319 > extern void
320 > getrotate(                              /* rotate camera */
321 >        char  *s
322 > )
323   {
324          VIEW  nv;
325          FVECT  v1;
# Line 229 | Line 334 | char  *s;
334          VCOPY(nv.vp, ourview.vp);
335          VCOPY(nv.vup, ourview.vup);
336          nv.hoff = ourview.hoff; nv.voff = ourview.voff;
337 +        nv.vfore = ourview.vfore; nv.vaft = ourview.vaft;
338          spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.));
339          if (elev != 0.0) {
340                  fcross(v1, nv.vdir, ourview.vup);
# Line 241 | Line 347 | char  *s;
347   }
348  
349  
350 < getpivot(s)                             /* pivot viewpoint */
351 < register char  *s;
350 > extern void
351 > getpivot(                               /* pivot viewpoint */
352 >        register char  *s
353 > )
354   {
355          FVECT  vc;
356          double  angle, elev, mag;
# Line 252 | Line 360 | register char  *s;
360                  error(COMMAND, "missing angle");
361                  return;
362          }
363 <        if (getinterest(sskip(sskip(s)), 0, vc, &mag) < 0)
363 >        if (getinterest(sskip2(s,2), 0, vc, &mag) < 0)
364                  return;
365          moveview(angle, elev, mag, vc);
366   }
367  
368  
369 < getexposure(s)                          /* get new exposure */
370 < char  *s;
369 > extern void
370 > getexposure(                            /* get new exposure */
371 >        char  *s
372 > )
373   {
374          char  buf[128];
375          register char  *cp;
266        register PNODE  *p;
376          RECT  r;
377          int  x, y;
378 <        double  e;
378 >        register PNODE  *p = &ptrunk;
379 >        int  adapt = 0;
380 >        double  e = 1.0;
381  
382          for (cp = s; isspace(*cp); cp++)
383                  ;
384 +        if (*cp == '@') {
385 +                adapt++;
386 +                while (isspace(*++cp))
387 +                        ;
388 +        }
389          if (*cp == '\0') {              /* normalize to point */
390                  if (dev->getcur == NULL)
391                          return;
# Line 279 | Line 395 | char  *s;
395                  r.l = r.d = 0;
396                  r.r = hresolu; r.u = vresolu;
397                  p = findrect(x, y, &ptrunk, &r, -1);
282                e = 1.0;
398          } else {
399                  if (*cp == '=') {       /* absolute setting */
400                          p = NULL;
# Line 287 | Line 402 | char  *s;
402                          for (cp++; isspace(*cp); cp++)
403                                  ;
404                          if (*cp == '\0') {      /* interactive */
405 <                                sprintf(buf, "exposure (%lf): ", exposure);
405 >                                sprintf(buf, "exposure (%f): ", exposure);
406                                  (*dev->comout)(buf);
407                                  (*dev->comin)(buf, NULL);
408                                  for (cp = buf; isspace(*cp); cp++)
# Line 295 | Line 410 | char  *s;
410                                  if (*cp == '\0')
411                                          return;
412                          }
298                } else {                /* normalize to average */
299                        p = &ptrunk;
300                        e = 1.0;
413                  }
414                  if (*cp == '+' || *cp == '-')   /* f-stops */
415                          e *= pow(2.0, atof(cp));
# Line 305 | Line 417 | char  *s;
417                          e *= atof(cp);
418          }
419          if (p != NULL) {                /* relative setting */
420 <                if (bright(p->v) < 1e-25) {
420 >                if (bright(p->v) < 1e-15) {
421                          error(COMMAND, "cannot normalize to zero");
422                          return;
423                  }
424 <                e *= 0.5 / bright(p->v);
424 >                if (adapt)
425 >                        e *= 106./pow(1.219+pow(luminance(p->v)/exposure,.4),2.5)/exposure;
426 >                else
427 >                        e *= 0.5 / bright(p->v);
428          }
429          if (e <= FTINY || fabs(1.0 - e) <= FTINY)
430                  return;
# Line 318 | Line 433 | char  *s;
433          redraw();
434   }
435  
436 + typedef union {int i; double d; COLOR C;}       *MyUptr;
437  
438 < getparam(str, dsc, typ, ptr)            /* get variable from user */
439 < char  *str, *dsc;
440 < int  typ;
441 < register union {int i; double d; COLOR C;}  *ptr;
438 > extern int
439 > getparam(               /* get variable from user */
440 >        char  *str,
441 >        char  *dsc,
442 >        int  typ,
443 >        void  *p
444 > )
445   {
446 <        extern char  *index();
446 >        register MyUptr  ptr = (MyUptr)p;
447          int  i0;
448          double  d0, d1, d2;
449          char  buf[48];
# Line 359 | Line 478 | register union {int i; double d; COLOR C;}  *ptr;
478                          (*dev->comout)(buf);
479                          (*dev->comin)(buf, NULL);
480                          if (buf[0] == '\0' ||
481 <                                        index("yY+1tTnN-0fF", buf[0]) == NULL)
481 >                                        strchr("yY+1tTnN-0fF", buf[0]) == NULL)
482                                  return(0);
483                  }
484 <                ptr->i = index("yY+1tT", buf[0]) != NULL;
484 >                ptr->i = strchr("yY+1tT", buf[0]) != NULL;
485                  return(1);
486          case 'C':                       /* color */
487                  if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) {
# Line 379 | Line 498 | register union {int i; double d; COLOR C;}  *ptr;
498                  setcolor(ptr->C, d0, d1, d2);
499                  return(1);
500          }
501 +        return 0; /* nothing matched */
502   }
503  
504  
505 < setparam(s)                             /* get/set program parameter */
506 < register char  *s;
505 > extern void
506 > setparam(                               /* get/set program parameter */
507 >        register char  *s
508 > )
509   {
388        extern int  psample;
389        extern double  maxdiff;
390        extern double  minweight;
391        extern int  maxdepth;
392        extern double  dstrsrc;
393        extern double  shadthresh;
394        extern double  shadcert;
395        extern COLOR  ambval;
396        extern double  ambacc;
397        extern int  ambres;
398        extern int  ambdiv;
399        extern int  ambssamp;
400        extern int  ambounce;
401        extern int  directinvis;
402        extern double  srcsizerat;
403        extern int  do_irrad;
404        extern double  specjitter;
405        extern double  specthresh;
510          char  buf[128];
511          
512          if (s[0] == '\0') {
513                  (*dev->comout)(
514 <                "aa ab ad ar as av b dc di dj ds dt i lr lw ps pt sj st: ");
514 >                "aa ab ad ar as av aw b dc dv dj ds dt i lr lw me ma mg ms ps pt sj st bv: ");
515                  (*dev->comin)(buf, NULL);
516                  s = buf;
517          }
# Line 415 | Line 519 | register char  *s;
519          case 'l':                       /* limit */
520                  switch (s[1]) {
521                  case 'w':                       /* weight */
522 <                        getparam(s+2, "limit weight", 'r', &minweight);
522 >                        getparam(s+2, "limit weight", 'r',
523 >                                        (void *)&minweight);
524                          break;
525                  case 'r':                       /* reflection */
526 <                        getparam(s+2, "limit reflection", 'i', &maxdepth);
526 >                        getparam(s+2, "limit reflection", 'i',
527 >                                        (void *)&maxdepth);
528                          break;
529                  default:
530                          goto badparam;
# Line 427 | Line 533 | register char  *s;
533          case 'd':                       /* direct */
534                  switch (s[1]) {
535                  case 'j':                       /* jitter */
536 <                        getparam(s+2, "direct jitter", 'r', &dstrsrc);
536 >                        getparam(s+2, "direct jitter", 'r',
537 >                                        (void *)&dstrsrc);
538                          break;
539                  case 'c':                       /* certainty */
540 <                        getparam(s+2, "direct certainty", 'r', &shadcert);
540 >                        getparam(s+2, "direct certainty", 'r',
541 >                                        (void *)&shadcert);
542                          break;
543                  case 't':                       /* threshold */
544 <                        getparam(s+2, "direct threshold", 'r', &shadthresh);
544 >                        getparam(s+2, "direct threshold", 'r',
545 >                                        (void *)&shadthresh);
546                          break;
547 <                case 'i':                       /* invisibility */
548 <                        getparam(s+2, "direct invisibility",
549 <                                        'b', &directinvis);
547 >                case 'v':                       /* visibility */
548 >                        getparam(s+2, "direct visibility", 'b',
549 >                                        (void *)&directvis);
550                          break;
551                  case 's':                       /* sampling */
552 <                        getparam(s+2, "direct sampling", 'r', &srcsizerat);
552 >                        getparam(s+2, "direct sampling", 'r',
553 >                                        (void *)&srcsizerat);
554                          break;
555                  default:
556                          goto badparam;
557                  }
558                  break;
559 <        case 'b':                       /* black and white */
560 <                getparam(s+1, "black and white", 'b', &greyscale);
559 >        case 'b':                       /* back faces or black and white */
560 >                switch (s[1]) {
561 >                case 'v':                       /* back face visibility */
562 >                        getparam(s+2, "back face visibility", 'b',
563 >                                        (void *)&backvis);
564 >                        break;
565 >                case '\0':                      /* black and white */
566 >                case ' ':
567 >                case 'y': case 'Y': case 't': case 'T': case '1': case '+':
568 >                case 'n': case 'N': case 'f': case 'F': case '0': case '-':
569 >                        getparam(s+1, "black and white", 'b',
570 >                                        (void *)&greyscale);
571 >                        break;
572 >                default:
573 >                        goto badparam;
574 >                }
575                  break;
576          case 'i':                       /* irradiance */
577 <                getparam(s+1, "irradiance", 'b', &do_irrad);
577 >                getparam(s+1, "irradiance", 'b',
578 >                                (void *)&do_irrad);
579                  break;
580          case 'a':                       /* ambient */
581                  switch (s[1]) {
582                  case 'v':                       /* value */
583 <                        getparam(s+2, "ambient value", 'C', (COLOR *)ambval);
583 >                        getparam(s+2, "ambient value", 'C',
584 >                                        (void *)ambval);
585                          break;
586 +                case 'w':                       /* weight */
587 +                        getparam(s+2, "ambient value weight", 'i',
588 +                                        (void *)&ambvwt);
589 +                        break;
590                  case 'a':                       /* accuracy */
591 <                        getparam(s+2, "ambient accuracy", 'r', &ambacc);
591 >                        if (getparam(s+2, "ambient accuracy", 'r',
592 >                                        (void *)&ambacc))
593 >                                setambacc(ambacc);
594                          break;
595                  case 'd':                       /* divisions */
596 <                        getparam(s+2, "ambient divisions", 'i', &ambdiv);
596 >                        getparam(s+2, "ambient divisions", 'i',
597 >                                        (void *)&ambdiv);
598                          break;
599                  case 's':                       /* samples */
600 <                        getparam(s+2, "ambient super-samples", 'i', &ambssamp);
600 >                        getparam(s+2, "ambient super-samples", 'i',
601 >                                        (void *)&ambssamp);
602                          break;
603                  case 'b':                       /* bounces */
604 <                        getparam(s+2, "ambient bounces", 'i', &ambounce);
604 >                        getparam(s+2, "ambient bounces", 'i',
605 >                                        (void *)&ambounce);
606                          break;
607                  case 'r':
608 <                        if (getparam(s+2, "ambient resolution", 'i', &ambres))
608 >                        if (getparam(s+2, "ambient resolution", 'i',
609 >                                        (void *)&ambres))
610                                  setambres(ambres);
611                          break;
612                  default:
613                          goto badparam;
614                  }
615                  break;
616 +        case 'm':                       /* medium */
617 +                switch (s[1]) {
618 +                case 'e':                       /* extinction coefficient */
619 +                        getparam(s+2, "extinction coefficient", 'C',
620 +                                        (void *)cextinction);
621 +                        break;
622 +                case 'a':                       /* scattering albedo */
623 +                        getparam(s+2, "scattering albedo", 'C',
624 +                                        (void *)salbedo);
625 +                        break;
626 +                case 'g':                       /* scattering eccentricity */
627 +                        getparam(s+2, "scattering eccentricity", 'r',
628 +                                        (void *)&seccg);
629 +                        break;
630 +                case 's':                       /* sampling distance */
631 +                        getparam(s+2, "mist sampling distance", 'r',
632 +                                        (void *)&ssampdist);
633 +                        break;
634 +                default:
635 +                        goto badparam;
636 +                }
637 +                break;
638          case 'p':                       /* pixel */
639                  switch (s[1]) {
640                  case 's':                       /* sample */
641 <                        if (getparam(s+2, "pixel sample", 'i', &psample))
641 >                        if (getparam(s+2, "pixel sample", 'i',
642 >                                        (void *)&psample))
643                                  pdepth = 0;
644                          break;
645                  case 't':                       /* threshold */
646 <                        if (getparam(s+2, "pixel threshold", 'r', &maxdiff))
646 >                        if (getparam(s+2, "pixel threshold", 'r',
647 >                                        (void *)&maxdiff))
648                                  pdepth = 0;
649                          break;
650                  default:
# Line 494 | Line 654 | register char  *s;
654          case 's':                       /* specular */
655                  switch (s[1]) {
656                  case 'j':                       /* jitter */
657 <                        getparam(s+2, "specular jitter", 'r', &specjitter);
657 >                        getparam(s+2, "specular jitter", 'r',
658 >                                        (void *)&specjitter);
659                          break;
660                  case 't':                       /* threshold */
661 <                        getparam(s+2, "specular threshold", 'r', &specthresh);
661 >                        getparam(s+2, "specular threshold", 'r',
662 >                                        (void *)&specthresh);
663                          break;
664                  default:
665                          goto badparam;
# Line 515 | Line 677 | badparam:
677   }
678  
679  
680 + extern void
681   traceray(s)                             /* trace a single ray */
682   char  *s;
683   {
684          char  buf[128];
685          int  x, y;
686 +        OBJREC  *ino;
687          RAY  thisray;
688  
689 +        thisray.rmax = 0.0;
690 +
691          if (!sscanvec(s, thisray.rorg) ||
692 <                        !sscanvec(sskip(sskip(sskip(s))), thisray.rdir)) {
692 >                        !sscanvec(sskip2(s,3), thisray.rdir)) {
693  
694                  if (dev->getcur == NULL)
695                          return;
# Line 531 | Line 697 | char  *s;
697                  if ((*dev->getcur)(&x, &y) == ABORT)
698                          return;
699  
700 <                if (viewray(thisray.rorg, thisray.rdir, &ourview,
701 <                                (x+.5)/hresolu, (y+.5)/vresolu) < 0) {
700 >                if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir,
701 >                        &ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) {
702                          error(COMMAND, "not on image");
703                          return;
704                  }
# Line 549 | Line 715 | char  *s;
715          if (thisray.ro == NULL)
716                  (*dev->comout)("ray hit nothing");
717          else {
718 <                sprintf(buf, "ray hit %s %s \"%s\"",
719 <                                objptr(thisray.ro->omod)->oname,
718 >                sprintf(buf, "ray hit %s%s %s \"%s\"",
719 >                                thisray.rod < 0.0 ? "back of " : "",
720 >                                thisray.ro->omod == OVOID ? VOIDID :
721 >                                        objptr(thisray.ro->omod)->oname,
722                                  ofun[thisray.ro->otype].funame,
723                                  thisray.ro->oname);
724 +                if ((ino = objptr(thisray.robj)) != thisray.ro)
725 +                        sprintf(buf+strlen(buf), " in %s \"%s\"",
726 +                                        ofun[ino->otype].funame, ino->oname);
727                  (*dev->comout)(buf);
728                  (*dev->comin)(buf, NULL);
729                  if (thisray.rot >= FHUGE)
730                          (*dev->comout)("at infinity");
731                  else {
732 <                        sprintf(buf, "at (%.6g %.6g %.6g)", thisray.rop[0],
733 <                                        thisray.rop[1], thisray.rop[2]);
732 >                        sprintf(buf, "at (%.6g %.6g %.6g) (%.6g)",
733 >                                        thisray.rop[0], thisray.rop[1],
734 >                                        thisray.rop[2], thisray.rt);
735                          (*dev->comout)(buf);
736                  }
737                  (*dev->comin)(buf, NULL);
738 <                sprintf(buf, "value (%.5g %.5g %.5g) (%.1fL)",
738 >                sprintf(buf, "value (%.5g %.5g %.5g) (%.3gL)",
739                                  colval(thisray.rcol,RED),
740                                  colval(thisray.rcol,GRN),
741                                  colval(thisray.rcol,BLU),
# Line 574 | Line 746 | char  *s;
746   }
747  
748  
749 + extern void
750   writepict(s)                            /* write the picture to a file */
751   char  *s;
752   {
# Line 583 | Line 756 | char  *s;
756          COLR  *scanline;
757          int  y;
758  
759 <        if (sscanf(s, "%s", buf) != 1 && buf[0] == '\0') {
759 >        while (isspace(*s))
760 >                s++;
761 >        if (*s)
762 >                atos(buf, sizeof(buf), s);
763 >        else if (buf[0] == '\0') {
764                  error(COMMAND, "no file");
765                  return;
766          }
# Line 593 | Line 770 | char  *s;
770                  error(COMMAND, errmsg);
771                  return;
772          }
773 < #ifdef MSDOS
597 <        setmode(fileno(fp), O_BINARY);
598 < #endif
773 >        SET_FILE_BINARY(fp);
774          (*dev->comout)("writing \"");
775          (*dev->comout)(fname);
776          (*dev->comout)("\"...\n");
777                                                  /* write header */
778 +        newheader("RADIANCE", fp);
779          fputs(progname, fp);
780          fprintview(&ourview, fp);
781          if (octname != NULL)
# Line 607 | Line 783 | char  *s;
783          else
784                  putc('\n', fp);
785          fprintf(fp, "SOFTWARE= %s\n", VersionID);
786 +        fputnow(fp);
787          if (exposure != 1.0)
788                  fputexpos(exposure, fp);
789          if (dev->pixaspect != 1.0)
# Line 627 | Line 804 | char  *s;
804                  if (fwritecolrs(scanline, hresolu, fp) < 0)
805                          break;
806          }
807 <        free((char *)scanline);
807 >        free((void *)scanline);
808          if (fclose(fp) < 0)
809                  error(COMMAND, "write error");
810   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines