| 10 |
|
#include "rmatrix.h" |
| 11 |
|
#include "platform.h" |
| 12 |
|
|
| 13 |
+ |
/* Preferred BSDF component: |
| 14 |
+ |
none, transmission, reflection front (normal side), reflection back */ |
| 15 |
+ |
typedef enum {RMPnone=-1, RMPtrans=0, RMPreflF, RMPreflB} RMPref; |
| 16 |
+ |
|
| 17 |
|
/* Unary matrix operation(s) */ |
| 18 |
|
typedef struct { |
| 19 |
|
double cmat[MAXCOMP*MAXCOMP]; /* component transformation */ |
| 39 |
|
int |
| 40 |
|
loadmatrix(ROPMAT *rop) |
| 41 |
|
{ |
| 42 |
< |
if (rop->mtx != NULL) /* already loaded? */ |
| 42 |
> |
if (rop->mtx) /* already loaded? */ |
| 43 |
|
return(0); |
| 44 |
+ |
/* check for BSDF input */ |
| 45 |
+ |
if ((rop->inspec[0] != '!') & (rop->rmp != RMPnone)) { |
| 46 |
+ |
const char *sp = strrchr(rop->inspec, '.'); |
| 47 |
+ |
if (sp > rop->inspec && !strcasecmp(sp+1, "XML")) { |
| 48 |
+ |
CMATRIX *cm = rop->rmp==RMPtrans ? cm_loadBTDF(rop->inspec) : |
| 49 |
+ |
cm_loadBRDF(rop->inspec, rop->rmp==RMPreflB) ; |
| 50 |
+ |
if (!cm) |
| 51 |
+ |
return(-1); |
| 52 |
+ |
rop->mtx = rmx_from_cmatrix(cm); |
| 53 |
+ |
cm_free(cm); |
| 54 |
+ |
if (!rop->mtx) |
| 55 |
+ |
return(-1); |
| 56 |
+ |
rop->mtx->dtype = DTascii; |
| 57 |
+ |
return(1); /* loaded BSDF XML file */ |
| 58 |
+ |
} |
| 59 |
+ |
} /* else load regular matrix */ |
| 60 |
+ |
rop->mtx = rmx_load(rop->inspec); |
| 61 |
|
|
| 62 |
< |
rop->mtx = rmx_load(rop->inspec, rop->rmp); |
| 42 |
< |
|
| 43 |
< |
return(!rop->mtx ? -1 : 1); |
| 62 |
> |
return(rop->mtx ? 1 : -1); |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
extern int checksymbolic(ROPMAT *rop); |
| 695 |
|
mres = loadop(mop+nmats); |
| 696 |
|
if (mres == NULL) |
| 697 |
|
return(1); |
| 698 |
< |
if (outfmt == DTfromHeader) /* check data type */ |
| 698 |
> |
if ((outfmt == DTfromHeader) & (mres->dtype < DTspec)) |
| 699 |
|
outfmt = mres->dtype; |
| 700 |
< |
if (outfmt == DTrgbe) { |
| 700 |
> |
if (outfmt == DTrgbe) { /* check data type */ |
| 701 |
|
if (mres->ncomp > 3) |
| 702 |
|
outfmt = DTspec; |
| 703 |
|
else if (mres->dtype == DTxyze) |