| 1 |
greg |
2.23 |
/* RCSid $Id: view.h,v 2.22 2022/01/12 21:07:39 greg Exp $ */
|
| 2 |
greg |
1.1 |
/*
|
| 3 |
|
|
* view.h - header file for image generation.
|
| 4 |
|
|
*
|
| 5 |
greg |
2.16 |
* Include after stdio.h and rtmath.h
|
| 6 |
greg |
2.7 |
* Includes resolu.h
|
| 7 |
|
|
*/
|
| 8 |
schorsch |
2.9 |
#ifndef _RAD_VIEW_H_
|
| 9 |
|
|
#define _RAD_VIEW_H_
|
| 10 |
schorsch |
2.13 |
|
| 11 |
|
|
#include "resolu.h"
|
| 12 |
|
|
|
| 13 |
schorsch |
2.9 |
#ifdef __cplusplus
|
| 14 |
|
|
extern "C" {
|
| 15 |
|
|
#endif
|
| 16 |
greg |
2.7 |
|
| 17 |
greg |
1.1 |
/* view types */
|
| 18 |
|
|
#define VT_PER 'v' /* perspective */
|
| 19 |
|
|
#define VT_PAR 'l' /* parallel */
|
| 20 |
greg |
1.6 |
#define VT_ANG 'a' /* angular fisheye */
|
| 21 |
|
|
#define VT_HEM 'h' /* hemispherical fisheye */
|
| 22 |
greg |
2.18 |
#define VT_PLS 's' /* planispheric fisheye */
|
| 23 |
greg |
2.5 |
#define VT_CYL 'c' /* cylindrical panorama */
|
| 24 |
greg |
1.1 |
|
| 25 |
|
|
typedef struct {
|
| 26 |
|
|
int type; /* view type */
|
| 27 |
|
|
FVECT vp; /* view origin */
|
| 28 |
|
|
FVECT vdir; /* view direction */
|
| 29 |
|
|
FVECT vup; /* view up */
|
| 30 |
greg |
2.17 |
double vdist; /* view distance */
|
| 31 |
greg |
1.1 |
double horiz; /* horizontal view size */
|
| 32 |
|
|
double vert; /* vertical view size */
|
| 33 |
greg |
1.4 |
double hoff; /* horizontal image offset */
|
| 34 |
|
|
double voff; /* vertical image offset */
|
| 35 |
greg |
2.4 |
double vfore; /* fore clipping plane */
|
| 36 |
|
|
double vaft; /* aft clipping plane (<=0 for inf) */
|
| 37 |
greg |
1.4 |
FVECT hvec; /* computed horizontal image vector */
|
| 38 |
|
|
FVECT vvec; /* computed vertical image vector */
|
| 39 |
|
|
double hn2; /* DOT(hvec,hvec) */
|
| 40 |
|
|
double vn2; /* DOT(vvec,vvec) */
|
| 41 |
greg |
1.1 |
} VIEW; /* view parameters */
|
| 42 |
|
|
|
| 43 |
|
|
extern VIEW stdview;
|
| 44 |
|
|
|
| 45 |
greg |
1.4 |
#define viewaspect(v) sqrt((v)->vn2/(v)->hn2)
|
| 46 |
|
|
|
| 47 |
greg |
2.3 |
#define STDVIEW {VT_PER,{0.,0.,0.},{0.,1.,0.},{0.,0.,1.}, \
|
| 48 |
greg |
2.17 |
1.,45.,45.,0.,0.,0.,0., \
|
| 49 |
greg |
2.4 |
{0.,0.,0.},{0.,0.,0.},0.,0.}
|
| 50 |
greg |
1.1 |
|
| 51 |
|
|
#define VIEWSTR "VIEW="
|
| 52 |
greg |
1.7 |
#define VIEWSTRL 5
|
| 53 |
greg |
2.7 |
|
| 54 |
greg |
2.20 |
/* return values/flags for viewloc() */
|
| 55 |
|
|
#define VL_BAD 0 /* illegal position (i.e. origin) */
|
| 56 |
|
|
#define VL_GOOD 0x1 /* result is valid */
|
| 57 |
|
|
#define VL_BEHIND 0x2 /* world point is behind fore plane */
|
| 58 |
|
|
#define VL_OUTSIDE 0x4 /* world point is outside frustum */
|
| 59 |
|
|
#define VL_BEYOND 0x8 /* point is beyond aft clipping plane */
|
| 60 |
greg |
2.7 |
|
| 61 |
greg |
2.23 |
extern char *progname; /* global argv[0] */
|
| 62 |
|
|
extern char *fixargv0(char *arg0);
|
| 63 |
greg |
2.7 |
extern char *setview(VIEW *v);
|
| 64 |
greg |
2.22 |
extern char *cropview(VIEW *v, double x0, double y0, double x1, double y1);
|
| 65 |
greg |
2.7 |
extern void normaspect(double va, double *ap, int *xp, int *yp);
|
| 66 |
|
|
extern double viewray(FVECT orig, FVECT direc, VIEW *v, double x, double y);
|
| 67 |
greg |
2.21 |
extern int jitteraperture(FVECT orig, FVECT direc, VIEW *v, double dia);
|
| 68 |
greg |
2.19 |
extern int viewloc(FVECT ip, VIEW *v, FVECT p);
|
| 69 |
schorsch |
2.10 |
extern void pix2loc(RREAL loc[2], RESOLU *rp, int px, int py);
|
| 70 |
greg |
2.7 |
extern void loc2pix(int pp[2], RESOLU *rp, double lx, double ly);
|
| 71 |
|
|
extern int getviewopt(VIEW *v, int ac, char *av[]);
|
| 72 |
|
|
extern int sscanview(VIEW *vp, char *s);
|
| 73 |
|
|
extern void fprintview(VIEW *vp, FILE *fp);
|
| 74 |
|
|
extern char *viewopt(VIEW *vp);
|
| 75 |
|
|
extern int isview(char *s);
|
| 76 |
|
|
extern int viewfile(char *fname, VIEW *vp, RESOLU *rp);
|
| 77 |
|
|
|
| 78 |
schorsch |
2.9 |
|
| 79 |
|
|
#ifdef __cplusplus
|
| 80 |
|
|
}
|
| 81 |
greg |
2.7 |
#endif
|
| 82 |
schorsch |
2.9 |
#endif /* _RAD_VIEW_H_ */
|
| 83 |
|
|
|