--- ray/src/common/view.h 2003/06/06 16:38:47 2.9 +++ ray/src/common/view.h 2018/04/27 05:00:29 2.20 @@ -1,25 +1,25 @@ -/* RCSid $Id: view.h,v 2.9 2003/06/06 16:38:47 schorsch Exp $ */ +/* RCSid $Id: view.h,v 2.20 2018/04/27 05:00:29 greg Exp $ */ /* * view.h - header file for image generation. * - * Include after fvect.h + * Include after stdio.h and rtmath.h * Includes resolu.h */ #ifndef _RAD_VIEW_H_ #define _RAD_VIEW_H_ + +#include "resolu.h" + #ifdef __cplusplus extern "C" { #endif -#include "copyright.h" - -#include "resolu.h" - /* view types */ #define VT_PER 'v' /* perspective */ #define VT_PAR 'l' /* parallel */ #define VT_ANG 'a' /* angular fisheye */ #define VT_HEM 'h' /* hemispherical fisheye */ +#define VT_PLS 's' /* planispheric fisheye */ #define VT_CYL 'c' /* cylindrical panorama */ typedef struct { @@ -27,6 +27,7 @@ typedef struct { FVECT vp; /* view origin */ FVECT vdir; /* view direction */ FVECT vup; /* view up */ + double vdist; /* view distance */ double horiz; /* horizontal view size */ double vert; /* vertical view size */ double hoff; /* horizontal image offset */ @@ -44,18 +45,24 @@ extern VIEW stdview; #define viewaspect(v) sqrt((v)->vn2/(v)->hn2) #define STDVIEW {VT_PER,{0.,0.,0.},{0.,1.,0.},{0.,0.,1.}, \ - 45.,45.,0.,0.,0.,0., \ + 1.,45.,45.,0.,0.,0.,0., \ {0.,0.,0.},{0.,0.,0.},0.,0.} #define VIEWSTR "VIEW=" #define VIEWSTRL 5 + /* return values/flags for viewloc() */ +#define VL_BAD 0 /* illegal position (i.e. origin) */ +#define VL_GOOD 0x1 /* result is valid */ +#define VL_BEHIND 0x2 /* world point is behind fore plane */ +#define VL_OUTSIDE 0x4 /* world point is outside frustum */ +#define VL_BEYOND 0x8 /* point is beyond aft clipping plane */ extern char *setview(VIEW *v); extern void normaspect(double va, double *ap, int *xp, int *yp); extern double viewray(FVECT orig, FVECT direc, VIEW *v, double x, double y); -extern void viewloc(FVECT ip, VIEW *v, FVECT p); -extern void pix2loc(FLOAT loc[2], RESOLU *rp, int px, int py); +extern int viewloc(FVECT ip, VIEW *v, FVECT p); +extern void pix2loc(RREAL loc[2], RESOLU *rp, int px, int py); extern void loc2pix(int pp[2], RESOLU *rp, double lx, double ly); extern int getviewopt(VIEW *v, int ac, char *av[]); extern int sscanview(VIEW *vp, char *s);