--- ray/src/rt/rv2.c 2005/01/18 00:33:16 2.44 +++ ray/src/rt/rv2.c 2005/04/14 17:38:06 2.48 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rv2.c,v 2.44 2005/01/18 00:33:16 greg Exp $"; +static const char RCSid[] = "$Id: rv2.c,v 2.48 2005/04/14 17:38:06 greg Exp $"; #endif /* * rv2.c - command routines used in tracing a view. @@ -14,6 +14,7 @@ static const char RCSid[] = "$Id: rv2.c,v 2.44 2005/01 #include "platform.h" #include "ray.h" +#include "source.h" #include "ambient.h" #include "otypes.h" #include "rpaint.h" @@ -109,12 +110,16 @@ getview( /* get/show view parameters */ if (sscanvec(buf, nv.vp)) change++; sprintf(buf, "view direction (%.6g %.6g %.6g): ", - ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); + ourview.vdir[0]*ourview.vdist, + ourview.vdir[1]*ourview.vdist, + ourview.vdir[2]*ourview.vdist); (*dev->comout)(buf); (*dev->comin)(buf, NULL); if (buf[0] == CTRL('C')) return; - if (sscanvec(buf, nv.vdir)) + if (sscanvec(buf, nv.vdir)) { + nv.vdist = 1.; change++; + } sprintf(buf, "view up (%.6g %.6g %.6g): ", ourview.vup[0], ourview.vup[1], ourview.vup[2]); (*dev->comout)(buf); @@ -280,6 +285,41 @@ getaim( /* aim camera */ extern void +getfocus( /* set focus distance */ + char *s +) +{ + FVECT vc; + double dist; + + if (sscanf(s, "%lf", &dist) < 1) { + int x, y; + RAY thisray; + if (dev->getcur == NULL) + return; + (*dev->comout)("Pick focus point\n"); + if ((*dev->getcur)(&x, &y) == ABORT) + return; + if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, + &ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) { + error(COMMAND, "not on image"); + return; + } + rayorigin(&thisray, NULL, PRIMARY, 1.0); + if (!localhit(&thisray, &thescene)) { + error(COMMAND, "not a local object"); + return; + } + dist = thisray.rot; + } else if (dist <= .0) { + error(COMMAND, "focus distance must be positive"); + return; + } + ourview.vdist = dist; +} + + +extern void getmove( /* move camera */ char *s ) @@ -686,10 +726,24 @@ char *s; if (thisray.ro == NULL) (*dev->comout)("ray hit nothing"); else { - sprintf(buf, "ray hit %s%s %s \"%s\"", - thisray.rod < 0.0 ? "back of " : "", - thisray.ro->omod == OVOID ? VOIDID : - objptr(thisray.ro->omod)->oname, + OBJREC *mat = NULL; + OBJREC *mod = NULL;; + char matspec[256]; + matspec[0] = '\0'; + if (thisray.ro->omod != OVOID) { + mod = objptr(thisray.ro->omod); + mat = findmaterial(mod); + } + if (thisray.rod < 0.0) + strcpy(matspec, "back of "); + if (mod != NULL) { + strcat(matspec, mod->oname); + if (mat != mod && mat != NULL) + sprintf(matspec+strlen(matspec), + " (%s)", mat->oname); + } else + strcat(matspec, VOIDID); + sprintf(buf, "ray hit %s %s \"%s\"", matspec, ofun[thisray.ro->otype].funame, thisray.ro->oname); if ((ino = objptr(thisray.robj)) != thisray.ro)