--- ray/src/util/rsensor.c 2008/02/21 20:18:25 2.2 +++ ray/src/util/rsensor.c 2008/04/11 22:06:04 2.5 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rsensor.c,v 2.2 2008/02/21 20:18:25 greg Exp $"; +static const char RCSid[] = "$Id: rsensor.c,v 2.5 2008/04/11 22:06:04 greg Exp $"; #endif /* @@ -22,7 +22,9 @@ extern char *progname; /* global argv[0] */ extern int nowarn; /* don't report warnings? */ /* current sensor's perspective */ -VIEW ourview = STDVIEW; +VIEW ourview = {VT_ANG,{0.,0.,0.},{0.,0.,1.},{1.,0.,0.}, + 1.,180.,180.,0.,0.,0.,0., + {0.,0.,0.},{0.,0.,0.},0.,0.}; unsigned long nsamps = 10000; /* desired number of initial samples */ unsigned long nssamps = 9000; /* number of super-samples */ @@ -45,8 +47,16 @@ double gscale = 1.; /* global scaling value */ static void comp_sensor(char *sfile); static void -print_defaults() +over_options() /* overriding options */ { + directvis = (ndsamps <= 0); + do_irrad = 0; +} + +static void +print_defaults() /* print out default parameters */ +{ + over_options(); printf("-n %-9d\t\t\t# number of processes\n", nprocs); printf("-rd %-9ld\t\t\t# ray directions\n", nsamps); /* printf("-rs %-9ld\t\t\t# ray super-samples\n", nssamps); */ @@ -68,6 +78,7 @@ main( ) { int doheader = 1; + int optwarn = 0; int i, rval; progname = argv[0]; @@ -78,27 +89,19 @@ main( directrelay = 3; ambounce = 1; maxdepth = -10; - /* just asking defaults? */ - if (argc == 2 && !strcmp(argv[1], "-defaults")) { - print_defaults(); - return(0); - } - /* check octree */ - if (argc < 2 || argv[argc-1][0] == '-') - error(USER, "missing octree argument"); /* get options from command line */ - for (i = 1; i < argc-1; i++) { + for (i = 1; i < argc; i++) { while ((rval = expandarg(&argc, &argv, i)) > 0) ; if (rval < 0) { sprintf(errmsg, "cannot expand '%s'", argv[i]); error(SYSTEM, errmsg); } - if (argv[i][0] != '-') { /* process a sensor file */ + if (argv[i][0] != '-') { + if (i >= argc-1) + break; /* final octree argument */ if (!ray_pnprocs) { - /* overriding options */ - directvis = (ndsamps <= 0); - do_irrad = 0; + over_options(); if (doheader) { /* print header */ printargs(argc, argv, stdout); fputformat("ascii", stdout); @@ -107,7 +110,7 @@ main( /* start process(es) */ ray_pinit(argv[argc-1], nprocs); } - comp_sensor(argv[i]); + comp_sensor(argv[i]); /* process a sensor file */ continue; } if (argv[i][1] == 'r') { /* sampling options */ @@ -150,12 +153,13 @@ main( sprintf(errmsg, "bad view option at '%s'", argv[i]); error(USER, errmsg); } - if (!strcmp(argv[i], "-w")) { /* turn off warnings */ - nowarn = 1; + if (!strcmp(argv[i], "-w")) { /* toggle warnings */ + nowarn = !nowarn; continue; } if (ray_pnprocs) { - error(WARNING, + if (!optwarn++) + error(WARNING, "rendering options should appear before first sensor"); } else if (!strcmp(argv[i], "-defaults")) { print_defaults(); @@ -178,6 +182,8 @@ main( } i += rval; } + if (!ray_pnprocs) + error(USER, i 0.5) - frac1 -= 0.5; - else if (p >= sntp[1]-1 || frac1 < 0.5) { - frac1 += 0.5; - --p; - } pvals[i*(nphi+1) + j] = (1.-frac1)*phdiv[p] + frac1*phdiv[p+1]; } @@ -475,11 +475,13 @@ comp_sensor( setcolor(vsum, .0f, .0f, .0f); nt = (int)(sqrt((double)nsamps*ntheta/nphi) + .5); np = nsamps/nt; - VCOPY(rr.rorg, ourview.vp); - rr.rmax = .0; for (i = 0; i < nt; i++) for (j = 0; j < np; j++) { + VCOPY(rr.rorg, ourview.vp); get_direc(rr.rdir, (i+frandom())/nt, (j+frandom())/np); + if (ourview.vfore > FTINY) + VSUM(rr.rorg, rr.rorg, rr.rdir, ourview.vfore); + rr.rmax = .0; rayorigin(&rr, PRIMARY, NULL, NULL); if (ray_pqueue(&rr) == 1) addcolor(vsum, rr.rcol);