13 |
|
#include "paths.h" |
14 |
|
#include "pmapopt.h" |
15 |
|
|
16 |
+ |
extern char *progname; /* global argv[0] */ |
17 |
|
|
18 |
+ |
char RFeatureList[2048] = /* newline-separated feature list */ |
19 |
+ |
"VirtualSources\nSecondarySources\nSourceSubsampling\n" |
20 |
+ |
"SourceVisibility\nAmbientModifierSelection\n" |
21 |
+ |
"PathTracing\nRussianRoulette\nLowDiscrepancySeq\n" |
22 |
+ |
"SpecularSampling\nMaterialMixtures\nAntimatter\nBackFaceVisibility\n" |
23 |
+ |
"ScatteringModels=WGMD,Ashikhmin-Shirley\n" |
24 |
+ |
"TabulatedBSDFs=DataFile,KlemsXML,TensorTreeXML,+ViewPeakExtraction\n" |
25 |
+ |
"Instancing=Octree,TriangleMesh\nAliases\n" |
26 |
+ |
#if MAXCSAMP>3 |
27 |
+ |
"Hyperspectral\n" |
28 |
+ |
#endif |
29 |
+ |
#if !defined(SHADCACHE) || SHADCACHE > 0 |
30 |
+ |
"ShadowCache\n" |
31 |
+ |
#endif |
32 |
+ |
#ifdef DISPERSE |
33 |
+ |
"DielectricDispersion\n" |
34 |
+ |
#endif |
35 |
+ |
/* PMAP_FEATURES XXX @Roland: need to define this in pmapopt.h */ |
36 |
+ |
; |
37 |
+ |
|
38 |
+ |
|
39 |
+ |
static char * |
40 |
+ |
get_feature( /* find a specific feature (with optional sublist) */ |
41 |
+ |
const char *feat |
42 |
+ |
) |
43 |
+ |
{ |
44 |
+ |
char *cp = RFeatureList; |
45 |
+ |
int n = 0; |
46 |
+ |
|
47 |
+ |
while ((feat[n] != '\0') & (feat[n] != '=')) |
48 |
+ |
n++; |
49 |
+ |
if (!n) |
50 |
+ |
return(NULL); |
51 |
+ |
while (*cp) { |
52 |
+ |
if (!strncmp(cp, feat, n) && (cp[n] == '\n') | !feat[n] | (cp[n] == feat[n])) |
53 |
+ |
return(cp); |
54 |
+ |
while (*cp++ != '\n') |
55 |
+ |
; |
56 |
+ |
} |
57 |
+ |
return(NULL); |
58 |
+ |
} |
59 |
+ |
|
60 |
+ |
|
61 |
+ |
static int |
62 |
+ |
match_subfeatures( /* check if subfeatures are supported */ |
63 |
+ |
char *mysublist, |
64 |
+ |
char *reqs |
65 |
+ |
) |
66 |
+ |
{ |
67 |
+ |
if (mysublist) |
68 |
+ |
mysublist = strchr(mysublist, '='); |
69 |
+ |
if (!mysublist++ | !reqs) |
70 |
+ |
return(0); /* not a feature list */ |
71 |
+ |
while (*reqs) { /* check each of their subfeature requests */ |
72 |
+ |
char subfeat[64]; |
73 |
+ |
char *cp = subfeat; |
74 |
+ |
int n; |
75 |
+ |
while (*reqs && (*cp = *reqs++) != ',') |
76 |
+ |
cp++; |
77 |
+ |
*cp = '\0'; |
78 |
+ |
n = cp - subfeat; |
79 |
+ |
if (!(cp = strstr(mysublist, subfeat)) || |
80 |
+ |
(cp[-1] != ',') & (cp[-1] != '=') || |
81 |
+ |
(cp[n] != ',') & (cp[n] != '\n')) |
82 |
+ |
return(0); /* missing this one! */ |
83 |
+ |
} |
84 |
+ |
return(1); /* matched them all */ |
85 |
+ |
} |
86 |
+ |
|
87 |
+ |
|
88 |
|
int |
89 |
+ |
feature_status( /* report active feature list / check specifics */ |
90 |
+ |
int ac, |
91 |
+ |
char *av[] |
92 |
+ |
) |
93 |
+ |
{ |
94 |
+ |
if (ac <= 0) /* report entire list? */ |
95 |
+ |
fputs(RFeatureList, stdout); |
96 |
+ |
|
97 |
+ |
for ( ; ac-- > 0; av++) { /* check each argument */ |
98 |
+ |
char *cp; |
99 |
+ |
if (!*av[0]) continue; |
100 |
+ |
if ((cp = strchr(av[0], '=')) != NULL) { |
101 |
+ |
if (!match_subfeatures(get_feature(av[0]), cp+1)) |
102 |
+ |
goto missing_feature; |
103 |
+ |
} else if ((cp = get_feature(av[0])) != NULL) { |
104 |
+ |
char *tp = strchr(cp, '='); |
105 |
+ |
if (tp && tp < strchr(cp, '\n')) |
106 |
+ |
do |
107 |
+ |
fputc(*cp, stdout); |
108 |
+ |
while (*cp++ != '\n'); |
109 |
+ |
} else |
110 |
+ |
goto missing_feature; |
111 |
+ |
} |
112 |
+ |
return(0); /* return satisfactory status */ |
113 |
+ |
missing_feature: /* or report error */ |
114 |
+ |
fprintf(stderr, "%s: missing feature - %s\n", progname, av[0]); |
115 |
+ |
return(1); |
116 |
+ |
} |
117 |
+ |
|
118 |
+ |
|
119 |
+ |
int |
120 |
|
getrenderopt( /* get next render option */ |
121 |
|
int ac, |
122 |
|
char *av[] |
246 |
|
amblp = amblist; |
247 |
|
} |
248 |
|
if (av[0][2] == 'I') { /* file */ |
249 |
< |
rval = wordfile(amblp, |
249 |
> |
rval = wordfile(amblp, AMBLLEN-(amblp-amblist), |
250 |
|
getpath(av[1],getrlibpath(),R_OK)); |
251 |
|
if (rval < 0) { |
252 |
|
sprintf(errmsg, |
267 |
|
amblp = amblist; |
268 |
|
} |
269 |
|
if (av[0][2] == 'E') { /* file */ |
270 |
< |
rval = wordfile(amblp, |
270 |
> |
rval = wordfile(amblp, AMBLLEN-(amblp-amblist), |
271 |
|
getpath(av[1],getrlibpath(),R_OK)); |
272 |
|
if (rval < 0) { |
273 |
|
sprintf(errmsg, |
310 |
|
return(1); |
311 |
|
} |
312 |
|
break; |
313 |
+ |
#if MAXCSAMP>3 |
314 |
+ |
case 'c': /* spectral sampling */ |
315 |
+ |
switch (av[0][2]) { |
316 |
+ |
case 's': /* spectral bin count */ |
317 |
+ |
check(3,"i"); |
318 |
+ |
NCSAMP = atoi(av[1]); |
319 |
+ |
return(1); |
320 |
+ |
case 'w': /* wavelength extrema */ |
321 |
+ |
check(3,"ff"); |
322 |
+ |
WLPART[0] = atof(av[1]); |
323 |
+ |
WLPART[3] = atof(av[2]); |
324 |
+ |
return(1); |
325 |
+ |
} |
326 |
+ |
break; |
327 |
+ |
#endif |
328 |
|
} |
329 |
|
|
330 |
|
/* PMAP: Parse photon mapping options */ |
372 |
|
colval(salbedo,GRN), colval(salbedo,BLU)); |
373 |
|
printf("-mg %f\t\t\t# mist scattering eccentricity\n", seccg); |
374 |
|
printf("-ms %f\t\t\t# mist sampling distance\n", ssampdist); |
375 |
+ |
if (NCSAMP > 3) { |
376 |
+ |
printf("-cs %-2d\t\t\t\t# number of spectral bins\n", NCSAMP); |
377 |
+ |
printf("-cw %3.0f %3.0f\t\t\t# wavelength limits (nm)\n", |
378 |
+ |
WLPART[3], WLPART[0]); |
379 |
+ |
} |
380 |
|
printf("-lr %-9d\t\t\t# limit reflection%s\n", maxdepth, |
381 |
|
maxdepth<=0 ? " (Russian roulette)" : ""); |
382 |
|
printf("-lw %.2e\t\t\t# limit weight\n", minweight); |