18 |
|
#include "random.h" |
19 |
|
#include "paths.h" |
20 |
|
#include "view.h" |
21 |
+ |
#include "pmapray.h" |
22 |
|
|
23 |
< |
char *progname; /* argv[0] */ |
23 |
> |
extern char *progname; /* global argv[0] */ |
24 |
|
|
25 |
< |
char *octname; /* octree name */ |
25 |
> |
VIEW ourview = STDVIEW; /* viewing parameters */ |
26 |
> |
int hresolu, vresolu; /* image resolution */ |
27 |
|
|
28 |
< |
char *sigerr[NSIG]; /* signal error messages */ |
28 |
> |
int psample = 8; /* pixel sample size */ |
29 |
> |
double maxdiff = .15; /* max. sample difference */ |
30 |
|
|
31 |
< |
char *shm_boundary = NULL; /* boundary of shared memory */ |
31 |
> |
int greyscale = 0; /* map colors to brightness? */ |
32 |
> |
char *dvcname = dev_default; /* output device name */ |
33 |
|
|
34 |
< |
char *errfile = NULL; /* error output file */ |
34 |
> |
double exposure = 1.0; /* exposure for scene */ |
35 |
|
|
36 |
< |
extern int greyscale; /* map colors to brightness? */ |
37 |
< |
extern char *dvcname; /* output device name */ |
38 |
< |
extern double exposure; /* exposure compensation */ |
36 |
> |
int newparam = 1; /* parameter setting changed */ |
37 |
> |
|
38 |
> |
struct driver *dev = NULL; /* driver functions */ |
39 |
|
|
40 |
< |
extern VIEW ourview; /* viewing parameters */ |
40 |
> |
char rifname[128]; /* rad input file name */ |
41 |
|
|
42 |
< |
extern char rifname[]; /* rad input file name */ |
42 |
> |
VIEW oldview; /* previous view parameters */ |
43 |
|
|
44 |
< |
extern int hresolu; /* horizontal resolution */ |
45 |
< |
extern int vresolu; /* vertical resolution */ |
44 |
> |
PNODE ptrunk; /* the base of our image */ |
45 |
> |
RECT pframe; /* current frame boundaries */ |
46 |
> |
int pdepth; /* image depth in current frame */ |
47 |
|
|
48 |
< |
extern int psample; /* pixel sample size */ |
44 |
< |
extern double maxdiff; /* max. sample difference */ |
48 |
> |
char *errfile = NULL; /* error output file */ |
49 |
|
|
50 |
+ |
int nproc = 1; /* number of processes */ |
51 |
+ |
|
52 |
+ |
char *sigerr[NSIG]; /* signal error messages */ |
53 |
+ |
|
54 |
|
static void onsig(int signo); |
55 |
|
static void sigdie(int signo, char *msg); |
56 |
|
static void printdefaults(void); |
57 |
|
|
58 |
|
|
59 |
|
int |
60 |
< |
main(int argc, char *argv[]) |
60 |
> |
main(int argc, char *argv[]) |
61 |
|
{ |
62 |
|
#define check(ol,al) if (argv[i][ol] || \ |
63 |
|
badarg(argc-i-1,argv+i+1,al)) \ |
69 |
|
case 'n': case 'N': case 'f': case 'F': \ |
70 |
|
case '-': case '0': var = 0; break; \ |
71 |
|
default: goto badopt; } |
72 |
+ |
char *octnm = NULL; |
73 |
|
char *err; |
74 |
|
int rval; |
75 |
|
int i; |
76 |
|
/* global program name */ |
77 |
|
progname = argv[0] = fixargv0(argv[0]); |
78 |
+ |
/* set our defaults */ |
79 |
+ |
shadthresh = .1; |
80 |
+ |
shadcert = .25; |
81 |
+ |
directrelay = 0; |
82 |
+ |
vspretest = 128; |
83 |
+ |
srcsizerat = 0.; |
84 |
+ |
specthresh = .3; |
85 |
+ |
specjitter = 1.; |
86 |
+ |
maxdepth = 6; |
87 |
+ |
minweight = 1e-2; |
88 |
+ |
ambacc = 0.3; |
89 |
+ |
ambres = 32; |
90 |
+ |
ambdiv = 256; |
91 |
+ |
ambssamp = 64; |
92 |
|
/* option city */ |
93 |
|
for (i = 1; i < argc; i++) { |
94 |
|
/* expand arguments */ |
124 |
|
continue; |
125 |
|
} |
126 |
|
switch (argv[i][1]) { |
127 |
+ |
case 'n': /* # processes */ |
128 |
+ |
check(2,"i"); |
129 |
+ |
nproc = atoi(argv[++i]); |
130 |
+ |
if (nproc <= 0) |
131 |
+ |
error(USER, "bad number of processes"); |
132 |
+ |
break; |
133 |
|
case 'v': /* view file */ |
134 |
|
if (argv[i][2] != 'f') |
135 |
|
goto badopt; |
195 |
|
err = setview(&ourview); /* set viewing parameters */ |
196 |
|
if (err != NULL) |
197 |
|
error(USER, err); |
198 |
< |
/* initialize object types */ |
170 |
< |
initotypes(); |
171 |
< |
/* initialize urand */ |
172 |
< |
srandom(rand_samp ? (long)time(0) : 0L); |
173 |
< |
initurand(2048); |
174 |
< |
/* set up signal handling */ |
198 |
> |
/* set up signal handling */ |
199 |
|
sigdie(SIGINT, "Interrupt"); |
176 |
– |
sigdie(SIGHUP, "Hangup"); |
200 |
|
sigdie(SIGTERM, "Terminate"); |
201 |
+ |
#ifndef _WIN32 |
202 |
+ |
sigdie(SIGHUP, "Hangup"); |
203 |
|
sigdie(SIGPIPE, "Broken pipe"); |
204 |
|
sigdie(SIGALRM, "Alarm clock"); |
180 |
– |
#ifdef SIGXCPU |
181 |
– |
sigdie(SIGXCPU, "CPU limit exceeded"); |
182 |
– |
sigdie(SIGXFSZ, "File size exceeded"); |
205 |
|
#endif |
206 |
|
/* open error file */ |
207 |
|
if (errfile != NULL) { |
218 |
|
#endif |
219 |
|
/* get octree */ |
220 |
|
if (i == argc) |
221 |
< |
octname = NULL; |
221 |
> |
octnm = NULL; |
222 |
|
else if (i == argc-1) |
223 |
< |
octname = argv[i]; |
223 |
> |
octnm = argv[i]; |
224 |
|
else |
225 |
|
goto badopt; |
226 |
< |
if (octname == NULL) |
226 |
> |
if (octnm == NULL) |
227 |
|
error(USER, "missing octree argument"); |
228 |
< |
/* set up output */ |
228 |
> |
/* set up output & start process(es) */ |
229 |
|
SET_FILE_BINARY(stdout); |
230 |
< |
readoct(octname, ~(IO_FILES|IO_INFO), &thescene, NULL); |
231 |
< |
nsceneobjs = nobjects; |
230 |
> |
|
231 |
> |
ray_init(octnm); |
232 |
> |
|
233 |
> |
/* PMAP: set up & load photon maps */ |
234 |
> |
ray_init_pmap(); |
235 |
|
|
211 |
– |
marksources(); /* find and mark sources */ |
212 |
– |
|
213 |
– |
setambient(); /* initialize ambient calculation */ |
214 |
– |
|
236 |
|
rview(); /* run interactive viewer */ |
237 |
|
|
238 |
< |
ambsync(); /* flush ambient file */ |
238 |
> |
devclose(); /* close output device */ |
239 |
|
|
240 |
+ |
/* PMAP: free photon maps */ |
241 |
+ |
ray_done_pmap(); |
242 |
+ |
|
243 |
|
quit(0); |
244 |
|
|
245 |
|
badopt: |
265 |
|
|
266 |
|
void |
267 |
|
eputs( /* put string to stderr */ |
268 |
< |
register char *s |
268 |
> |
char *s |
269 |
|
) |
270 |
|
{ |
271 |
|
static int midline = 0; |
294 |
|
if (gotsig++) /* two signals and we're gone! */ |
295 |
|
_exit(signo); |
296 |
|
|
297 |
+ |
#ifndef _WIN32 |
298 |
|
alarm(15); /* allow 15 seconds to clean up */ |
299 |
|
signal(SIGALRM, SIG_DFL); /* make certain we do die */ |
300 |
+ |
#endif |
301 |
|
eputs("signal - "); |
302 |
|
eputs(sigerr[signo]); |
303 |
|
eputs("\n"); |
304 |
+ |
devclose(); |
305 |
|
quit(3); |
306 |
|
} |
307 |
|
|
321 |
|
static void |
322 |
|
printdefaults(void) /* print default values to stdout */ |
323 |
|
{ |
324 |
+ |
printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc); |
325 |
|
printf(greyscale ? "-b+\t\t\t\t# greyscale on\n" : |
326 |
|
"-b-\t\t\t\t# greyscale off\n"); |
327 |
|
printf("-vt%c\t\t\t\t# view type %s\n", ourview.type, |
330 |
|
ourview.type==VT_HEM ? "hemispherical" : |
331 |
|
ourview.type==VT_ANG ? "angular" : |
332 |
|
ourview.type==VT_CYL ? "cylindrical" : |
333 |
+ |
ourview.type==VT_PLS ? "planisphere" : |
334 |
|
"unknown"); |
335 |
|
printf("-vp %f %f %f\t# view point\n", |
336 |
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |