--- ray/src/common/image.c 2004/01/01 19:47:05 2.25 +++ ray/src/common/image.c 2005/02/07 20:13:55 2.30 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: image.c,v 2.25 2004/01/01 19:47:05 greg Exp $"; +static const char RCSid[] = "$Id: image.c,v 2.30 2005/02/07 20:13:55 greg Exp $"; #endif /* * image.c - routines for image generation. @@ -10,6 +10,8 @@ static const char RCSid[] = "$Id: image.c,v 2.25 2004/ #include "copyright.h" #include "rtio.h" +#include "rtmath.h" +#include "paths.h" #include "view.h" @@ -19,7 +21,9 @@ static const char RCSid[] = "$Id: image.c,v 2.25 2004/ VIEW stdview = STDVIEW; /* default view parameters */ +static gethfunc gethview; + char * setview(v) /* set hvec and vvec, return message on error */ register VIEW *v; @@ -30,7 +34,8 @@ register VIEW *v; if (v->vaft < -FTINY || (v->vaft > FTINY && v->vaft <= v->vfore)) return("illegal fore/aft clipping plane"); - if (normalize(v->vdir) == 0.0) /* normalize direction */ + v->vdist *= normalize(v->vdir); /* normalize direction */ + if (v->vdist == 0.0) return("zero view direction"); if (normalize(v->vup) == 0.0) /* normalize view up */ @@ -344,6 +349,7 @@ register char *av[]; v->vdir[0] = atof(av[1]); v->vdir[1] = atof(av[2]); v->vdir[2] = atof(av[3]); + v->vdist = 1.; return(3); case 'u': /* up */ check(3,"fff"); @@ -424,7 +430,9 @@ FILE *fp; { fprintf(fp, " -vt%c", vp->type); fprintf(fp, " -vp %.6g %.6g %.6g", vp->vp[0], vp->vp[1], vp->vp[2]); - fprintf(fp, " -vd %.6g %.6g %.6g", vp->vdir[0], vp->vdir[1], vp->vdir[2]); + fprintf(fp, " -vd %.6g %.6g %.6g", vp->vdir[0]*vp->vdist, + vp->vdir[1]*vp->vdist, + vp->vdir[2]*vp->vdist); fprintf(fp, " -vu %.6g %.6g %.6g", vp->vup[0], vp->vup[1], vp->vup[2]); fprintf(fp, " -vh %.6g -vv %.6g", vp->horiz, vp->vert); fprintf(fp, " -vo %.6g -va %.6g", vp->vfore, vp->vaft); @@ -448,9 +456,11 @@ register VIEW *vp; vp->vp[0], vp->vp[1], vp->vp[2]); cp += strlen(cp); } - if (!VEQ(vp->vdir,stdview.vdir)) { + if (!FEQ(vp->vdist,stdview.vdist) || !VEQ(vp->vdir,stdview.vdir)) { sprintf(cp, " -vd %.6g %.6g %.6g", - vp->vdir[0], vp->vdir[1], vp->vdir[2]); + vp->vdir[0]*vp->vdist, + vp->vdir[1]*vp->vdist, + vp->vdir[2]*vp->vdist); cp += strlen(cp); } if (!VEQ(vp->vup,stdview.vup)) { @@ -522,12 +532,13 @@ struct myview { static int -gethview(s, v) /* get view from header */ -char *s; -register struct myview *v; +gethview( /* get view from header */ + char *s, + void *v +) { - if (isview(s) && sscanview(v->hv, s) > 0) - v->ok++; + if (isview(s) && sscanview(((struct myview*)v)->hv, s) > 0) + ((struct myview*)v)->ok++; return(0); } @@ -549,7 +560,7 @@ RESOLU *rp; mvs.hv = vp; mvs.ok = 0; - getheader(fp, (int (*)(char *, char *))&gethview, (char *)&mvs); + getheader(fp, gethview, &mvs); if (rp != NULL && !fgetsresolu(rp, fp)) mvs.ok = 0;