| 1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
| 18 |
|
|
| 19 |
|
#include "otypes.h" |
| 20 |
|
|
| 21 |
< |
#ifndef DEFPATH |
| 22 |
< |
#define DEFPATH ":/usr/local/lib/ray" |
| 23 |
< |
#endif |
| 21 |
> |
#include "paths.h" |
| 22 |
|
|
| 23 |
< |
#define OMARGIN (10*FTINY) /* margin around global cube */ |
| 23 |
> |
#define OMARGIN (10*FTINY) /* margin around global cube */ |
| 24 |
|
|
| 25 |
< |
#define MAXOBJFIL 63 /* maximum number of scene files */ |
| 25 |
> |
#define MAXOBJFIL 63 /* maximum number of scene files */ |
| 26 |
|
|
| 27 |
|
char *progname; /* argv[0] */ |
| 28 |
|
|
| 39 |
|
char *ofname[MAXOBJFIL+1]; /* object file names */ |
| 40 |
|
int nfiles = 0; /* number of object files */ |
| 41 |
|
|
| 42 |
< |
double mincusize; /* minimum cube size from resolu */ |
| 42 |
> |
double mincusize; /* minimum cube size from resolu */ |
| 43 |
|
|
| 44 |
|
int (*addobjnotify[])() = {NULL}; /* new object notifier functions */ |
| 45 |
|
|
| 52 |
|
FVECT bbmin, bbmax; |
| 53 |
|
char *infile = NULL; |
| 54 |
|
int outflags = IO_ALL; |
| 55 |
< |
OBJECT startobj; |
| 55 |
> |
OBJECT startobj; |
| 56 |
|
int i; |
| 57 |
|
|
| 58 |
< |
progname = argv[0]; |
| 58 |
> |
progname = argv[0] = fixargv0(argv[0]); |
| 59 |
|
|
| 60 |
< |
if ((libpath = getenv("RAYPATH")) == NULL) |
| 60 |
> |
if ((libpath = getenv(ULIBVAR)) == NULL) |
| 61 |
|
libpath = DEFPATH; |
| 62 |
|
|
| 63 |
|
initotypes(); |
| 93 |
|
break; |
| 94 |
|
} |
| 95 |
|
breakopt: |
| 96 |
+ |
#ifdef MSDOS |
| 97 |
+ |
setmode(fileno(stdout), O_BINARY); |
| 98 |
+ |
#endif |
| 99 |
|
if (infile != NULL) { /* get old octree & objects */ |
| 100 |
|
if (thescene.cusize > FTINY) |
| 101 |
|
error(USER, "only one of '-b' or '-i'"); |
| 111 |
|
printf("\n"); |
| 112 |
|
|
| 113 |
|
startobj = nobjects; /* previous objects already converted */ |
| 114 |
< |
|
| 114 |
> |
|
| 115 |
|
for ( ; i < argc; i++) /* read new scene descriptions */ |
| 116 |
|
if (!strcmp(argv[i], "-")) { /* from stdin */ |
| 117 |
|
readobj(NULL); |
| 150 |
|
} |
| 151 |
|
|
| 152 |
|
mincusize = thescene.cusize / resolu - FTINY; |
| 153 |
< |
|
| 153 |
> |
|
| 154 |
|
for (i = startobj; i < nobjects; i++) /* add new objects */ |
| 155 |
|
addobject(&thescene, i); |
| 156 |
< |
|
| 156 |
> |
|
| 157 |
|
thescene.cutree = combine(thescene.cutree); /* optimize */ |
| 158 |
|
|
| 159 |
|
writeoct(outflags, &thescene, ofname); /* write structures to stdout */ |
| 198 |
|
} |
| 199 |
|
|
| 200 |
|
|
| 201 |
< |
#define bitop(f,i,op) (f[((i)>>3)] op (1<<((i)&7))) |
| 202 |
< |
#define tstbit(f,i) bitop(f,i,&) |
| 203 |
< |
#define setbit(f,i) bitop(f,i,|=) |
| 204 |
< |
#define clrbit(f,i) bitop(f,i,&=~) |
| 205 |
< |
#define tglbit(f,i) bitop(f,i,^=) |
| 201 |
> |
#define bitop(f,i,op) (f[((i)>>3)] op (1<<((i)&7))) |
| 202 |
> |
#define tstbit(f,i) bitop(f,i,&) |
| 203 |
> |
#define setbit(f,i) bitop(f,i,|=) |
| 204 |
> |
#define clrbit(f,i) bitop(f,i,&=~) |
| 205 |
> |
#define tglbit(f,i) bitop(f,i,^=) |
| 206 |
|
|
| 207 |
|
|
| 208 |
|
addobject(cu, obj) /* add an object to a cube */ |
| 209 |
|
register CUBE *cu; |
| 210 |
< |
OBJECT obj; |
| 210 |
> |
OBJECT obj; |
| 211 |
|
{ |
| 212 |
|
CUBE cukid; |
| 213 |
< |
OCTREE ot; |
| 214 |
< |
OBJECT oset[MAXSET+1]; |
| 213 |
> |
OCTREE ot; |
| 214 |
> |
OBJECT oset[MAXSET+1]; |
| 215 |
|
unsigned char inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8]; |
| 216 |
|
int in; |
| 217 |
|
register int i, j; |
| 220 |
|
|
| 221 |
|
if (in == O_MISS) |
| 222 |
|
return; /* no intersection */ |
| 223 |
< |
|
| 223 |
> |
|
| 224 |
|
if (istree(cu->cutree)) { |
| 225 |
|
/* do children */ |
| 226 |
|
cukid.cusize = cu->cusize * 0.5; |
| 245 |
|
/* add to full node */ |
| 246 |
|
objset(oset, cu->cutree); |
| 247 |
|
cukid.cusize = cu->cusize * 0.5; |
| 248 |
< |
|
| 248 |
> |
|
| 249 |
|
if (in==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { |
| 250 |
|
/* add to set */ |
| 251 |
|
if (oset[0] >= MAXSET) { |