--- ray/src/common/bsdf.h 2011/06/05 20:27:14 2.13 +++ ray/src/common/bsdf.h 2012/10/13 20:15:43 2.20 @@ -1,4 +1,4 @@ -/* RCSid $Id: bsdf.h,v 2.13 2011/06/05 20:27:14 greg Exp $ */ +/* RCSid $Id: bsdf.h,v 2.20 2012/10/13 20:15:43 greg Exp $ */ /* * bsdf.h * @@ -30,6 +30,10 @@ extern "C" { #endif +#ifdef _WIN32 +#define strcasecmp stricmp +#endif + #define SDnameLn 128 /* maximum BSDF name length */ #define SDmaxCh 3 /* maximum # spectral channels */ @@ -67,13 +71,15 @@ typedef struct { } SDValue; /* Cached, encoded, cumulative distribution for one incident (solid) angle */ -#define SD_CDIST_BASE double cTotal; \ - struct SDCDst_s *next +#define SD_CDIST_BASE(styp) double cTotal; \ + struct styp *next typedef struct SDCDst_s { - SD_CDIST_BASE; /* base fields first */ + SD_CDIST_BASE(SDCDst_s); /* base fields first */ /* ...encoded distribution extends struct */ } SDCDst; +extern const SDCDst SDemptyCD; /* empty distribution */ + /* Forward declaration of BSDF component */ typedef struct SDComp_s SDComponent; @@ -114,12 +120,15 @@ typedef struct { /* Loaded BSDF data */ typedef struct { char name[SDnameLn]; /* BSDF name (usu. derived from file) */ + char matn[SDnameLn]; /* material name */ + char makr[SDnameLn]; /* manufacturer */ char *mgf; /* geometric description (if any) */ float dim[3]; /* width, height, thickness (meters) */ SDValue rLambFront; /* diffuse front reflectance */ SDValue rLambBack; /* diffuse rear reflectance */ SDValue tLamb; /* diffuse transmission */ - SDSpectralDF *rf, *rb, *tf; /* non-diffuse BSDF components */ + SDSpectralDF *rf, *rb; /* non-diffuse BRDF components */ + SDSpectralDF *tf, *tb; /* non-diffuse BTDF components */ } SDData; /* List of loaded BSDFs */ @@ -130,9 +139,9 @@ extern struct SDCache_s { *next; } *SDcacheList; /* Global BSDF cache */ -/* BSDF cache retention preference */ -#define SDretainNone 0 /* free unreferenced data*/ -#define SDretainBSDFs 1 /* keep loaded BSDFs in cache */ +/* BSDF cache retention policies */ +#define SDretainNone 0 /* free unreferenced BSDF data */ +#define SDretainBSDFs 1 /* keep loaded BSDFs in memory */ #define SDretainAll 2 /* also keep cumulative cache data */ extern int SDretainSet; /* =SDretainNone by default */ @@ -152,6 +161,9 @@ extern void SDclipName(char res[SDnameLn], const char /* Allocate new spectral distribution function */ extern SDSpectralDF *SDnewSpectralDF(int nc); +/* Add component(s) to spectral distribution function */ +extern SDSpectralDF *SDaddComponent(SDSpectralDF *odf, int nadd); + /* Free a spectral distribution function */ extern void SDfreeSpectralDF(SDSpectralDF *df); @@ -233,66 +245,6 @@ extern SDData *loadBSDF(char *name); /* Application-specific BSDF error translator (not part of our library) */ extern char *transSDError(SDError ec); - -/*################################################################*/ -/*######### DEPRECATED DEFINITIONS AWAITING PERMANENT REMOVAL #######*/ -/* - * Header for BSDF i/o and access routines - */ - -#include "mat4.h" - /* up directions */ -typedef enum { - UDzneg=-3, - UDyneg=-2, - UDxneg=-1, - UDunknown=0, - UDxpos=1, - UDypos=2, - UDzpos=3 -} UpDir; - /* BSDF coordinate calculation routines */ - /* vectors always point away from surface */ - -typedef int b_vecf2(FVECT v, int n, void *cd); -typedef int b_ndxf2(FVECT v, void *cd); -typedef double b_radf2(int n, void *cd); - -/* Bidirectional Scattering Distribution Function */ -struct BSDF_data { - int ninc; /* number of incoming directions */ - int nout; /* number of outgoing directions */ - float dim[3]; /* width, height, thickness (meters) */ - char *mgf; /* geometric description (if any) */ - void *ib_priv; /* input basis private data */ - b_vecf2 *ib_vec; /* get input vector from index */ - b_ndxf2 *ib_ndx; /* get input index from vector */ - b_radf2 *ib_ohm; /* get input radius for index */ - void *ob_priv; /* output basis private data */ - b_vecf2 *ob_vec; /* get output vector from index */ - b_ndxf2 *ob_ndx; /* get output index from vector */ - b_radf2 *ob_ohm; /* get output radius for index */ - float *bsdf; /* scattering distribution data */ -}; /* bidirectional scattering distrib. func. */ - -#define getBSDF_incvec(v,b,i) (*(b)->ib_vec)(v,i,(b)->ib_priv) -#define getBSDF_incndx(b,v) (*(b)->ib_ndx)(v,(b)->ib_priv) -#define getBSDF_incohm(b,i) (*(b)->ib_ohm)(i,(b)->ib_priv) -#define getBSDF_outvec(v,b,o) (*(b)->ob_vec)(v,o,(b)->ob_priv) -#define getBSDF_outndx(b,v) (*(b)->ob_ndx)(v,(b)->ob_priv) -#define getBSDF_outohm(b,o) (*(b)->ob_ohm)(o,(b)->ob_priv) -#define BSDF_value(b,i,o) (b)->bsdf[(o)*(b)->ninc + (i)] - -extern struct BSDF_data *load_BSDF(char *fname); -extern void free_BSDF(struct BSDF_data *b); -extern int r_BSDF_incvec(FVECT v, struct BSDF_data *b, int i, - double rv, MAT4 xm); -extern int r_BSDF_outvec(FVECT v, struct BSDF_data *b, int o, - double rv, MAT4 xm); -extern int getBSDF_xfm(MAT4 xm, FVECT nrm, UpDir ud, char *xfbuf); - -/*######### END DEPRECATED DEFINITIONS #######*/ -/*################################################################*/ #ifdef __cplusplus }