| 7 |
|
* 7/29/85 |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
– |
#include "standard.h" |
| 10 |
|
#include "platform.h" |
| 11 |
+ |
#include "standard.h" |
| 12 |
|
#include "octree.h" |
| 13 |
|
#include "object.h" |
| 14 |
|
#include "otypes.h" |
| 15 |
|
#include "paths.h" |
| 16 |
+ |
#include "resolu.h" |
| 17 |
+ |
#include "oconv.h" |
| 18 |
|
|
| 19 |
|
#define OMARGIN (10*FTINY) /* margin around global cube */ |
| 20 |
|
|
| 21 |
< |
#define MAXOBJFIL 127 /* maximum number of scene files */ |
| 21 |
> |
#define MAXOBJFIL 255 /* maximum number of scene files */ |
| 22 |
|
|
| 21 |
– |
char *progname; /* argv[0] */ |
| 22 |
– |
|
| 23 |
|
int nowarn = 0; /* supress warnings? */ |
| 24 |
|
|
| 25 |
|
int objlim = 6; /* # of objects before split */ |
| 26 |
|
|
| 27 |
|
int resolu = 16384; /* octree resolution limit */ |
| 28 |
|
|
| 29 |
< |
CUBE thescene = {EMPTY, {0.0, 0.0, 0.0}, 0.0}; /* our scene */ |
| 29 |
> |
CUBE thescene = {{0.0, 0.0, 0.0}, 0.0, EMPTY}; /* our scene */ |
| 30 |
|
|
| 31 |
|
char *ofname[MAXOBJFIL+1]; /* object file names */ |
| 32 |
|
int nfiles = 0; /* number of object files */ |
| 35 |
|
|
| 36 |
|
void (*addobjnotify[])() = {NULL}; /* new object notifier functions */ |
| 37 |
|
|
| 38 |
+ |
static void addobject(CUBE *cu, OBJECT obj); |
| 39 |
+ |
static void add2full(CUBE *cu, OBJECT obj, int inc); |
| 40 |
|
|
| 41 |
< |
main(argc, argv) /* convert object files to an octree */ |
| 42 |
< |
int argc; |
| 43 |
< |
char *argv[]; |
| 41 |
> |
|
| 42 |
> |
int |
| 43 |
> |
main( /* convert object files to an octree */ |
| 44 |
> |
int argc, |
| 45 |
> |
char *argv[] |
| 46 |
> |
) |
| 47 |
|
{ |
| 48 |
|
FVECT bbmin, bbmax; |
| 49 |
|
char *infile = NULL; |
| 52 |
|
OBJECT startobj; |
| 53 |
|
int i; |
| 54 |
|
|
| 55 |
< |
progname = argv[0] = fixargv0(argv[0]); |
| 55 |
> |
fixargv0(argv[0]); /* sets global progname */ |
| 56 |
|
|
| 57 |
< |
initotypes(); |
| 57 |
> |
ot_initotypes(); |
| 58 |
|
|
| 59 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
| 60 |
|
switch (argv[i][1]) { |
| 154 |
|
writeoct(outflags, &thescene, ofname); /* write structures to stdout */ |
| 155 |
|
|
| 156 |
|
quit(0); |
| 157 |
+ |
return 0; /* pro forma return */ |
| 158 |
|
} |
| 159 |
|
|
| 160 |
|
|
| 161 |
|
void |
| 162 |
< |
quit(code) /* exit program */ |
| 163 |
< |
int code; |
| 162 |
> |
quit( /* exit program */ |
| 163 |
> |
int code |
| 164 |
> |
) |
| 165 |
|
{ |
| 166 |
|
exit(code); |
| 167 |
|
} |
| 168 |
|
|
| 169 |
|
|
| 170 |
|
void |
| 171 |
< |
cputs() /* interactive error */ |
| 171 |
> |
cputs(void) /* interactive error */ |
| 172 |
|
{ |
| 173 |
|
/* referenced, but not used */ |
| 174 |
|
} |
| 175 |
|
|
| 176 |
|
|
| 177 |
|
void |
| 178 |
< |
wputs(s) /* warning message */ |
| 179 |
< |
char *s; |
| 178 |
> |
wputs( /* warning message */ |
| 179 |
> |
const char *s |
| 180 |
> |
) |
| 181 |
|
{ |
| 182 |
|
if (!nowarn) |
| 183 |
|
eputs(s); |
| 185 |
|
|
| 186 |
|
|
| 187 |
|
void |
| 188 |
< |
eputs(s) /* put string to stderr */ |
| 189 |
< |
register char *s; |
| 188 |
> |
eputs( /* put string to stderr */ |
| 189 |
> |
const char *s |
| 190 |
> |
) |
| 191 |
|
{ |
| 192 |
|
static int inln = 0; |
| 193 |
|
|
| 213 |
|
#define tglbit(f,i) bitop(f,i,^=) |
| 214 |
|
|
| 215 |
|
|
| 216 |
< |
addobject(cu, obj) /* add an object to a cube */ |
| 217 |
< |
register CUBE *cu; |
| 218 |
< |
OBJECT obj; |
| 216 |
> |
static void |
| 217 |
> |
addobject( /* add an object to a cube */ |
| 218 |
> |
CUBE *cu, |
| 219 |
> |
OBJECT obj |
| 220 |
> |
) |
| 221 |
|
{ |
| 222 |
|
int inc; |
| 223 |
|
|
| 253 |
|
} |
| 254 |
|
|
| 255 |
|
|
| 256 |
< |
add2full(cu, obj, inc) /* add object to full node */ |
| 257 |
< |
register CUBE *cu; |
| 258 |
< |
OBJECT obj; |
| 259 |
< |
int inc; |
| 256 |
> |
static void |
| 257 |
> |
add2full( /* add object to full node */ |
| 258 |
> |
CUBE *cu, |
| 259 |
> |
OBJECT obj, |
| 260 |
> |
int inc |
| 261 |
> |
) |
| 262 |
|
{ |
| 263 |
|
OCTREE ot; |
| 264 |
|
OBJECT oset[MAXSET+1]; |
| 265 |
|
CUBE cukid; |
| 266 |
|
unsigned char inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8]; |
| 267 |
< |
register int i, j; |
| 267 |
> |
int i, j; |
| 268 |
|
|
| 269 |
|
objset(oset, cu->cutree); |
| 270 |
|
cukid.cusize = cu->cusize * 0.5; |
| 271 |
|
|
| 272 |
< |
if (inc==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { |
| 272 |
> |
if (inc==O_IN || oset[0] < objlim || cukid.cusize < |
| 273 |
> |
(oset[0] < MAXSET ? mincusize : mincusize/256.0)) { |
| 274 |
|
/* add to set */ |
| 275 |
|
if (oset[0] >= MAXSET) { |
| 276 |
|
sprintf(errmsg, "set overflow in addobject (%s)", |