1 |
greg |
3.7 |
/* RCSid $Id: bsdf_m.h,v 3.6 2013/04/21 22:58:40 greg Exp $ */ |
2 |
greg |
3.1 |
/* |
3 |
|
|
* bsdf_m.h |
4 |
|
|
* |
5 |
greg |
3.4 |
* Support for BSDF matrices. |
6 |
|
|
* Assumes "bsdf.h" already included. |
7 |
|
|
* Include after "ezxml.h" for SDloadMtx() declaration. |
8 |
greg |
3.1 |
* |
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 |
greg |
3.4 |
typedef int b_vecf(FVECT vec, double ndxr, void *c_data); |
21 |
greg |
3.1 |
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 |
greg |
3.7 |
C_CHROMA *chroma; /* chromaticity data */ |
37 |
greg |
3.1 |
float bsdf[1]; /* scattering data (extends struct) */ |
38 |
|
|
} SDMat; |
39 |
|
|
|
40 |
|
|
/* Matrix BSDF accessors */ |
41 |
greg |
3.4 |
#define mBSDF_incvec(v,b,ix) (*(b)->ib_vec)(v,ix,(b)->ib_priv) |
42 |
greg |
3.1 |
#define mBSDF_incndx(b,v) (*(b)->ib_ndx)(v,(b)->ib_priv) |
43 |
|
|
#define mBSDF_incohm(b,i) (*(b)->ib_ohm)(i,(b)->ib_priv) |
44 |
greg |
3.4 |
#define mBSDF_outvec(v,b,ox) (*(b)->ob_vec)(v,ox,(b)->ob_priv) |
45 |
greg |
3.1 |
#define mBSDF_outndx(b,v) (*(b)->ob_ndx)(v,(b)->ob_priv) |
46 |
|
|
#define mBSDF_outohm(b,o) (*(b)->ob_ohm)(o,(b)->ob_priv) |
47 |
|
|
#define mBSDF_value(b,i,o) (b)->bsdf[(o)*(b)->ninc + (i)] |
48 |
|
|
|
49 |
|
|
/* Holder for cumulative distribution (sum of BSDF * projSA) */ |
50 |
greg |
3.5 |
typedef struct SDMatCDst_s { |
51 |
|
|
SD_CDIST_BASE(SDMatCDst_s); /* base fields; must come first */ |
52 |
greg |
3.1 |
int indx; /* incident angle index */ |
53 |
|
|
void *ob_priv; /* private data for generator */ |
54 |
|
|
b_vecf *ob_vec; /* outbound vector generator */ |
55 |
|
|
int calen; /* cumulative array length */ |
56 |
|
|
unsigned carr[1]; /* cumulative array (extends struct) */ |
57 |
|
|
} SDMatCDst; |
58 |
|
|
|
59 |
greg |
3.4 |
#ifdef _EZXML_H |
60 |
greg |
3.1 |
/* Load a set of BSDF matrices from an open XML file */ |
61 |
greg |
3.3 |
extern SDError SDloadMtx(SDData *sd, ezxml_t wtl); |
62 |
greg |
3.4 |
#endif |
63 |
greg |
3.1 |
|
64 |
|
|
/* Our matrix handling routines */ |
65 |
|
|
extern SDFunc SDhandleMtx; |
66 |
|
|
|
67 |
greg |
3.6 |
/******** Klems basis declarations for more intimate access ********/ |
68 |
|
|
|
69 |
|
|
#define MAXLATS 46 /* maximum number of latitudes */ |
70 |
|
|
|
71 |
|
|
/* BSDF angle specification */ |
72 |
|
|
typedef struct { |
73 |
|
|
char name[64]; /* basis name */ |
74 |
|
|
int nangles; /* total number of directions */ |
75 |
|
|
struct { |
76 |
|
|
float tmin; /* starting theta */ |
77 |
|
|
int nphis; /* number of phis (0 term) */ |
78 |
|
|
} lat[MAXLATS+1]; /* latitudes */ |
79 |
|
|
} ANGLE_BASIS; |
80 |
|
|
|
81 |
|
|
#define MAXABASES 7 /* limit on defined bases */ |
82 |
|
|
|
83 |
|
|
extern ANGLE_BASIS abase_list[MAXABASES]; |
84 |
|
|
|
85 |
|
|
extern int nabases; /* current number of defined bases */ |
86 |
|
|
|
87 |
greg |
3.7 |
extern C_COLOR mtx_RGB_prim[3]; /* matrix RGB primaries */ |
88 |
|
|
extern float mtx_RGB_coef[3]; /* corresponding Y coefficients */ |
89 |
|
|
|
90 |
|
|
/* Get color or grayscale value for BSDF in the given directions */ |
91 |
|
|
extern int mBSDF_color(float coef[], const SDMat *b, int i, int o); |
92 |
|
|
|
93 |
greg |
3.6 |
/* Get vector for this angle basis index (front exiting) */ |
94 |
|
|
extern b_vecf fo_getvec; |
95 |
|
|
|
96 |
|
|
/* Get index corresponding to the given vector (front exiting) */ |
97 |
|
|
extern b_ndxf fo_getndx; |
98 |
|
|
|
99 |
|
|
/* Get projected solid angle for this angle basis index (universal) */ |
100 |
|
|
extern b_ohmf io_getohm; |
101 |
|
|
|
102 |
|
|
/* Get vector for this angle basis index (back incident) */ |
103 |
|
|
extern b_vecf bi_getvec; |
104 |
|
|
|
105 |
|
|
/* Get index corresponding to the vector (back incident) */ |
106 |
|
|
extern b_ndxf bi_getndx; |
107 |
|
|
|
108 |
|
|
/* Get vector for this angle basis index (back exiting) */ |
109 |
|
|
extern b_vecf bo_getvec; |
110 |
|
|
|
111 |
|
|
/* Get index corresponding to the vector (back exiting) */ |
112 |
|
|
extern b_ndxf bo_getndx; |
113 |
|
|
|
114 |
|
|
/* Get vector for this angle basis index (front incident) */ |
115 |
|
|
extern b_vecf fi_getvec; |
116 |
|
|
|
117 |
|
|
/* Get index corresponding to the vector (front incident) */ |
118 |
|
|
extern b_ndxf fi_getndx; |
119 |
|
|
|
120 |
greg |
3.1 |
#ifdef __cplusplus |
121 |
|
|
} |
122 |
|
|
#endif |
123 |
|
|
#endif /* ! _BSDF_M_H_ */ |