| 1 |
greg |
2.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 |
greg |
2.2 |
#include "copyright.h"
|
| 11 |
greg |
2.1 |
|
| 12 |
|
|
#include "ray.h"
|
| 13 |
|
|
|
| 14 |
|
|
|
| 15 |
|
|
int
|
| 16 |
|
|
getrenderopt(ac, av) /* get next render option */
|
| 17 |
|
|
int ac;
|
| 18 |
|
|
char *av[];
|
| 19 |
|
|
{
|
| 20 |
|
|
#define check(ol,al) if (av[0][ol] || \
|
| 21 |
|
|
badarg(ac-1,av+1,al)) \
|
| 22 |
|
|
return(-1)
|
| 23 |
|
|
#define bool(olen,var) switch (av[0][olen]) { \
|
| 24 |
|
|
case '\0': var = !var; break; \
|
| 25 |
|
|
case 'y': case 'Y': case 't': case 'T': \
|
| 26 |
|
|
case '+': case '1': var = 1; break; \
|
| 27 |
|
|
case 'n': case 'N': case 'f': case 'F': \
|
| 28 |
|
|
case '-': case '0': var = 0; break; \
|
| 29 |
|
|
default: return(-1); }
|
| 30 |
|
|
static char **amblp; /* pointer to build ambient list */
|
| 31 |
|
|
int rval;
|
| 32 |
|
|
/* is it even an option? */
|
| 33 |
|
|
if (ac < 1 || av[0] == NULL || av[0][0] != '-')
|
| 34 |
|
|
return(-1);
|
| 35 |
|
|
/* check if it's one we know */
|
| 36 |
|
|
switch (av[0][1]) {
|
| 37 |
|
|
case 'b': /* back face vis. */
|
| 38 |
|
|
if (av[0][2] == 'v') {
|
| 39 |
|
|
bool(3,backvis);
|
| 40 |
|
|
return(0);
|
| 41 |
|
|
}
|
| 42 |
|
|
break;
|
| 43 |
|
|
case 'd': /* direct */
|
| 44 |
|
|
switch (av[0][2]) {
|
| 45 |
|
|
case 't': /* threshold */
|
| 46 |
|
|
check(3,"f");
|
| 47 |
|
|
shadthresh = atof(av[1]);
|
| 48 |
|
|
return(1);
|
| 49 |
|
|
case 'c': /* certainty */
|
| 50 |
|
|
check(3,"f");
|
| 51 |
|
|
shadcert = atof(av[1]);
|
| 52 |
|
|
return(1);
|
| 53 |
|
|
case 'j': /* jitter */
|
| 54 |
|
|
check(3,"f");
|
| 55 |
|
|
dstrsrc = atof(av[1]);
|
| 56 |
|
|
return(1);
|
| 57 |
|
|
case 'r': /* relays */
|
| 58 |
|
|
check(3,"i");
|
| 59 |
|
|
directrelay = atoi(av[1]);
|
| 60 |
|
|
return(1);
|
| 61 |
|
|
case 'p': /* pretest */
|
| 62 |
|
|
check(3,"i");
|
| 63 |
|
|
vspretest = atoi(av[1]);
|
| 64 |
|
|
return(1);
|
| 65 |
|
|
case 'v': /* visibility */
|
| 66 |
|
|
bool(3,directvis);
|
| 67 |
|
|
return(0);
|
| 68 |
|
|
case 's': /* size */
|
| 69 |
|
|
check(3,"f");
|
| 70 |
|
|
srcsizerat = atof(av[1]);
|
| 71 |
|
|
return(1);
|
| 72 |
|
|
}
|
| 73 |
|
|
break;
|
| 74 |
|
|
case 's': /* specular */
|
| 75 |
|
|
switch (av[0][2]) {
|
| 76 |
|
|
case 't': /* threshold */
|
| 77 |
|
|
check(3,"f");
|
| 78 |
|
|
specthresh = atof(av[1]);
|
| 79 |
|
|
return(1);
|
| 80 |
|
|
case 'j': /* jitter */
|
| 81 |
|
|
check(3,"f");
|
| 82 |
|
|
specjitter = atof(av[1]);
|
| 83 |
|
|
return(1);
|
| 84 |
|
|
}
|
| 85 |
|
|
break;
|
| 86 |
|
|
case 'l': /* limit */
|
| 87 |
|
|
switch (av[0][2]) {
|
| 88 |
|
|
case 'r': /* recursion */
|
| 89 |
|
|
check(3,"i");
|
| 90 |
|
|
maxdepth = atoi(av[1]);
|
| 91 |
|
|
return(1);
|
| 92 |
|
|
case 'w': /* weight */
|
| 93 |
|
|
check(3,"f");
|
| 94 |
|
|
minweight = atof(av[1]);
|
| 95 |
|
|
return(1);
|
| 96 |
|
|
}
|
| 97 |
|
|
break;
|
| 98 |
|
|
case 'i': /* irradiance */
|
| 99 |
|
|
bool(2,do_irrad);
|
| 100 |
|
|
return(0);
|
| 101 |
|
|
case 'a': /* ambient */
|
| 102 |
|
|
switch (av[0][2]) {
|
| 103 |
|
|
case 'v': /* value */
|
| 104 |
|
|
check(3,"fff");
|
| 105 |
|
|
setcolor(ambval, atof(av[1]),
|
| 106 |
|
|
atof(av[2]),
|
| 107 |
|
|
atof(av[3]));
|
| 108 |
|
|
return(3);
|
| 109 |
|
|
case 'w': /* weight */
|
| 110 |
|
|
check(3,"i");
|
| 111 |
|
|
ambvwt = atoi(av[1]);
|
| 112 |
|
|
return(1);
|
| 113 |
|
|
case 'a': /* accuracy */
|
| 114 |
|
|
check(3,"f");
|
| 115 |
|
|
ambacc = atof(av[1]);
|
| 116 |
|
|
return(1);
|
| 117 |
|
|
case 'r': /* resolution */
|
| 118 |
|
|
check(3,"i");
|
| 119 |
|
|
ambres = atoi(av[1]);
|
| 120 |
|
|
return(1);
|
| 121 |
|
|
case 'd': /* divisions */
|
| 122 |
|
|
check(3,"i");
|
| 123 |
|
|
ambdiv = atoi(av[1]);
|
| 124 |
|
|
return(1);
|
| 125 |
|
|
case 's': /* super-samp */
|
| 126 |
|
|
check(3,"i");
|
| 127 |
|
|
ambssamp = atoi(av[1]);
|
| 128 |
|
|
return(1);
|
| 129 |
|
|
case 'b': /* bounces */
|
| 130 |
|
|
check(3,"i");
|
| 131 |
|
|
ambounce = atoi(av[1]);
|
| 132 |
|
|
return(1);
|
| 133 |
|
|
case 'i': /* include */
|
| 134 |
|
|
case 'I':
|
| 135 |
|
|
check(3,"s");
|
| 136 |
|
|
if (ambincl != 1) {
|
| 137 |
|
|
ambincl = 1;
|
| 138 |
|
|
amblp = amblist;
|
| 139 |
|
|
}
|
| 140 |
|
|
if (av[0][2] == 'I') { /* file */
|
| 141 |
|
|
rval = wordfile(amblp,
|
| 142 |
|
|
getpath(av[1],getlibpath(),R_OK));
|
| 143 |
|
|
if (rval < 0) {
|
| 144 |
|
|
sprintf(errmsg,
|
| 145 |
|
|
"cannot open ambient include file \"%s\"", av[0]);
|
| 146 |
|
|
error(SYSTEM, errmsg);
|
| 147 |
|
|
}
|
| 148 |
|
|
amblp += rval;
|
| 149 |
|
|
} else {
|
| 150 |
|
|
*amblp++ = av[1];
|
| 151 |
|
|
*amblp = NULL;
|
| 152 |
|
|
}
|
| 153 |
|
|
return(1);
|
| 154 |
|
|
case 'e': /* exclude */
|
| 155 |
|
|
case 'E':
|
| 156 |
|
|
check(3,"s");
|
| 157 |
|
|
if (ambincl != 0) {
|
| 158 |
|
|
ambincl = 0;
|
| 159 |
|
|
amblp = amblist;
|
| 160 |
|
|
}
|
| 161 |
|
|
if (av[0][2] == 'E') { /* file */
|
| 162 |
|
|
rval = wordfile(amblp,
|
| 163 |
|
|
getpath(av[1],getlibpath(),R_OK));
|
| 164 |
|
|
if (rval < 0) {
|
| 165 |
|
|
sprintf(errmsg,
|
| 166 |
|
|
"cannot open ambient exclude file \"%s\"", av[0]);
|
| 167 |
|
|
error(SYSTEM, errmsg);
|
| 168 |
|
|
}
|
| 169 |
|
|
amblp += rval;
|
| 170 |
|
|
} else {
|
| 171 |
|
|
*amblp++ = av[1];
|
| 172 |
|
|
*amblp = NULL;
|
| 173 |
|
|
}
|
| 174 |
|
|
return(1);
|
| 175 |
|
|
case 'f': /* file */
|
| 176 |
|
|
check(3,"s");
|
| 177 |
|
|
ambfile= av[1];
|
| 178 |
|
|
return(1);
|
| 179 |
|
|
}
|
| 180 |
|
|
break;
|
| 181 |
|
|
case 'm': /* medium */
|
| 182 |
|
|
switch (av[0][2]) {
|
| 183 |
|
|
case 'e': /* extinction */
|
| 184 |
|
|
check(3,"fff");
|
| 185 |
|
|
setcolor(cextinction, atof(av[1]),
|
| 186 |
|
|
atof(av[2]),
|
| 187 |
|
|
atof(av[3]));
|
| 188 |
|
|
return(3);
|
| 189 |
|
|
case 'a': /* albedo */
|
| 190 |
|
|
check(3,"fff");
|
| 191 |
|
|
setcolor(salbedo, atof(av[1]),
|
| 192 |
|
|
atof(av[2]),
|
| 193 |
|
|
atof(av[3]));
|
| 194 |
|
|
return(3);
|
| 195 |
|
|
case 'g': /* eccentr. */
|
| 196 |
|
|
check(3,"f");
|
| 197 |
|
|
seccg = atof(av[1]);
|
| 198 |
|
|
return(1);
|
| 199 |
|
|
case 's': /* sampling */
|
| 200 |
|
|
check(3,"f");
|
| 201 |
|
|
ssampdist = atof(av[1]);
|
| 202 |
|
|
return(1);
|
| 203 |
|
|
}
|
| 204 |
|
|
break;
|
| 205 |
|
|
}
|
| 206 |
|
|
return(-1); /* unknown option */
|
| 207 |
|
|
|
| 208 |
|
|
#undef check
|
| 209 |
|
|
#undef bool
|
| 210 |
|
|
}
|
| 211 |
|
|
|
| 212 |
|
|
|
| 213 |
|
|
void
|
| 214 |
|
|
print_rdefaults() /* print default render values to stdout */
|
| 215 |
|
|
{
|
| 216 |
|
|
register char *cp;
|
| 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 |
|
|
}
|