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.2 by greg, Fri Feb 3 07:58:07 1989 UTC vs.
Revision 1.23 by greg, Thu Jul 18 15:49:06 1991 UTC

# Line 28 | Line 28 | extern char  *progname;
28   getframe(s)                             /* get a new frame */
29   char  *s;
30   {
31 <        int  x0, y0, x1, y1;
32 <
33 <        if (!strcmp("all", s)) {
34 <                pframe.l = pframe.d = 0;
35 <                pframe.r = ourview.hresolu;
36 <                pframe.u = ourview.vresolu;
37 <                pdepth = 0;
31 >        if (getrect(s, &pframe) < 0)
32                  return;
39        }
40        if (sscanf(s, "%d %d %d %d", &x0, &y0, &x1, &y1) != 4) {
41                if (dev->getcur == NULL)
42                        return;
43                (*dev->comout)("Pick first corner\n");
44                if ((*dev->getcur)(&x0, &y0) == ABORT)
45                        return;
46                (*dev->comout)("Pick second corner\n");
47                if ((*dev->getcur)(&x1, &y1) == ABORT)
48                        return;
49        }
50        if (x0 < x1) {
51                pframe.l = x0;
52                pframe.r = x1;
53        } else {
54                pframe.l = x1;
55                pframe.r = x0;
56        }
57        if (y0 < y1) {
58                pframe.d = y0;
59                pframe.u = y1;
60        } else {
61                pframe.d = y1;
62                pframe.u = y0;
63        }
64        if (pframe.l < 0) pframe.l = 0;
65        if (pframe.d < 0) pframe.d = 0;
66        if (pframe.r > ourview.hresolu) pframe.r = ourview.hresolu;
67        if (pframe.u > ourview.vresolu) pframe.u = ourview.vresolu;
33          pdepth = 0;
34   }
35  
36  
37 + getrepaint(s)                           /* get area and repaint */
38 + char  *s;
39 + {
40 +        RECT  box;
41 +
42 +        if (getrect(s, &box) < 0)
43 +                return;
44 +        paintrect(&ptrunk, 0, 0, hresolu, vresolu, &box);
45 + }
46 +
47 +
48   getview(s)                              /* get/show view parameters */
49   char  *s;
50   {
51          FILE  *fp;
52          char  buf[128];
53 <        char  *fname, *getpath();
53 >        char  *fname;
54 >        int  change = 0;
55          VIEW  nv;
56  
57          if (sscanf(s, "%s", buf) == 1) {        /* write parameters to a file */
58 <                if ((fname = getpath(buf, NULL)) == NULL ||
58 >                if ((fname = getpath(buf, NULL, 0)) == NULL ||
59                                  (fp = fopen(fname, "a")) == NULL) {
60                          sprintf(errmsg, "cannot open \"%s\"", buf);
61                          error(COMMAND, errmsg);
# Line 86 | Line 63 | char  *s;
63                  }
64                  fputs(progname, fp);
65                  fprintview(&ourview, fp);
66 +                fputs(sskip(s), fp);
67                  fputs("\n", fp);
68                  fclose(fp);
69                  return;
70          }
71          sprintf(buf, "view type (%c): ", ourview.type);
72          (*dev->comout)(buf);
73 <        (*dev->comin)(buf);
73 >        (*dev->comin)(buf, NULL);
74          if (buf[0] == CTRL(C)) return;
75 <        if (buf[0])
75 >        if (buf[0] && buf[0] != ourview.type) {
76                  nv.type = buf[0];
77 <        else
77 >                change++;
78 >        } else
79                  nv.type = ourview.type;
80          sprintf(buf, "view point (%.6g %.6g %.6g): ",
81                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);
82          (*dev->comout)(buf);
83 <        (*dev->comin)(buf);
83 >        (*dev->comin)(buf, NULL);
84          if (buf[0] == CTRL(C)) return;
85 <        if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) != 3)
85 >        if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3)
86 >                change++;
87 >        else
88                  VCOPY(nv.vp, ourview.vp);
89          sprintf(buf, "view direction (%.6g %.6g %.6g): ",
90                          ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]);
91          (*dev->comout)(buf);
92 <        (*dev->comin)(buf);
92 >        (*dev->comin)(buf, NULL);
93          if (buf[0] == CTRL(C)) return;
94 <        if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) != 3)
94 >        if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3)
95 >                change++;
96 >        else
97                  VCOPY(nv.vdir, ourview.vdir);
98          sprintf(buf, "view up (%.6g %.6g %.6g): ",
99                          ourview.vup[0], ourview.vup[1], ourview.vup[2]);
100          (*dev->comout)(buf);
101 <        (*dev->comin)(buf);
101 >        (*dev->comin)(buf, NULL);
102          if (buf[0] == CTRL(C)) return;
103 <        if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) != 3)
103 >        if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3)
104 >                change++;
105 >        else
106                  VCOPY(nv.vup, ourview.vup);
107          sprintf(buf, "view horiz and vert size (%.6g %.6g): ",
108                          ourview.horiz, ourview.vert);
109          (*dev->comout)(buf);
110 <        (*dev->comin)(buf);
110 >        (*dev->comin)(buf, NULL);
111          if (buf[0] == CTRL(C)) return;
112 <        if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) != 2) {
112 >        if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2)
113 >                change++;
114 >        else {
115                  nv.horiz = ourview.horiz; nv.vert = ourview.vert;
116          }
117 <        sprintf(buf, "x and y resolution (%d %d): ",
118 <                        ourview.hresolu, ourview.vresolu);
117 >        sprintf(buf, "view shift and lift (%.6g %.6g): ",
118 >                        ourview.hoff, ourview.voff);
119          (*dev->comout)(buf);
120 <        (*dev->comin)(buf);
120 >        (*dev->comin)(buf, NULL);
121          if (buf[0] == CTRL(C)) return;
122 <        if (sscanf(buf, "%d %d", &nv.hresolu, &nv.vresolu) != 2) {
123 <                nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu;
122 >        if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2)
123 >                change++;
124 >        else {
125 >                nv.hoff = ourview.hoff; nv.voff = ourview.voff;
126          }
127 <        newview(&nv);
127 >        if (change)
128 >                newview(&nv);
129   }
130  
131  
# Line 143 | Line 133 | lastview(s)                            /* return to a previous view */
133   char  *s;
134   {
135          char  buf[128];
136 <        char  *fname, *getpath();
136 >        char  *fname;
137          int  success;
138          VIEW  nv;
139  
140          if (sscanf(s, "%s", buf) == 1) {        /* get parameters from a file */
141 <                bcopy(&stdview, &nv, sizeof(VIEW));
142 <                if ((fname = getpath(buf, NULL)) == NULL ||
143 <                                (success = viewfile(fname, &nv)) == -1) {
141 >                copystruct(&nv, &stdview);
142 >                if ((fname = getpath(buf, NULL, 0)) == NULL ||
143 >                                (success = viewfile(fname, &nv, 0, 0)) == -1) {
144                          sprintf(errmsg, "cannot open \"%s\"", buf);
145                          error(COMMAND, errmsg);
146                          return;
# Line 161 | Line 151 | char  *s;
151                          newview(&nv);
152                  return;
153          }
154 <        if (oldview.hresolu == 0) {     /* no old view! */
154 >        if (oldview.type == 0) {        /* no old view! */
155                  error(COMMAND, "no previous view");
156                  return;
157          }
158 <        bcopy(&ourview, &nv, sizeof(VIEW));
159 <        bcopy(&oldview, &ourview, sizeof(VIEW));
160 <        bcopy(&nv, &oldview, sizeof(VIEW));
158 >        copystruct(&nv, &ourview);
159 >        copystruct(&ourview, &oldview);
160 >        copystruct(&oldview, &nv);
161          newimage();
162   }
163  
164  
175 getinterest(s, direc, vec, mp)          /* get area of interest */
176 char  *s;
177 int  direc;
178 FVECT  vec;
179 double  *mp;
180 {
181        int  x, y;
182        RAY  thisray;
183        register int  i;
184
185        if (sscanf(s, "%lf", mp) != 1)
186                *mp = 1.0;
187        else if (*mp < -FTINY)          /* negative zoom is reduction */
188                *mp = -1.0 / *mp;
189        else if (*mp <= FTINY) {        /* too small */
190                error(COMMAND, "illegal magnification");
191                return(-1);
192        }
193        if (sscanf(s, "%*lf %lf %lf %lf", &vec[0], &vec[1], &vec[2]) != 3) {
194                if (dev->getcur == NULL)
195                        return(-1);
196                (*dev->comout)("Pick view center\n");
197                if ((*dev->getcur)(&x, &y) == ABORT)
198                        return(-1);
199                rayview(thisray.rorg, thisray.rdir, &ourview, x+.5, y+.5);
200                if (!direc || ourview.type == VT_PAR) {
201                        rayorigin(&thisray, NULL, PRIMARY, 1.0);
202                        if (!localhit(&thisray, &thescene)) {
203                                error(COMMAND, "not a local object");
204                                return(-1);
205                        }
206                }
207                if (direc)
208                        if (ourview.type == VT_PAR)
209                                for (i = 0; i < 3; i++)
210                                        vec[i] = thisray.rop[i] - ourview.vp[i];
211                        else
212                                VCOPY(vec, thisray.rdir);
213                else
214                        VCOPY(vec, thisray.rop);
215        } else if (direc)
216                        for (i = 0; i < 3; i++)
217                                vec[i] -= ourview.vp[i];
218        return(0);
219 }
220
221
165   getaim(s)                               /* aim camera */
166   char  *s;
167   {
# Line 228 | Line 171 | char  *s;
171  
172          if (getinterest(s, 1, nv.vdir, &zfact) < 0)
173                  return;
174 +        nv.type = ourview.type;
175          VCOPY(nv.vp, ourview.vp);
176          VCOPY(nv.vup, ourview.vup);
177 <        nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu;
178 <        if ((nv.type = ourview.type) == VT_PAR) {
179 <                nv.horiz = ourview.horiz / zfact;
236 <                nv.vert = ourview.vert / zfact;
237 <        } else {
238 <                nv.horiz = atan(tan(ourview.horiz*(PI/180./2.))/zfact) /
239 <                                (PI/180./2.);
240 <                nv.vert = atan(tan(ourview.vert*(PI/180./2.))/zfact) /
241 <                                (PI/180./2.);
242 <        }
177 >        nv.hoff = ourview.hoff; nv.voff = ourview.voff;
178 >        nv.horiz = ourview.horiz; nv.vert = ourview.vert;
179 >        zoomview(&nv, zfact);
180          newview(&nv);
181   }
182  
# Line 252 | Line 189 | char  *s;
189  
190          if (getinterest(s, 0, vc, &mag) < 0)
191                  return;
192 <        moveview(0.0, mag, vc);
192 >        moveview(0.0, 0.0, mag, vc);
193   }
194  
195  
196   getrotate(s)                            /* rotate camera */
197   char  *s;
198   {
199 <        extern double  normalize();
199 >        extern double  normalize(), tan(), atan();
200          VIEW  nv;
201          FVECT  v1;
202 <        double  angle, elev;
202 >        double  angle, elev, zfact;
203          
204 <        elev = 0.0;
205 <        if (sscanf(s, "%lf %lf", &angle, &elev) < 1) {
204 >        elev = 0.0; zfact = 1.0;
205 >        if (sscanf(s, "%lf %lf %lf", &angle, &elev, &zfact) < 1) {
206                  error(COMMAND, "missing angle");
207                  return;
208          }
209          nv.type = ourview.type;
210          VCOPY(nv.vp, ourview.vp);
211          VCOPY(nv.vup, ourview.vup);
212 <        nv.horiz = ourview.horiz; nv.vert = ourview.vert;
276 <        nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu;
212 >        nv.hoff = ourview.hoff; nv.voff = ourview.voff;
213          spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.));
214          if (elev != 0.0) {
215                  fcross(v1, nv.vdir, ourview.vup);
216                  normalize(v1);
217                  spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.));
218          }
219 +        nv.horiz = ourview.horiz; nv.vert = ourview.vert;
220 +        zoomview(&nv, zfact);
221          newview(&nv);
222   }
223  
# Line 288 | Line 226 | getpivot(s)                            /* pivot viewpoint */
226   register char  *s;
227   {
228          FVECT  vc;
229 <        double  angle, mag;
229 >        double  angle, elev, mag;
230  
231 <        if (sscanf(s, "%lf", &angle) != 1) {
231 >        elev = 0.0;
232 >        if (sscanf(s, "%lf %lf", &angle, &elev) < 1) {
233                  error(COMMAND, "missing angle");
234                  return;
235          }
236 <        if (getinterest(sskip(s), 0, vc, &mag) < 0)
236 >        if (getinterest(sskip(sskip(s)), 0, vc, &mag) < 0)
237                  return;
238 <        moveview(angle, mag, vc);
238 >        moveview(angle, elev, mag, vc);
239   }
240  
241  
# Line 320 | Line 259 | char  *s;
259                  if ((*dev->getcur)(&x, &y) == ABORT)
260                          return;
261                  r.l = r.d = 0;
262 <                r.r = ourview.hresolu; r.u = ourview.vresolu;
262 >                r.r = hresolu; r.u = vresolu;
263                  p = findrect(x, y, &ptrunk, &r, -1);
264                  e = 1.0;
265          } else {
# Line 332 | Line 271 | char  *s;
271                          if (*cp == '\0') {      /* interactive */
272                                  sprintf(buf, "exposure (%lf): ", exposure);
273                                  (*dev->comout)(buf);
274 <                                (*dev->comin)(buf);
274 >                                (*dev->comin)(buf, NULL);
275                                  for (cp = buf; isspace(*cp); cp++)
276                                          ;
277                                  if (*cp == '\0')
# Line 348 | Line 287 | char  *s;
287                          e *= atof(cp);
288          }
289          if (p != NULL) {                /* relative setting */
290 <                if (intens(p->v) <= FTINY) {
290 >                if (bright(p->v) <= FTINY) {
291                          error(COMMAND, "cannot normalize to zero");
292                          return;
293                  }
294 <                e *= 0.5 / intens(p->v);
294 >                e *= 0.5 / bright(p->v);
295          }
296          if (e <= FTINY || fabs(1.0 - e) <= FTINY)
297                  return;
# Line 370 | Line 309 | register char  *s;
309          extern double  minweight;
310          extern int  maxdepth;
311          extern double  dstrsrc;
312 +        extern double  shadthresh;
313 +        extern double  shadcert;
314          extern COLOR  ambval;
315          extern double  ambacc;
316          extern double  minarad;
# Line 377 | Line 318 | register char  *s;
318          extern int  ambdiv;
319          extern int  ambssamp;
320          extern int  ambounce;
321 +        extern int  directinvis;
322 +        extern int  do_irrad;
323          int  i0;
324          double  d0, d1, d2;
325 <        char  buf[128];
325 >        char  buf[128], ans[4];
326          
327          if (s[0] == '\0') {
328 <                (*dev->comout)("aa ab ad ar as av ds lr lw sd sp: ");
329 <                (*dev->comin)(buf);
328 >                (*dev->comout)(
329 >                        "aa ab ad ar as av b dc dj di dt i lr lw sp st: ");
330 >                (*dev->comin)(buf, NULL);
331                  s = buf;
332          }
333          switch (s[0]) {
# Line 394 | Line 338 | register char  *s;
338                                  sprintf(buf, "limit weight (%.6g): ",
339                                                  minweight);
340                                  (*dev->comout)(buf);
341 <                                (*dev->comin)(buf);
341 >                                (*dev->comin)(buf, NULL);
342                                  if (sscanf(buf, "%lf", &d0) != 1)
343                                          break;
344                          }
# Line 405 | Line 349 | register char  *s;
349                                  sprintf(buf, "limit reflection (%d): ",
350                                                  maxdepth);
351                                  (*dev->comout)(buf);
352 <                                (*dev->comin)(buf);
352 >                                (*dev->comin)(buf, NULL);
353                                  if (sscanf(buf, "%d", &i0) != 1)
354                                          break;
355                          }
# Line 415 | Line 359 | register char  *s;
359                          goto badparam;
360                  }
361                  break;
362 <        case 'd':                       /* distribute source */
363 <                if (s[1] != 's')
362 >        case 'd':                       /* direct */
363 >                switch (s[1]) {
364 >                case 'j':                       /* jitter */
365 >                        if (sscanf(s+2, "%lf", &d0) != 1) {
366 >                                sprintf(buf, "direct jitter (%.6g): ",
367 >                                                dstrsrc);
368 >                                (*dev->comout)(buf);
369 >                                (*dev->comin)(buf, NULL);
370 >                                if (sscanf(buf, "%lf", &d0) != 1)
371 >                                        break;
372 >                        }
373 >                        dstrsrc = d0;
374 >                        break;
375 >                case 'c':                       /* certainty */
376 >                        if (sscanf(s+2, "%lf", &d0) != 1) {
377 >                                sprintf(buf, "direct certainty (%.6g): ",
378 >                                                shadcert);
379 >                                (*dev->comout)(buf);
380 >                                (*dev->comin)(buf, NULL);
381 >                                if (sscanf(buf, "%lf", &d0) != 1)
382 >                                        break;
383 >                        }
384 >                        shadcert = d0;
385 >                        break;
386 >                case 't':                       /* threshold */
387 >                        if (sscanf(s+2, "%lf", &d0) != 1) {
388 >                                sprintf(buf, "direct threshold (%.6g): ",
389 >                                                shadthresh);
390 >                                (*dev->comout)(buf);
391 >                                (*dev->comin)(buf, NULL);
392 >                                if (sscanf(buf, "%lf", &d0) != 1)
393 >                                        break;
394 >                        }
395 >                        shadthresh = d0;
396 >                        break;
397 >                case 'i':                       /* invisibility */
398 >                        if (sscanf(s+2, "%1s", ans) != 1) {
399 >                                sprintf(buf, "direct invisibility (%c): ",
400 >                                                directinvis ? 'y' : 'n');
401 >                                (*dev->comout)(buf);
402 >                                (*dev->comin)(buf, NULL);
403 >                                if (sscanf(buf, "%1s", ans) != 1)
404 >                                        break;
405 >                        }
406 >                        directinvis = tolower(ans[0]) == 'y';
407 >                        break;
408 >                default:
409                          goto badparam;
410 <                if (sscanf(s+2, "%lf", &d0) != 1) {
411 <                        sprintf(buf, "distribute source (%.6g): ", dstrsrc);
410 >                }
411 >                break;
412 >        case 'b':                       /* black and white */
413 >                if (sscanf(s+1, "%1s", ans) != 1) {
414 >                        sprintf(buf, "black and white (%c): ",
415 >                                        greyscale ? 'y' : 'n');
416                          (*dev->comout)(buf);
417 <                        (*dev->comin)(buf);
418 <                        if (sscanf(buf, "%lf", &d0) != 1)
417 >                        (*dev->comin)(buf, NULL);
418 >                        if (sscanf(buf, "%1s", ans) != 1)
419                                  break;
420                  }
421 <                dstrsrc = d0;
421 >                greyscale = tolower(ans[0]) == 'y';
422                  break;
423 +        case 'i':                       /* irradiance */
424 +                if (sscanf(s+1, "%1s", ans) != 1) {
425 +                        sprintf(buf, "irradiance (%c): ",
426 +                                        do_irrad ? 'y' : 'n');
427 +                        (*dev->comout)(buf);
428 +                        (*dev->comin)(buf, NULL);
429 +                        if (sscanf(buf, "%1s", ans) != 1)
430 +                                break;
431 +                }
432 +                do_irrad = tolower(ans[0]) == 'y';
433 +                break;
434          case 'a':                       /* ambient */
435                  switch (s[1]) {
436                  case 'v':                       /* value */
# Line 437 | Line 441 | register char  *s;
441                                                  colval(ambval,GRN),
442                                                  colval(ambval,BLU));
443                                  (*dev->comout)(buf);
444 <                                (*dev->comin)(buf);
444 >                                (*dev->comin)(buf, NULL);
445                                  if (sscanf(buf, "%lf %lf %lf",
446                                                  &d0, &d1, &d2) != 3)
447                                          break;
# Line 449 | Line 453 | register char  *s;
453                                  sprintf(buf, "ambient accuracy (%.6g): ",
454                                                  ambacc);
455                                  (*dev->comout)(buf);
456 <                                (*dev->comin)(buf);
456 >                                (*dev->comin)(buf, NULL);
457                                  if (sscanf(buf, "%lf", &d0) != 1)
458                                          break;
459                          }
# Line 460 | Line 464 | register char  *s;
464                                  sprintf(buf, "ambient divisions (%d): ",
465                                                  ambdiv);
466                                  (*dev->comout)(buf);
467 <                                (*dev->comin)(buf);
467 >                                (*dev->comin)(buf, NULL);
468                                  if (sscanf(buf, "%d", &i0) != 1)
469                                          break;
470                          }
# Line 471 | Line 475 | register char  *s;
475                                  sprintf(buf, "ambient super-samples (%d): ",
476                                                  ambssamp);
477                                  (*dev->comout)(buf);
478 <                                (*dev->comin)(buf);
478 >                                (*dev->comin)(buf, NULL);
479                                  if (sscanf(buf, "%d", &i0) != 1)
480                                          break;
481                          }
# Line 482 | Line 486 | register char  *s;
486                                  sprintf(buf, "ambient bounces (%d): ",
487                                                  ambounce);
488                                  (*dev->comout)(buf);
489 <                                (*dev->comin)(buf);
489 >                                (*dev->comin)(buf, NULL);
490                                  if (sscanf(buf, "%d", &i0) != 1)
491                                          break;
492                          }
# Line 493 | Line 497 | register char  *s;
497                                  sprintf(buf, "ambient resolution (%d): ",
498                                                  ambres);
499                                  (*dev->comout)(buf);
500 <                                (*dev->comin)(buf);
500 >                                (*dev->comin)(buf, NULL);
501                                  if (sscanf(buf, "%d", &i0) != 1)
502                                          break;
503                          }
# Line 510 | Line 514 | register char  *s;
514                          if (sscanf(s+2, "%d", &i0) != 1) {
515                                  sprintf(buf, "sample pixel (%d): ", psample);
516                                  (*dev->comout)(buf);
517 <                                (*dev->comin)(buf);
517 >                                (*dev->comin)(buf, NULL);
518                                  if (sscanf(buf, "%d", &i0) != 1)
519                                          break;
520                          }
521                          psample = i0;
522                          pdepth = 0;
523                          break;
524 <                case 'd':                       /* difference */
524 >                case 't':                       /* threshold */
525                          if (sscanf(s+2, "%lf", &d0) != 1) {
526 <                                sprintf(buf, "sample difference (%.6g): ",
526 >                                sprintf(buf, "sample threshold (%.6g): ",
527                                                  maxdiff);
528                                  (*dev->comout)(buf);
529 <                                (*dev->comin)(buf);
529 >                                (*dev->comin)(buf, NULL);
530                                  if (sscanf(buf, "%lf", &d0) != 1)
531                                          break;
532                          }
# Line 561 | Line 565 | char  *s;
565                  if ((*dev->getcur)(&x, &y) == ABORT)
566                          return;
567  
568 <                rayview(thisray.rorg, thisray.rdir, &ourview, x+.5, y+.5);
569 <                
568 >                if (viewray(thisray.rorg, thisray.rdir, &ourview,
569 >                                (x+.5)/hresolu, (y+.5)/vresolu) < 0) {
570 >                        error(COMMAND, "not on image");
571 >                        return;
572 >                }
573 >
574          } else if (normalize(thisray.rdir) == 0.0) {
575                  error(COMMAND, "zero ray direction");
576                  return;
# Line 580 | Line 588 | char  *s;
588                                  ofun[thisray.ro->otype].funame,
589                                  thisray.ro->oname);
590                  (*dev->comout)(buf);
591 <                (*dev->comin)(buf);
591 >                (*dev->comin)(buf, NULL);
592                  if (thisray.rot >= FHUGE)
593                          (*dev->comout)("at infinity");
594                  else {
# Line 588 | Line 596 | char  *s;
596                                          thisray.rop[1], thisray.rop[2]);
597                          (*dev->comout)(buf);
598                  }
599 <                (*dev->comin)(buf);
599 >                (*dev->comin)(buf, NULL);
600                  sprintf(buf, "with value (%.6g %.6g %.6g)",
601                                  colval(thisray.rcol,RED),
602                                  colval(thisray.rcol,GRN),
603                                  colval(thisray.rcol,BLU));
604                  (*dev->comout)(buf);
605          }
606 <        (*dev->comin)(buf);
606 >        (*dev->comin)(buf, NULL);
607   }
608  
609  
# Line 603 | Line 611 | writepict(s)                           /* write the picture to a file */
611   char  *s;
612   {
613          static char  buf[128];
614 <        char  *fname, *getpath();
614 >        char  *fname;
615          FILE  *fp;
616          COLR  *scanline;
617          int  y;
# Line 612 | Line 620 | char  *s;
620                  error(COMMAND, "no file");
621                  return;
622          }
623 <        if ((fname = getpath(buf, NULL)) == NULL ||
623 >        if ((fname = getpath(buf, NULL, 0)) == NULL ||
624                          (fp = fopen(fname, "w")) == NULL) {
625                  sprintf(errmsg, "cannot open \"%s\"", buf);
626                  error(COMMAND, errmsg);
# Line 624 | Line 632 | char  *s;
632                                                  /* write header */
633          fputs(progname, fp);
634          fprintview(&ourview, fp);
635 <        fputs("\n", fp);
635 >        putc('\n', fp);
636          if (exposure != 1.0)
637 <                fprintf(fp, "EXPOSURE=%e\n", exposure);
638 <        fprintf(fp, "\n-Y %d +X %d\n", ourview.vresolu, ourview.hresolu);
637 >                fputexpos(exposure, fp);
638 >        if (dev->pixaspect != 1.0)
639 >                fputaspect(dev->pixaspect, fp);
640 >        fputformat(COLRFMT, fp);
641 >        putc('\n', fp);
642 >        fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp);
643  
644 <        scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR));
644 >        scanline = (COLR *)malloc(hresolu*sizeof(COLR));
645          if (scanline == NULL)
646                  error(SYSTEM, "out of memory in writepict");
647 <        for (y = ourview.vresolu-1; y >= 0; y--) {
648 <                getpictcolrs(y, scanline, &ptrunk,
649 <                                ourview.hresolu, ourview.vresolu);
638 <                if (fwritecolrs(scanline, ourview.hresolu, fp) < 0)
647 >        for (y = vresolu-1; y >= 0; y--) {
648 >                getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu);
649 >                if (fwritecolrs(scanline, hresolu, fp) < 0)
650                          break;
651          }
652          if (fclose(fp) < 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines