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