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.19 by greg, Mon Feb 5 09:57:45 1990 UTC vs.
Revision 1.25 by greg, Fri Jul 19 15:22:02 1991 UTC

# Line 151 | Line 151 | char  *s;
151                          newview(&nv);
152                  return;
153          }
154 <        if (oldview.horiz == 0) {       /* no old view! */
154 >        if (oldview.type == 0) {        /* no old view! */
155                  error(COMMAND, "no previous view");
156                  return;
157          }
# Line 171 | 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.hoff = ourview.hoff; nv.voff = ourview.voff;
178 <        if ((nv.type = ourview.type) == VT_PAR) {
179 <                nv.horiz = ourview.horiz / zfact;
179 <                nv.vert = ourview.vert / zfact;
180 <        } else {
181 <                nv.horiz = atan(tan(ourview.horiz*(PI/180./2.))/zfact) /
182 <                                (PI/180./2.);
183 <                nv.vert = atan(tan(ourview.vert*(PI/180./2.))/zfact) /
184 <                                (PI/180./2.);
185 <        }
178 >        nv.horiz = ourview.horiz; nv.vert = ourview.vert;
179 >        zoomview(&nv, zfact);
180          newview(&nv);
181   }
182  
# Line 212 | Line 206 | char  *s;
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.hoff = ourview.hoff; nv.voff = ourview.voff;
# Line 221 | Line 216 | char  *s;
216                  normalize(v1);
217                  spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.));
218          }
219 <        if ((nv.type = ourview.type) == VT_PAR) {
220 <                nv.horiz = ourview.horiz / zfact;
226 <                nv.vert = ourview.vert / zfact;
227 <        } else {
228 <                nv.horiz = atan(tan(ourview.horiz*(PI/180./2.))/zfact) /
229 <                                (PI/180./2.);
230 <                nv.vert = atan(tan(ourview.vert*(PI/180./2.))/zfact) /
231 <                                (PI/180./2.);
232 <        }
219 >        nv.horiz = ourview.horiz; nv.vert = ourview.vert;
220 >        zoomview(&nv, zfact);
221          newview(&nv);
222   }
223  
# Line 313 | Line 301 | char  *s;
301   }
302  
303  
304 + getparam(str, dsc, typ, ptr)            /* get variable from user */
305 + char  *str, *dsc;
306 + int  typ;
307 + register union {int i; double d; COLOR C;}  *ptr;
308 + {
309 +        extern char  *index();
310 +        int  i0;
311 +        double  d0, d1, d2;
312 +        char  buf[48];
313 +
314 +        switch (typ) {
315 +        case 'i':                       /* integer */
316 +                if (sscanf(str, "%d", &i0) != 1) {
317 +                        (*dev->comout)(dsc);
318 +                        sprintf(buf, " (%d): ", ptr->i);
319 +                        (*dev->comout)(buf);
320 +                        (*dev->comin)(buf, NULL);
321 +                        if (sscanf(buf, "%d", &i0) != 1)
322 +                                break;
323 +                }
324 +                ptr->i = i0;
325 +                break;
326 +        case 'r':                       /* real */
327 +                if (sscanf(str, "%lf", &d0) != 1) {
328 +                        (*dev->comout)(dsc);
329 +                        sprintf(buf, " (%.6g): ", ptr->d);
330 +                        (*dev->comout)(buf);
331 +                        (*dev->comin)(buf, NULL);
332 +                        if (sscanf(buf, "%lf", &d0) != 1)
333 +                                break;
334 +                }
335 +                ptr->d = d0;
336 +                break;
337 +        case 'b':                       /* boolean */
338 +                if (sscanf(str, "%1s", buf) != 1) {
339 +                        (*dev->comout)(dsc);
340 +                        sprintf(buf, " (%c): ", ptr->i ? 'y' : 'n');
341 +                        (*dev->comout)(buf);
342 +                        (*dev->comin)(buf, NULL);
343 +                        if (buf[0] == '\0' ||
344 +                                        index("yY+1tTnN-0fF", buf[0]) == NULL)
345 +                                break;
346 +                }
347 +                ptr->i = index("yY+1tT", buf[0]) != NULL;
348 +                break;
349 +        case 'C':                       /* color */
350 +                if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) {
351 +                        (*dev->comout)(dsc);
352 +                        sprintf(buf, " (%.6g %.6g %.6g): ",
353 +                                        colval(ptr->C,RED),
354 +                                        colval(ptr->C,GRN),
355 +                                        colval(ptr->C,BLU));
356 +                        (*dev->comout)(buf);
357 +                        (*dev->comin)(buf, NULL);
358 +                        if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3)
359 +                                break;
360 +                }
361 +                setcolor(ptr->C, d0, d1, d2);
362 +                break;
363 +        }
364 + }
365 +
366 +
367   setparam(s)                             /* get/set program parameter */
368   register char  *s;
369   {
# Line 330 | Line 381 | register char  *s;
381          extern int  ambdiv;
382          extern int  ambssamp;
383          extern int  ambounce;
384 <        int  i0;
385 <        double  d0, d1, d2;
384 >        extern int  directinvis;
385 >        extern int  do_irrad;
386          char  buf[128];
387          
388          if (s[0] == '\0') {
389 <                (*dev->comout)("aa ab ad ar as av dc dj dt lr lw sp st: ");
389 >                (*dev->comout)(
390 >                        "aa ab ad ar as av b dc di dj dt i lr lw sp st: ");
391                  (*dev->comin)(buf, NULL);
392                  s = buf;
393          }
# Line 343 | Line 395 | register char  *s;
395          case 'l':                       /* limit */
396                  switch (s[1]) {
397                  case 'w':                       /* weight */
398 <                        if (sscanf(s+2, "%lf", &d0) != 1) {
347 <                                sprintf(buf, "limit weight (%.6g): ",
348 <                                                minweight);
349 <                                (*dev->comout)(buf);
350 <                                (*dev->comin)(buf, NULL);
351 <                                if (sscanf(buf, "%lf", &d0) != 1)
352 <                                        break;
353 <                        }
354 <                        minweight = d0;
398 >                        getparam(s+2, "limit weight", 'r', &minweight);
399                          break;
400                  case 'r':                       /* reflection */
401 <                        if (sscanf(s+2, "%d", &i0) != 1) {
358 <                                sprintf(buf, "limit reflection (%d): ",
359 <                                                maxdepth);
360 <                                (*dev->comout)(buf);
361 <                                (*dev->comin)(buf, NULL);
362 <                                if (sscanf(buf, "%d", &i0) != 1)
363 <                                        break;
364 <                        }
365 <                        maxdepth = i0;
401 >                        getparam(s+2, "limit reflection", 'i', &maxdepth);
402                          break;
403                  default:
404                          goto badparam;
# Line 371 | Line 407 | register char  *s;
407          case 'd':                       /* direct */
408                  switch (s[1]) {
409                  case 'j':                       /* jitter */
410 <                        if (sscanf(s+2, "%lf", &d0) != 1) {
375 <                                sprintf(buf, "direct jitter (%.6g): ",
376 <                                                dstrsrc);
377 <                                (*dev->comout)(buf);
378 <                                (*dev->comin)(buf, NULL);
379 <                                if (sscanf(buf, "%lf", &d0) != 1)
380 <                                        break;
381 <                        }
382 <                        dstrsrc = d0;
410 >                        getparam(s+2, "direct jitter", 'r', &dstrsrc);
411                          break;
412                  case 'c':                       /* certainty */
413 <                        if (sscanf(s+2, "%lf", &d0) != 1) {
386 <                                sprintf(buf, "direct certainty (%.6g): ",
387 <                                                shadcert);
388 <                                (*dev->comout)(buf);
389 <                                (*dev->comin)(buf, NULL);
390 <                                if (sscanf(buf, "%lf", &d0) != 1)
391 <                                        break;
392 <                        }
393 <                        shadcert = d0;
413 >                        getparam(s+2, "direct certainty", 'r', &shadcert);
414                          break;
415                  case 't':                       /* threshold */
416 <                        if (sscanf(s+2, "%lf", &d0) != 1) {
397 <                                sprintf(buf, "direct threshold (%.6g): ",
398 <                                                shadthresh);
399 <                                (*dev->comout)(buf);
400 <                                (*dev->comin)(buf, NULL);
401 <                                if (sscanf(buf, "%lf", &d0) != 1)
402 <                                        break;
403 <                        }
404 <                        shadthresh = d0;
416 >                        getparam(s+2, "direct threshold", 'r', &shadthresh);
417                          break;
418 +                case 'i':                       /* invisibility */
419 +                        getparam(s+2, "direct invisibility",
420 +                                        'b', &directinvis);
421 +                        break;
422                  default:
423                          goto badparam;
424                  }
425                  break;
426 +        case 'b':                       /* black and white */
427 +                getparam(s+1, "black and white", 'b', &greyscale);
428 +                break;
429 +        case 'i':                       /* irradiance */
430 +                getparam(s+1, "irradiance", 'b', &do_irrad);
431 +                break;
432          case 'a':                       /* ambient */
433                  switch (s[1]) {
434                  case 'v':                       /* value */
435 <                        if (sscanf(s+2, "%lf %lf %lf", &d0, &d1, &d2) != 3) {
414 <                                sprintf(buf,
415 <                                        "ambient value (%.6g %.6g %.6g): ",
416 <                                                colval(ambval,RED),
417 <                                                colval(ambval,GRN),
418 <                                                colval(ambval,BLU));
419 <                                (*dev->comout)(buf);
420 <                                (*dev->comin)(buf, NULL);
421 <                                if (sscanf(buf, "%lf %lf %lf",
422 <                                                &d0, &d1, &d2) != 3)
423 <                                        break;
424 <                        }
425 <                        setcolor(ambval, d0, d1, d2);
435 >                        getparam(s+2, "ambient value", 'C', ambval);
436                          break;
437                  case 'a':                       /* accuracy */
438 <                        if (sscanf(s+2, "%lf", &d0) != 1) {
429 <                                sprintf(buf, "ambient accuracy (%.6g): ",
430 <                                                ambacc);
431 <                                (*dev->comout)(buf);
432 <                                (*dev->comin)(buf, NULL);
433 <                                if (sscanf(buf, "%lf", &d0) != 1)
434 <                                        break;
435 <                        }
436 <                        ambacc = d0;
438 >                        getparam(s+2, "ambient accuracy", 'r', &ambacc);
439                          break;
440                  case 'd':                       /* divisions */
441 <                        if (sscanf(s+2, "%d", &i0) != 1) {
440 <                                sprintf(buf, "ambient divisions (%d): ",
441 <                                                ambdiv);
442 <                                (*dev->comout)(buf);
443 <                                (*dev->comin)(buf, NULL);
444 <                                if (sscanf(buf, "%d", &i0) != 1)
445 <                                        break;
446 <                        }
447 <                        ambdiv = i0;
441 >                        getparam(s+2, "ambient divisions", 'i', &ambdiv);
442                          break;
443                  case 's':                       /* samples */
444 <                        if (sscanf(s+2, "%d", &i0) != 1) {
451 <                                sprintf(buf, "ambient super-samples (%d): ",
452 <                                                ambssamp);
453 <                                (*dev->comout)(buf);
454 <                                (*dev->comin)(buf, NULL);
455 <                                if (sscanf(buf, "%d", &i0) != 1)
456 <                                        break;
457 <                        }
458 <                        ambssamp = i0;
444 >                        getparam(s+2, "ambient super-samples", 'i', &ambssamp);
445                          break;
446                  case 'b':                       /* bounces */
447 <                        if (sscanf(s+2, "%d", &i0) != 1) {
462 <                                sprintf(buf, "ambient bounces (%d): ",
463 <                                                ambounce);
464 <                                (*dev->comout)(buf);
465 <                                (*dev->comin)(buf, NULL);
466 <                                if (sscanf(buf, "%d", &i0) != 1)
467 <                                        break;
468 <                        }
469 <                        ambounce = i0;
447 >                        getparam(s+2, "ambient bounces", 'i', &ambounce);
448                          break;
449                  case 'r':
450 <                        if (sscanf(s+2, "%d", &i0) != 1) {
473 <                                sprintf(buf, "ambient resolution (%d): ",
474 <                                                ambres);
475 <                                (*dev->comout)(buf);
476 <                                (*dev->comin)(buf, NULL);
477 <                                if (sscanf(buf, "%d", &i0) != 1)
478 <                                        break;
479 <                        }
480 <                        ambres = i0;
450 >                        getparam(s+2, "ambient resolution", 'i', &ambres);
451                          minarad = ambres > 0 ? thescene.cusize/ambres : 0.0;
452                          break;
453                  default:
# Line 487 | Line 457 | register char  *s;
457          case 's':                       /* sample */
458                  switch (s[1]) {
459                  case 'p':                       /* pixel */
460 <                        if (sscanf(s+2, "%d", &i0) != 1) {
491 <                                sprintf(buf, "sample pixel (%d): ", psample);
492 <                                (*dev->comout)(buf);
493 <                                (*dev->comin)(buf, NULL);
494 <                                if (sscanf(buf, "%d", &i0) != 1)
495 <                                        break;
496 <                        }
497 <                        psample = i0;
460 >                        getparam(s+2, "sample pixel", 'i', &psample);
461                          pdepth = 0;
462                          break;
463                  case 't':                       /* threshold */
464 <                        if (sscanf(s+2, "%lf", &d0) != 1) {
502 <                                sprintf(buf, "sample threshold (%.6g): ",
503 <                                                maxdiff);
504 <                                (*dev->comout)(buf);
505 <                                (*dev->comin)(buf, NULL);
506 <                                if (sscanf(buf, "%lf", &d0) != 1)
507 <                                        break;
508 <                        }
509 <                        maxdiff = d0;
464 >                        getparam(s+2, "sample threshold", 'r', &maxdiff);
465                          pdepth = 0;
466                          break;
467                  default:
# Line 541 | Line 496 | char  *s;
496                  if ((*dev->getcur)(&x, &y) == ABORT)
497                          return;
498  
499 <                viewray(thisray.rorg, thisray.rdir, &ourview,
500 <                                (x+.5)/hresolu, (y+.5)/vresolu);
501 <                
499 >                if (viewray(thisray.rorg, thisray.rdir, &ourview,
500 >                                (x+.5)/hresolu, (y+.5)/vresolu) < 0) {
501 >                        error(COMMAND, "not on image");
502 >                        return;
503 >                }
504 >
505          } else if (normalize(thisray.rdir) == 0.0) {
506                  error(COMMAND, "zero ray direction");
507                  return;
# Line 610 | Line 568 | char  *s;
568                  fputexpos(exposure, fp);
569          if (dev->pixaspect != 1.0)
570                  fputaspect(dev->pixaspect, fp);
571 +        fputformat(COLRFMT, fp);
572          putc('\n', fp);
573          fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp);
574  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines