--- ray/src/rt/rv2.c 2008/09/05 19:45:41 2.58 +++ ray/src/rt/rv2.c 2012/09/06 00:07:43 2.63 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rv2.c,v 2.58 2008/09/05 19:45:41 greg Exp $"; +static const char RCSid[] = "$Id: rv2.c,v 2.63 2012/09/06 00:07:43 greg Exp $"; #endif /* * rv2.c - command routines used in tracing a view. @@ -13,6 +13,8 @@ static const char RCSid[] = "$Id: rv2.c,v 2.58 2008/09 #include #include "platform.h" +#include "rtprocess.h" /* win_popen() */ +#include "paths.h" #include "ray.h" #include "source.h" #include "ambient.h" @@ -61,7 +63,7 @@ getrepaint( /* get area and repaint */ void -getview( /* get/show view parameters */ +getview( /* get/show/save view parameters */ char *s ) { @@ -80,7 +82,7 @@ getview( /* get/show view parameters */ error(COMMAND, "bad view option(s)"); return; } - if (sscanf(s, "%s", buf) == 1) { /* write parameters to a file */ + if (nextword(buf, sizeof(buf), s) != NULL) { /* write to a file */ if ((fname = getpath(buf, NULL, 0)) == NULL || (fp = fopen(fname, "a")) == NULL) { sprintf(errmsg, "cannot open \"%s\"", buf); @@ -162,8 +164,8 @@ lastview( /* return to a previous view */ char *fname; int success; VIEW nv; - - if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ + /* get parameters from a file */ + if (nextword(buf, sizeof(buf), s) != NULL) { nv = stdview; if ((fname = getpath(buf, "", R_OK)) == NULL || (success = viewfile(fname, &nv, NULL)) == -1) { @@ -204,11 +206,7 @@ saveview( /* save view to rad file */ } s = sskip(s); } - while (isspace(*s)) - s++; - if (*s) - atos(rifname, sizeof(rifname), s); - else if (rifname[0] == '\0') { + if (nextword(rifname, sizeof(rifname), s) == NULL && !rifname[0]) { error(COMMAND, "no previous rad file"); return; } @@ -241,9 +239,7 @@ loadview( /* load view from rad file */ s = sskip(s); else strcat(buf, "1"); - if (*s) - atos(rifname, sizeof(rifname), s); - else if (rifname[0] == '\0') { + if (nextword(rifname, sizeof(rifname), s) == NULL && !rifname[0]) { error(COMMAND, "no previous rad file"); return; } @@ -341,7 +337,6 @@ getrotate( /* rotate camera */ ) { VIEW nv = ourview; - FVECT v1; double angle, elev, zfact; elev = 0.0; zfact = 1.0; @@ -350,11 +345,9 @@ getrotate( /* rotate camera */ return; } spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); - if (elev != 0.0) { - fcross(v1, nv.vdir, ourview.vup); - normalize(v1); - spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); - } + if (elev != 0.0) + geodesic(nv.vdir, nv.vdir, nv.vup, elev*(PI/180.), GEOD_RAD); + zoomview(&nv, zfact); newview(&nv); } @@ -534,11 +527,12 @@ setparam( /* get/set program parameter */ char *s ) { + int prev_newp = newparam; char buf[128]; if (s[0] == '\0') { (*dev->comout)( - "aa ab ad ar as av aw b bv dc dv dj ds dt i lr lw me ma mg ms ps pt sj st u: "); + "aa ab ad ar as av aw b bv dc dv dj ds dt i lr lw me ma mg ms ps pt ss st u: "); (*dev->comin)(buf, NULL); s = buf; } @@ -599,6 +593,7 @@ setparam( /* get/set program parameter */ case 'n': case 'N': case 'f': case 'F': case '0': case '-': getparam(s+1, "black and white", 'b', (void *)&greyscale); + newparam = prev_newp; break; default: goto badparam; @@ -681,11 +676,12 @@ setparam( /* get/set program parameter */ default: goto badparam; } + newparam = prev_newp; break; case 's': /* specular */ switch (s[1]) { - case 'j': /* jitter */ - getparam(s+2, "specular jitter", 'r', + case 's': /* sampling */ + getparam(s+2, "specular sampling", 'r', (void *)&specjitter); break; case 't': /* threshold */ @@ -713,15 +709,14 @@ traceray( /* trace a single ray */ char *s ) { - char buf[128]; - int x, y; - OBJREC *ino; - RAY thisray; + RAY thisray; + char buf[512]; thisray.rmax = 0.0; if (!sscanvec(s, thisray.rorg) || !sscanvec(sskip2(s,3), thisray.rdir)) { + int x, y; if (dev->getcur == NULL) return; @@ -748,6 +743,8 @@ traceray( /* trace a single ray */ OBJREC *mat = NULL; OBJREC *mod = NULL; char matspec[256]; + OBJREC *ino; + matspec[0] = '\0'; if (thisray.ro->omod != OVOID) { mod = objptr(thisray.ro->omod); @@ -800,12 +797,8 @@ writepict( /* write the picture to a file */ FILE *fp; COLR *scanline; int y; - - while (isspace(*s)) - s++; - if (*s) - atos(buf, sizeof(buf), s); - else if (buf[0] == '\0') { + /* XXX relies on words.c 2.11 behavior */ + if (nextword(buf, sizeof(buf), s) == NULL && !buf[0]) { error(COMMAND, "no file"); return; }