ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/renderopts.c
Revision: 2.7
Committed: Fri Aug 20 20:03:00 2004 UTC (19 years, 8 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R6, rad3R6P1
Changes since 2.6: +3 -3 lines
Log Message:
Fixed error message for missing -aE and -aI files

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: renderopts.c,v 2.6 2004/08/13 22:57:56 greg Exp $";
3 #endif
4 /*
5 * renderopts.c - process common rendering options
6 *
7 * External symbols declared in ray.h
8 */
9
10 #include "copyright.h"
11
12 #include "ray.h"
13 #include "paths.h"
14
15
16 extern int
17 getrenderopt( /* get next render option */
18 int ac,
19 char *av[]
20 )
21 {
22 #define check(ol,al) if (av[0][ol] || \
23 badarg(ac-1,av+1,al)) \
24 return(-1)
25 #define bool(olen,var) switch (av[0][olen]) { \
26 case '\0': var = !var; break; \
27 case 'y': case 'Y': case 't': case 'T': \
28 case '+': case '1': var = 1; break; \
29 case 'n': case 'N': case 'f': case 'F': \
30 case '-': case '0': var = 0; break; \
31 default: return(-1); }
32 static char **amblp; /* pointer to build ambient list */
33 int rval;
34 /* is it even an option? */
35 if (ac < 1 || av[0] == NULL || av[0][0] != '-')
36 return(-1);
37 /* check if it's one we know */
38 switch (av[0][1]) {
39 case 'b': /* back face vis. */
40 if (av[0][2] == 'v') {
41 bool(3,backvis);
42 return(0);
43 }
44 break;
45 case 'd': /* direct */
46 switch (av[0][2]) {
47 case 't': /* threshold */
48 check(3,"f");
49 shadthresh = atof(av[1]);
50 return(1);
51 case 'c': /* certainty */
52 check(3,"f");
53 shadcert = atof(av[1]);
54 return(1);
55 case 'j': /* jitter */
56 check(3,"f");
57 dstrsrc = atof(av[1]);
58 return(1);
59 case 'r': /* relays */
60 check(3,"i");
61 directrelay = atoi(av[1]);
62 return(1);
63 case 'p': /* pretest */
64 check(3,"i");
65 vspretest = atoi(av[1]);
66 return(1);
67 case 'v': /* visibility */
68 bool(3,directvis);
69 return(0);
70 case 's': /* size */
71 check(3,"f");
72 srcsizerat = atof(av[1]);
73 return(1);
74 }
75 break;
76 case 's': /* specular */
77 switch (av[0][2]) {
78 case 't': /* threshold */
79 check(3,"f");
80 specthresh = atof(av[1]);
81 return(1);
82 case 'j': /* jitter */
83 check(3,"f");
84 specjitter = atof(av[1]);
85 return(1);
86 }
87 break;
88 case 'l': /* limit */
89 switch (av[0][2]) {
90 case 'r': /* recursion */
91 check(3,"i");
92 maxdepth = atoi(av[1]);
93 return(1);
94 case 'w': /* weight */
95 check(3,"f");
96 minweight = atof(av[1]);
97 return(1);
98 }
99 break;
100 case 'i': /* irradiance */
101 bool(2,do_irrad);
102 return(0);
103 case 'a': /* ambient */
104 switch (av[0][2]) {
105 case 'v': /* value */
106 check(3,"fff");
107 setcolor(ambval, atof(av[1]),
108 atof(av[2]),
109 atof(av[3]));
110 return(3);
111 case 'w': /* weight */
112 check(3,"i");
113 ambvwt = atoi(av[1]);
114 return(1);
115 case 'a': /* accuracy */
116 check(3,"f");
117 ambacc = atof(av[1]);
118 return(1);
119 case 'r': /* resolution */
120 check(3,"i");
121 ambres = atoi(av[1]);
122 return(1);
123 case 'd': /* divisions */
124 check(3,"i");
125 ambdiv = atoi(av[1]);
126 return(1);
127 case 's': /* super-samp */
128 check(3,"i");
129 ambssamp = atoi(av[1]);
130 return(1);
131 case 'b': /* bounces */
132 check(3,"i");
133 ambounce = atoi(av[1]);
134 return(1);
135 case 'i': /* include */
136 case 'I':
137 check(3,"s");
138 if (ambincl != 1) {
139 ambincl = 1;
140 amblp = amblist;
141 }
142 if (av[0][2] == 'I') { /* file */
143 rval = wordfile(amblp,
144 getpath(av[1],getrlibpath(),R_OK));
145 if (rval < 0) {
146 sprintf(errmsg,
147 "cannot open ambient include file \"%s\"", av[1]);
148 error(SYSTEM, errmsg);
149 }
150 amblp += rval;
151 } else {
152 *amblp++ = savqstr(av[1]);
153 *amblp = NULL;
154 }
155 return(1);
156 case 'e': /* exclude */
157 case 'E':
158 check(3,"s");
159 if (ambincl != 0) {
160 ambincl = 0;
161 amblp = amblist;
162 }
163 if (av[0][2] == 'E') { /* file */
164 rval = wordfile(amblp,
165 getpath(av[1],getrlibpath(),R_OK));
166 if (rval < 0) {
167 sprintf(errmsg,
168 "cannot open ambient exclude file \"%s\"", av[1]);
169 error(SYSTEM, errmsg);
170 }
171 amblp += rval;
172 } else {
173 *amblp++ = savqstr(av[1]);
174 *amblp = NULL;
175 }
176 return(1);
177 case 'f': /* file */
178 check(3,"s");
179 ambfile = savqstr(av[1]);
180 return(1);
181 }
182 break;
183 case 'm': /* medium */
184 switch (av[0][2]) {
185 case 'e': /* extinction */
186 check(3,"fff");
187 setcolor(cextinction, atof(av[1]),
188 atof(av[2]),
189 atof(av[3]));
190 return(3);
191 case 'a': /* albedo */
192 check(3,"fff");
193 setcolor(salbedo, atof(av[1]),
194 atof(av[2]),
195 atof(av[3]));
196 return(3);
197 case 'g': /* eccentr. */
198 check(3,"f");
199 seccg = atof(av[1]);
200 return(1);
201 case 's': /* sampling */
202 check(3,"f");
203 ssampdist = atof(av[1]);
204 return(1);
205 }
206 break;
207 }
208 return(-1); /* unknown option */
209
210 #undef check
211 #undef bool
212 }
213
214
215 extern void
216 print_rdefaults(void) /* print default render values to stdout */
217 {
218 printf(do_irrad ? "-i+\t\t\t\t# irradiance calculation on\n" :
219 "-i-\t\t\t\t# irradiance calculation off\n");
220 printf(backvis ? "-bv+\t\t\t\t# back face visibility on\n" :
221 "-bv-\t\t\t\t# back face visibility off\n");
222 printf("-dt %f\t\t\t# direct threshold\n", shadthresh);
223 printf("-dc %f\t\t\t# direct certainty\n", shadcert);
224 printf("-dj %f\t\t\t# direct jitter\n", dstrsrc);
225 printf("-ds %f\t\t\t# direct sampling\n", srcsizerat);
226 printf("-dr %-9d\t\t\t# direct relays\n", directrelay);
227 printf("-dp %-9d\t\t\t# direct pretest density\n", vspretest);
228 printf(directvis ? "-dv+\t\t\t\t# direct visibility on\n" :
229 "-dv-\t\t\t\t# direct visibility off\n");
230 printf("-sj %f\t\t\t# specular jitter\n", specjitter);
231 printf("-st %f\t\t\t# specular threshold\n", specthresh);
232 printf("-av %f %f %f\t# ambient value\n", colval(ambval,RED),
233 colval(ambval,GRN), colval(ambval, BLU));
234 printf("-aw %-9d\t\t\t# ambient value weight\n", ambvwt);
235 printf("-ab %-9d\t\t\t# ambient bounces\n", ambounce);
236 printf("-aa %f\t\t\t# ambient accuracy\n", ambacc);
237 printf("-ar %-9d\t\t\t# ambient resolution\n", ambres);
238 printf("-ad %-9d\t\t\t# ambient divisions\n", ambdiv);
239 printf("-as %-9d\t\t\t# ambient super-samples\n", ambssamp);
240 printf("-me %.2e %.2e %.2e\t# mist extinction coefficient\n",
241 colval(cextinction,RED),
242 colval(cextinction,GRN),
243 colval(cextinction,BLU));
244 printf("-ma %f %f %f\t# mist scattering albedo\n", colval(salbedo,RED),
245 colval(salbedo,GRN), colval(salbedo,BLU));
246 printf("-mg %f\t\t\t# mist scattering eccentricity\n", seccg);
247 printf("-ms %f\t\t\t# mist sampling distance\n", ssampdist);
248 printf("-lr %-9d\t\t\t# limit reflection\n", maxdepth);
249 printf("-lw %f\t\t\t# limit weight\n", minweight);
250 }