1 |
/* RCSid $Id: bsdf_m.h,v 3.3 2011/02/19 01:48:59 greg Exp $ */ |
2 |
/* |
3 |
* bsdf_m.h |
4 |
* |
5 |
* Support for BSDF matrices. |
6 |
* Assumes "bsdf.h" already included. |
7 |
* Include after "ezxml.h" for SDloadMtx() declaration. |
8 |
* |
9 |
* Created by Greg Ward on 2/2/11. |
10 |
* |
11 |
*/ |
12 |
|
13 |
#ifndef _BSDF_M_H_ |
14 |
#define _BSDF_M_H_ |
15 |
|
16 |
#ifdef __cplusplus |
17 |
extern "C" { |
18 |
#endif |
19 |
/* Fixed-position coordinate functions */ |
20 |
typedef int b_vecf(FVECT vec, double ndxr, void *c_data); |
21 |
typedef int b_ndxf(const FVECT vec, void *c_data); |
22 |
typedef double b_ohmf(int ndx, void *c_data); |
23 |
|
24 |
/* Rectangular matrix format BSDF */ |
25 |
typedef struct { |
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_ohmf *ib_ohm; /* get input proj. SA 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_ohmf *ob_ohm; /* get output proj. SA for index */ |
36 |
float bsdf[1]; /* scattering data (extends struct) */ |
37 |
} SDMat; |
38 |
|
39 |
/* Matrix BSDF accessors */ |
40 |
#define mBSDF_incvec(v,b,ix) (*(b)->ib_vec)(v,ix,(b)->ib_priv) |
41 |
#define mBSDF_incndx(b,v) (*(b)->ib_ndx)(v,(b)->ib_priv) |
42 |
#define mBSDF_incohm(b,i) (*(b)->ib_ohm)(i,(b)->ib_priv) |
43 |
#define mBSDF_outvec(v,b,ox) (*(b)->ob_vec)(v,ox,(b)->ob_priv) |
44 |
#define mBSDF_outndx(b,v) (*(b)->ob_ndx)(v,(b)->ob_priv) |
45 |
#define mBSDF_outohm(b,o) (*(b)->ob_ohm)(o,(b)->ob_priv) |
46 |
#define mBSDF_value(b,i,o) (b)->bsdf[(o)*(b)->ninc + (i)] |
47 |
|
48 |
/* Holder for cumulative distribution (sum of BSDF * projSA) */ |
49 |
typedef struct { |
50 |
SD_CDIST_BASE; /* base fields; must come first */ |
51 |
int indx; /* incident angle index */ |
52 |
void *ob_priv; /* private data for generator */ |
53 |
b_vecf *ob_vec; /* outbound vector generator */ |
54 |
int calen; /* cumulative array length */ |
55 |
unsigned carr[1]; /* cumulative array (extends struct) */ |
56 |
} SDMatCDst; |
57 |
|
58 |
#ifdef _EZXML_H |
59 |
/* Load a set of BSDF matrices from an open XML file */ |
60 |
extern SDError SDloadMtx(SDData *sd, ezxml_t wtl); |
61 |
#endif |
62 |
|
63 |
/* Our matrix handling routines */ |
64 |
extern SDFunc SDhandleMtx; |
65 |
|
66 |
#ifdef __cplusplus |
67 |
} |
68 |
#endif |
69 |
#endif /* ! _BSDF_M_H_ */ |