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 |
+ |
rop->mtx->dtype = DTascii; |
55 |
+ |
return(1); /* loaded BSDF XML file */ |
56 |
+ |
} |
57 |
+ |
} /* else load regular matrix */ |
58 |
+ |
rop->mtx = rmx_load(rop->inspec); |
59 |
|
|
60 |
< |
rop->mtx = rmx_load(rop->inspec, rop->rmp); |
42 |
< |
|
43 |
< |
return(!rop->mtx ? -1 : 1); |
60 |
> |
return(rop->mtx ? 1 : -1); |
61 |
|
} |
62 |
|
|
63 |
|
extern int checksymbolic(ROPMAT *rop); |