--- ray/src/rt/rv2.c 1989/02/03 07:58:07 1.2 +++ ray/src/rt/rv2.c 1989/06/07 08:38:35 1.6 @@ -75,6 +75,7 @@ char *s; FILE *fp; char buf[128]; char *fname, *getpath(); + int change = 0; VIEW nv; if (sscanf(s, "%s", buf) == 1) { /* write parameters to a file */ @@ -94,37 +95,46 @@ char *s; (*dev->comout)(buf); (*dev->comin)(buf); if (buf[0] == CTRL(C)) return; - if (buf[0]) + if (buf[0] && buf[0] != ourview.type) { nv.type = buf[0]; - else + change++; + } else nv.type = ourview.type; sprintf(buf, "view point (%.6g %.6g %.6g): ", ourview.vp[0], ourview.vp[1], ourview.vp[2]); (*dev->comout)(buf); (*dev->comin)(buf); if (buf[0] == CTRL(C)) return; - if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) != 3) + if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3) + change++; + else VCOPY(nv.vp, ourview.vp); sprintf(buf, "view direction (%.6g %.6g %.6g): ", ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); (*dev->comout)(buf); (*dev->comin)(buf); if (buf[0] == CTRL(C)) return; - if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) != 3) + if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3) + change++; + else VCOPY(nv.vdir, ourview.vdir); sprintf(buf, "view up (%.6g %.6g %.6g): ", ourview.vup[0], ourview.vup[1], ourview.vup[2]); (*dev->comout)(buf); (*dev->comin)(buf); if (buf[0] == CTRL(C)) return; - if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) != 3) + if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3) + change++; + else VCOPY(nv.vup, ourview.vup); sprintf(buf, "view horiz and vert size (%.6g %.6g): ", ourview.horiz, ourview.vert); (*dev->comout)(buf); (*dev->comin)(buf); if (buf[0] == CTRL(C)) return; - if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) != 2) { + if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) + change++; + else { nv.horiz = ourview.horiz; nv.vert = ourview.vert; } sprintf(buf, "x and y resolution (%d %d): ", @@ -132,10 +142,13 @@ char *s; (*dev->comout)(buf); (*dev->comin)(buf); if (buf[0] == CTRL(C)) return; - if (sscanf(buf, "%d %d", &nv.hresolu, &nv.vresolu) != 2) { + if (sscanf(buf, "%d %d", &nv.hresolu, &nv.vresolu) == 2) + change++; + else { nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; } - newview(&nv); + if (change) + newview(&nv); } @@ -252,27 +265,25 @@ char *s; if (getinterest(s, 0, vc, &mag) < 0) return; - moveview(0.0, mag, vc); + moveview(0.0, 0.0, mag, vc); } getrotate(s) /* rotate camera */ char *s; { - extern double normalize(); + extern double normalize(), tan(), atan(); VIEW nv; FVECT v1; - double angle, elev; + double angle, elev, zfact; - elev = 0.0; - if (sscanf(s, "%lf %lf", &angle, &elev) < 1) { + elev = 0.0; zfact = 1.0; + if (sscanf(s, "%lf %lf %lf", &angle, &elev, &zfact) < 1) { error(COMMAND, "missing angle"); return; } - nv.type = ourview.type; VCOPY(nv.vp, ourview.vp); VCOPY(nv.vup, ourview.vup); - nv.horiz = ourview.horiz; nv.vert = ourview.vert; nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu; spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); if (elev != 0.0) { @@ -280,6 +291,15 @@ char *s; normalize(v1); spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); } + if ((nv.type = ourview.type) == VT_PAR) { + nv.horiz = ourview.horiz / zfact; + nv.vert = ourview.vert / zfact; + } else { + nv.horiz = atan(tan(ourview.horiz*(PI/180./2.))/zfact) / + (PI/180./2.); + nv.vert = atan(tan(ourview.vert*(PI/180./2.))/zfact) / + (PI/180./2.); + } newview(&nv); } @@ -288,15 +308,16 @@ getpivot(s) /* pivot viewpoint */ register char *s; { FVECT vc; - double angle, mag; + double angle, elev, mag; - if (sscanf(s, "%lf", &angle) != 1) { + elev = 0.0; + if (sscanf(s, "%lf %lf", &angle, &elev) < 1) { error(COMMAND, "missing angle"); return; } - if (getinterest(sskip(s), 0, vc, &mag) < 0) + if (getinterest(sskip(sskip(s)), 0, vc, &mag) < 0) return; - moveview(angle, mag, vc); + moveview(angle, elev, mag, vc); } @@ -348,11 +369,11 @@ char *s; e *= atof(cp); } if (p != NULL) { /* relative setting */ - if (intens(p->v) <= FTINY) { + if (bright(p->v) <= FTINY) { error(COMMAND, "cannot normalize to zero"); return; } - e *= 0.5 / intens(p->v); + e *= 0.5 / bright(p->v); } if (e <= FTINY || fabs(1.0 - e) <= FTINY) return; @@ -370,6 +391,7 @@ register char *s; extern double minweight; extern int maxdepth; extern double dstrsrc; + extern double shadthresh; extern COLOR ambval; extern double ambacc; extern double minarad; @@ -382,7 +404,7 @@ register char *s; char buf[128]; if (s[0] == '\0') { - (*dev->comout)("aa ab ad ar as av ds lr lw sd sp: "); + (*dev->comout)("aa ab ad ar as av dj dt lr lw sd sp: "); (*dev->comin)(buf); s = buf; } @@ -415,17 +437,33 @@ register char *s; goto badparam; } break; - case 'd': /* distribute source */ - if (s[1] != 's') + case 'd': /* direct */ + switch (s[1]) { + case 'j': /* jitter */ + if (sscanf(s+2, "%lf", &d0) != 1) { + sprintf(buf, "direct jitter (%.6g): ", + dstrsrc); + (*dev->comout)(buf); + (*dev->comin)(buf); + if (sscanf(buf, "%lf", &d0) != 1) + break; + } + dstrsrc = d0; + break; + case 't': /* threshold */ + if (sscanf(s+2, "%lf", &d0) != 1) { + sprintf(buf, "direct threshold (%.6g): ", + shadthresh); + (*dev->comout)(buf); + (*dev->comin)(buf); + if (sscanf(buf, "%lf", &d0) != 1) + break; + } + shadthresh = d0; + break; + default: goto badparam; - if (sscanf(s+2, "%lf", &d0) != 1) { - sprintf(buf, "distribute source (%.6g): ", dstrsrc); - (*dev->comout)(buf); - (*dev->comin)(buf); - if (sscanf(buf, "%lf", &d0) != 1) - break; } - dstrsrc = d0; break; case 'a': /* ambient */ switch (s[1]) {