--- ray/src/common/image.c 2003/08/26 04:24:26 2.19 +++ ray/src/common/image.c 2005/01/18 00:33:16 2.29 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: image.c,v 2.19 2003/08/26 04:24:26 greg Exp $"; +static const char RCSid[] = "$Id: image.c,v 2.29 2005/01/18 00:33:16 greg Exp $"; #endif /* * image.c - routines for image generation. @@ -9,11 +9,11 @@ static const char RCSid[] = "$Id: image.c,v 2.19 2003/ #include "copyright.h" -#include "standard.h" - +#include "rtio.h" +#include "rtmath.h" +#include "paths.h" #include "view.h" -#include "paths.h" #define FEQ(x,y) (fabs((x)-(y)) <= FTINY) #define VEQ(v,w) (FEQ((v)[0],(w)[0]) && FEQ((v)[1],(w)[1]) \ @@ -21,7 +21,9 @@ static const char RCSid[] = "$Id: image.c,v 2.19 2003/ VIEW stdview = STDVIEW; /* default view parameters */ +static gethfunc gethview; + char * setview(v) /* set hvec and vvec, return message on error */ register VIEW *v; @@ -32,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 */ @@ -394,12 +397,15 @@ register char *s; int na; int nvopts = 0; - while (*s && *s != ' ') + while (*s == ' ') s++; + if (*s != '-') + s = sskip2(s,1); while (*s) { ac = 0; do { - av[ac++] = s; + if (ac || *s == '-') + av[ac++] = s; while (*s && *s != ' ') s++; while (*s == ' ') @@ -423,7 +429,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); @@ -447,9 +455,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)) { @@ -489,7 +499,7 @@ int isview(s) /* is this a view string? */ char *s; { - static char *altname[]={NULL,VIEWSTR,"rpict","rview","pinterp",NULL}; + static char *altname[]={NULL,VIEWSTR,"rpict","rview","rvu","rpiece","pinterp",NULL}; extern char *progname; register char *cp; register char **an; @@ -521,12 +531,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); } @@ -548,7 +559,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;