| 1 |
/* RCSid $Id: bsdf.h,v 2.1 2009/06/12 17:37:37 greg Exp $ */
|
| 2 |
/*
|
| 3 |
* Header for BSDF i/o and access routines
|
| 4 |
*/
|
| 5 |
/* up directions */
|
| 6 |
typedef enum {
|
| 7 |
UDzneg=-3,
|
| 8 |
UDyneg=-2,
|
| 9 |
UDxneg=-1,
|
| 10 |
UDunknown=0,
|
| 11 |
UDxpos=1,
|
| 12 |
UDypos=2,
|
| 13 |
UDzpos=3
|
| 14 |
} UpDir;
|
| 15 |
/* BSDF coordinate calculation routines */
|
| 16 |
/* vectors always point away from surface */
|
| 17 |
typedef int b_vecf(FVECT, int, void *);
|
| 18 |
typedef int b_ndxf(FVECT, void *);
|
| 19 |
typedef double b_radf(int, void *);
|
| 20 |
|
| 21 |
/* Bidirectional Scattering Distribution Function */
|
| 22 |
struct BSDF_data {
|
| 23 |
int ninc; /* number of incoming directions */
|
| 24 |
int nout; /* number of outgoing directions */
|
| 25 |
void *ib_priv; /* input basis private data */
|
| 26 |
b_vecf *ib_vec; /* get input vector from index */
|
| 27 |
b_ndxf *ib_ndx; /* get input index from vector */
|
| 28 |
b_radf *ib_ohm; /* get input radius for index */
|
| 29 |
void *ob_priv; /* output basis private data */
|
| 30 |
b_vecf *ob_vec; /* get output vector from index */
|
| 31 |
b_ndxf *ob_ndx; /* get output index from vector */
|
| 32 |
b_radf *ob_ohm; /* get output radius for index */
|
| 33 |
float *bsdf; /* scattering distribution data */
|
| 34 |
}; /* bidirectional scattering distrib. func. */
|
| 35 |
|
| 36 |
#define getBSDF_incvec(v,b,i) (*(b)->ib_vec)(v,i,(b)->ib_priv)
|
| 37 |
#define getBSDF_incndx(b,v) (*(b)->ib_ndx)(v,(b)->ib_priv)
|
| 38 |
#define getBSDF_incohm(b,i) (*(b)->ib_ohm)(i,(b)->ib_priv)
|
| 39 |
#define getBSDF_outvec(v,b,o) (*(b)->ob_vec)(v,o,(b)->ob_priv)
|
| 40 |
#define getBSDF_outndx(b,v) (*(b)->ob_ndx)(v,(b)->ob_priv)
|
| 41 |
#define getBSDF_outohm(b,o) (*(b)->ob_ohm)(o,(b)->ob_priv)
|
| 42 |
#define BSDF_value(b,i,o) (b)->bsdf[(o)*(b)->ninc + (i)]
|
| 43 |
|
| 44 |
extern struct BSDF_data *load_BSDF(char *fname);
|
| 45 |
extern void free_BSDF(struct BSDF_data *b);
|
| 46 |
extern int r_BSDF_incvec(FVECT v, struct BSDF_data *b, int i,
|
| 47 |
double rv, MAT4 xm);
|
| 48 |
extern int r_BSDF_outvec(FVECT v, struct BSDF_data *b, int o,
|
| 49 |
double rv, MAT4 xm);
|
| 50 |
extern int getBSDF_xfm(MAT4 xm, FVECT nrm, UpDir ud);
|