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