| 18 |
|
#endif |
| 19 |
|
|
| 20 |
|
#include <signal.h> |
| 21 |
– |
#include <fcntl.h> |
| 21 |
|
|
| 22 |
|
#include "view.h" |
| 23 |
|
|
| 34 |
|
VIEW ourview = STDVIEW; /* view parameters */ |
| 35 |
|
int hresolu = 512; /* horizontal resolution */ |
| 36 |
|
int vresolu = 512; /* vertical resolution */ |
| 37 |
< |
double pixaspect = 1.0; /* pixel aspect ratio */ |
| 37 |
> |
double pixaspect = 1.0; /* pixel aspect ratio */ |
| 38 |
|
|
| 39 |
|
int psample = 4; /* pixel sample size */ |
| 40 |
< |
double maxdiff = .05; /* max. difference for interpolation */ |
| 41 |
< |
double dstrpix = 0.67; /* square pixel distribution */ |
| 40 |
> |
double maxdiff = .05; /* max. difference for interpolation */ |
| 41 |
> |
double dstrpix = 0.67; /* square pixel distribution */ |
| 42 |
|
|
| 43 |
< |
double dstrsrc = 0.0; /* square source distribution */ |
| 44 |
< |
double shadthresh = .05; /* shadow threshold */ |
| 45 |
< |
double shadcert = .5; /* shadow certainty */ |
| 43 |
> |
double dstrsrc = 0.0; /* square source distribution */ |
| 44 |
> |
double shadthresh = .05; /* shadow threshold */ |
| 45 |
> |
double shadcert = .5; /* shadow certainty */ |
| 46 |
|
int directrelay = 1; /* number of source relays */ |
| 47 |
|
int vspretest = 512; /* virtual source pretest density */ |
| 48 |
|
int directinvis = 0; /* sources invisible? */ |
| 49 |
< |
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
| 49 |
> |
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
| 50 |
|
|
| 51 |
< |
double specthresh = .15; /* specular sampling threshold */ |
| 52 |
< |
double specjitter = 1.; /* specular sampling jitter */ |
| 51 |
> |
double specthresh = .15; /* specular sampling threshold */ |
| 52 |
> |
double specjitter = 1.; /* specular sampling jitter */ |
| 53 |
|
|
| 54 |
|
int maxdepth = 6; /* maximum recursion depth */ |
| 55 |
< |
double minweight = 5e-3; /* minimum ray weight */ |
| 55 |
> |
double minweight = 5e-3; /* minimum ray weight */ |
| 56 |
|
|
| 57 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
| 58 |
< |
double ambacc = 0.2; /* ambient accuracy */ |
| 58 |
> |
double ambacc = 0.2; /* ambient accuracy */ |
| 59 |
|
int ambres = 32; /* ambient resolution */ |
| 60 |
|
int ambdiv = 128; /* ambient divisions */ |
| 61 |
|
int ambssamp = 0; /* ambient super-samples */ |
| 65 |
|
|
| 66 |
|
int ralrm = 0; /* seconds between reports */ |
| 67 |
|
|
| 68 |
< |
double pctdone = 0.0; /* percentage done */ |
| 68 |
> |
double pctdone = 0.0; /* percentage done */ |
| 69 |
|
|
| 70 |
|
long tlastrept = 0L; /* time at last report */ |
| 71 |
|
|
| 74 |
|
|
| 75 |
|
extern long nrays; /* number of rays traced */ |
| 76 |
|
|
| 77 |
< |
#define MAXDIV 16 /* maximum sample size */ |
| 77 |
> |
#define MAXDIV 16 /* maximum sample size */ |
| 78 |
|
|
| 79 |
< |
#define pixjitter() (.5+dstrpix*(.5-frandom())) |
| 79 |
> |
#define pixjitter() (.5+dstrpix*(.5-frandom())) |
| 80 |
|
|
| 81 |
< |
#define RFTEMPLATE "rfXXXXXX" |
| 82 |
< |
#define HFTEMPLATE TEMPLATE |
| 81 |
> |
#define RFTEMPLATE "rfXXXXXX" |
| 82 |
> |
#define HFTEMPLATE TEMPLATE |
| 83 |
|
|
| 84 |
|
static char *hfname = NULL; /* header file name */ |
| 85 |
|
static FILE *hfp = NULL; /* header file pointer */ |
| 88 |
|
|
| 89 |
|
extern char *mktemp(); |
| 90 |
|
|
| 91 |
< |
double pixvalue(); |
| 91 |
> |
double pixvalue(); |
| 92 |
|
|
| 93 |
|
|
| 94 |
|
quit(code) /* quit program */ |
| 109 |
|
report() /* report progress */ |
| 110 |
|
{ |
| 111 |
|
struct rusage rubuf; |
| 112 |
< |
double t; |
| 112 |
> |
double t; |
| 113 |
|
|
| 114 |
|
getrusage(RUSAGE_SELF, &rubuf); |
| 115 |
|
t = (rubuf.ru_utime.tv_usec + rubuf.ru_stime.tv_usec) / 1e6; |
| 183 |
|
extern char *rindex(), *strncpy(), *strcat(); |
| 184 |
|
char fbuf[128], fbuf2[128]; |
| 185 |
|
register char *cp; |
| 186 |
< |
RESOLU rs; |
| 187 |
< |
double pa; |
| 186 |
> |
RESOLU rs; |
| 187 |
> |
double pa; |
| 188 |
|
/* finished writing header */ |
| 189 |
|
closeheader(); |
| 190 |
|
/* check sampling */ |
| 348 |
|
pctdone = 100.0*i/vres; |
| 349 |
|
if (ralrm > 0) /* report init stats */ |
| 350 |
|
report(); |
| 351 |
< |
#ifndef BSD |
| 351 |
> |
#ifndef BSD |
| 352 |
|
else |
| 353 |
|
#endif |
| 354 |
|
signal(SIGALRM, report); |
| 373 |
|
/* fill bar */ |
| 374 |
|
fillscanbar(scanbar, zbar, hres, ypos, ystep); |
| 375 |
|
/* write it out */ |
| 376 |
< |
#ifndef BSD |
| 376 |
> |
#ifndef BSD |
| 377 |
|
signal(SIGALRM, SIG_IGN); /* don't interrupt writes */ |
| 378 |
|
#endif |
| 379 |
|
for (i = ystep; i > 0; i--) { |
| 390 |
|
pctdone = 100.0*(vres-1-ypos)/vres; |
| 391 |
|
if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm) |
| 392 |
|
report(); |
| 393 |
< |
#ifndef BSD |
| 393 |
> |
#ifndef BSD |
| 394 |
|
else |
| 395 |
|
signal(SIGALRM, report); |
| 396 |
|
#endif |
| 425 |
|
|
| 426 |
|
|
| 427 |
|
fillscanline(scanline, zline, sd, xres, y, xstep) /* fill scan at y */ |
| 428 |
< |
register COLOR *scanline; |
| 429 |
< |
register float *zline; |
| 428 |
> |
register COLOR *scanline; |
| 429 |
> |
register float *zline; |
| 430 |
|
register char *sd; |
| 431 |
|
int xres, y, xstep; |
| 432 |
|
{ |
| 433 |
|
static int nc = 0; /* number of calls */ |
| 434 |
|
int bl = xstep, b = xstep; |
| 435 |
< |
double z; |
| 435 |
> |
double z; |
| 436 |
|
register int i; |
| 437 |
|
|
| 438 |
|
z = pixvalue(scanline[0], 0, y); |
| 460 |
|
|
| 461 |
|
|
| 462 |
|
fillscanbar(scanbar, zbar, xres, y, ysize) /* fill interior */ |
| 463 |
< |
register COLOR *scanbar[]; |
| 464 |
< |
register float *zbar[]; |
| 463 |
> |
register COLOR *scanbar[]; |
| 464 |
> |
register float *zbar[]; |
| 465 |
|
int xres, y, ysize; |
| 466 |
|
{ |
| 467 |
|
COLOR vline[MAXDIV+1]; |
| 491 |
|
|
| 492 |
|
|
| 493 |
|
int |
| 494 |
< |
fillsample(colline, zline, x, y, xlen, ylen, b) /* fill interior points */ |
| 495 |
< |
register COLOR *colline; |
| 496 |
< |
register float *zline; |
| 494 |
> |
fillsample(colline, zline, x, y, xlen, ylen, b) /* fill interior points */ |
| 495 |
> |
register COLOR *colline; |
| 496 |
> |
register float *zline; |
| 497 |
|
int x, y; |
| 498 |
|
int xlen, ylen; |
| 499 |
|
int b; |
| 500 |
|
{ |
| 501 |
|
extern double fabs(); |
| 502 |
< |
double ratio; |
| 503 |
< |
double z; |
| 502 |
> |
double ratio; |
| 503 |
> |
double z; |
| 504 |
|
COLOR ctmp; |
| 505 |
|
int ncut; |
| 506 |
|
register int len; |