ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/renderopts.c
Revision: 2.1
Committed: Sat Feb 22 02:07:29 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id$";
3 #endif
4 /*
5 * renderopts.c - process common rendering options
6 *
7 * External symbols declared in ray.h
8 */
9
10 /* ====================================================================
11 * The Radiance Software License, Version 1.0
12 *
13 * Copyright (c) 1990 - 2002 The Regents of the University of California,
14 * through Lawrence Berkeley National Laboratory. All rights reserved.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 *
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 *
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in
25 * the documentation and/or other materials provided with the
26 * distribution.
27 *
28 * 3. The end-user documentation included with the redistribution,
29 * if any, must include the following acknowledgment:
30 * "This product includes Radiance software
31 * (http://radsite.lbl.gov/)
32 * developed by the Lawrence Berkeley National Laboratory
33 * (http://www.lbl.gov/)."
34 * Alternately, this acknowledgment may appear in the software itself,
35 * if and wherever such third-party acknowledgments normally appear.
36 *
37 * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
38 * and "The Regents of the University of California" must
39 * not be used to endorse or promote products derived from this
40 * software without prior written permission. For written
41 * permission, please contact [email protected].
42 *
43 * 5. Products derived from this software may not be called "Radiance",
44 * nor may "Radiance" appear in their name, without prior written
45 * permission of Lawrence Berkeley National Laboratory.
46 *
47 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
48 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 * DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
51 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
54 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
55 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
56 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
57 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 * ====================================================================
60 *
61 * This software consists of voluntary contributions made by many
62 * individuals on behalf of Lawrence Berkeley National Laboratory. For more
63 * information on Lawrence Berkeley National Laboratory, please see
64 * <http://www.lbl.gov/>.
65 */
66
67 #include "ray.h"
68
69
70 int
71 getrenderopt(ac, av) /* get next render option */
72 int ac;
73 char *av[];
74 {
75 #define check(ol,al) if (av[0][ol] || \
76 badarg(ac-1,av+1,al)) \
77 return(-1)
78 #define bool(olen,var) switch (av[0][olen]) { \
79 case '\0': var = !var; break; \
80 case 'y': case 'Y': case 't': case 'T': \
81 case '+': case '1': var = 1; break; \
82 case 'n': case 'N': case 'f': case 'F': \
83 case '-': case '0': var = 0; break; \
84 default: return(-1); }
85 static char **amblp; /* pointer to build ambient list */
86 int rval;
87 /* is it even an option? */
88 if (ac < 1 || av[0] == NULL || av[0][0] != '-')
89 return(-1);
90 /* check if it's one we know */
91 switch (av[0][1]) {
92 case 'b': /* back face vis. */
93 if (av[0][2] == 'v') {
94 bool(3,backvis);
95 return(0);
96 }
97 break;
98 case 'd': /* direct */
99 switch (av[0][2]) {
100 case 't': /* threshold */
101 check(3,"f");
102 shadthresh = atof(av[1]);
103 return(1);
104 case 'c': /* certainty */
105 check(3,"f");
106 shadcert = atof(av[1]);
107 return(1);
108 case 'j': /* jitter */
109 check(3,"f");
110 dstrsrc = atof(av[1]);
111 return(1);
112 case 'r': /* relays */
113 check(3,"i");
114 directrelay = atoi(av[1]);
115 return(1);
116 case 'p': /* pretest */
117 check(3,"i");
118 vspretest = atoi(av[1]);
119 return(1);
120 case 'v': /* visibility */
121 bool(3,directvis);
122 return(0);
123 case 's': /* size */
124 check(3,"f");
125 srcsizerat = atof(av[1]);
126 return(1);
127 }
128 break;
129 case 's': /* specular */
130 switch (av[0][2]) {
131 case 't': /* threshold */
132 check(3,"f");
133 specthresh = atof(av[1]);
134 return(1);
135 case 'j': /* jitter */
136 check(3,"f");
137 specjitter = atof(av[1]);
138 return(1);
139 }
140 break;
141 case 'l': /* limit */
142 switch (av[0][2]) {
143 case 'r': /* recursion */
144 check(3,"i");
145 maxdepth = atoi(av[1]);
146 return(1);
147 case 'w': /* weight */
148 check(3,"f");
149 minweight = atof(av[1]);
150 return(1);
151 }
152 break;
153 case 'i': /* irradiance */
154 bool(2,do_irrad);
155 return(0);
156 case 'a': /* ambient */
157 switch (av[0][2]) {
158 case 'v': /* value */
159 check(3,"fff");
160 setcolor(ambval, atof(av[1]),
161 atof(av[2]),
162 atof(av[3]));
163 return(3);
164 case 'w': /* weight */
165 check(3,"i");
166 ambvwt = atoi(av[1]);
167 return(1);
168 case 'a': /* accuracy */
169 check(3,"f");
170 ambacc = atof(av[1]);
171 return(1);
172 case 'r': /* resolution */
173 check(3,"i");
174 ambres = atoi(av[1]);
175 return(1);
176 case 'd': /* divisions */
177 check(3,"i");
178 ambdiv = atoi(av[1]);
179 return(1);
180 case 's': /* super-samp */
181 check(3,"i");
182 ambssamp = atoi(av[1]);
183 return(1);
184 case 'b': /* bounces */
185 check(3,"i");
186 ambounce = atoi(av[1]);
187 return(1);
188 case 'i': /* include */
189 case 'I':
190 check(3,"s");
191 if (ambincl != 1) {
192 ambincl = 1;
193 amblp = amblist;
194 }
195 if (av[0][2] == 'I') { /* file */
196 rval = wordfile(amblp,
197 getpath(av[1],getlibpath(),R_OK));
198 if (rval < 0) {
199 sprintf(errmsg,
200 "cannot open ambient include file \"%s\"", av[0]);
201 error(SYSTEM, errmsg);
202 }
203 amblp += rval;
204 } else {
205 *amblp++ = av[1];
206 *amblp = NULL;
207 }
208 return(1);
209 case 'e': /* exclude */
210 case 'E':
211 check(3,"s");
212 if (ambincl != 0) {
213 ambincl = 0;
214 amblp = amblist;
215 }
216 if (av[0][2] == 'E') { /* file */
217 rval = wordfile(amblp,
218 getpath(av[1],getlibpath(),R_OK));
219 if (rval < 0) {
220 sprintf(errmsg,
221 "cannot open ambient exclude file \"%s\"", av[0]);
222 error(SYSTEM, errmsg);
223 }
224 amblp += rval;
225 } else {
226 *amblp++ = av[1];
227 *amblp = NULL;
228 }
229 return(1);
230 case 'f': /* file */
231 check(3,"s");
232 ambfile= av[1];
233 return(1);
234 }
235 break;
236 case 'm': /* medium */
237 switch (av[0][2]) {
238 case 'e': /* extinction */
239 check(3,"fff");
240 setcolor(cextinction, atof(av[1]),
241 atof(av[2]),
242 atof(av[3]));
243 return(3);
244 case 'a': /* albedo */
245 check(3,"fff");
246 setcolor(salbedo, atof(av[1]),
247 atof(av[2]),
248 atof(av[3]));
249 return(3);
250 case 'g': /* eccentr. */
251 check(3,"f");
252 seccg = atof(av[1]);
253 return(1);
254 case 's': /* sampling */
255 check(3,"f");
256 ssampdist = atof(av[1]);
257 return(1);
258 }
259 break;
260 }
261 return(-1); /* unknown option */
262
263 #undef check
264 #undef bool
265 }
266
267
268 void
269 print_rdefaults() /* print default render values to stdout */
270 {
271 register char *cp;
272
273 printf(do_irrad ? "-i+\t\t\t\t# irradiance calculation on\n" :
274 "-i-\t\t\t\t# irradiance calculation off\n");
275 printf(backvis ? "-bv+\t\t\t\t# back face visibility on\n" :
276 "-bv-\t\t\t\t# back face visibility off\n");
277 printf("-dt %f\t\t\t# direct threshold\n", shadthresh);
278 printf("-dc %f\t\t\t# direct certainty\n", shadcert);
279 printf("-dj %f\t\t\t# direct jitter\n", dstrsrc);
280 printf("-ds %f\t\t\t# direct sampling\n", srcsizerat);
281 printf("-dr %-9d\t\t\t# direct relays\n", directrelay);
282 printf("-dp %-9d\t\t\t# direct pretest density\n", vspretest);
283 printf(directvis ? "-dv+\t\t\t\t# direct visibility on\n" :
284 "-dv-\t\t\t\t# direct visibility off\n");
285 printf("-sj %f\t\t\t# specular jitter\n", specjitter);
286 printf("-st %f\t\t\t# specular threshold\n", specthresh);
287 printf("-av %f %f %f\t# ambient value\n", colval(ambval,RED),
288 colval(ambval,GRN), colval(ambval, BLU));
289 printf("-aw %-9d\t\t\t# ambient value weight\n", ambvwt);
290 printf("-ab %-9d\t\t\t# ambient bounces\n", ambounce);
291 printf("-aa %f\t\t\t# ambient accuracy\n", ambacc);
292 printf("-ar %-9d\t\t\t# ambient resolution\n", ambres);
293 printf("-ad %-9d\t\t\t# ambient divisions\n", ambdiv);
294 printf("-as %-9d\t\t\t# ambient super-samples\n", ambssamp);
295 printf("-me %.2e %.2e %.2e\t# mist extinction coefficient\n",
296 colval(cextinction,RED),
297 colval(cextinction,GRN),
298 colval(cextinction,BLU));
299 printf("-ma %f %f %f\t# mist scattering albedo\n", colval(salbedo,RED),
300 colval(salbedo,GRN), colval(salbedo,BLU));
301 printf("-mg %f\t\t\t# mist scattering eccentricity\n", seccg);
302 printf("-ms %f\t\t\t# mist sampling distance\n", ssampdist);
303 printf("-lr %-9d\t\t\t# limit reflection\n", maxdepth);
304 printf("-lw %f\t\t\t# limit weight\n", minweight);
305 }