1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* oconv.c - main program for object to octree conversion. |
6 |
|
* |
8 |
|
*/ |
9 |
|
|
10 |
|
#include "standard.h" |
11 |
< |
|
11 |
> |
#include "platform.h" |
12 |
|
#include "octree.h" |
16 |
– |
|
13 |
|
#include "object.h" |
18 |
– |
|
14 |
|
#include "otypes.h" |
20 |
– |
|
15 |
|
#include "paths.h" |
16 |
|
|
17 |
|
#define OMARGIN (10*FTINY) /* margin around global cube */ |
18 |
|
|
19 |
< |
#define MAXOBJFIL 63 /* maximum number of scene files */ |
19 |
> |
#define MAXOBJFIL 127 /* maximum number of scene files */ |
20 |
|
|
21 |
|
char *progname; /* argv[0] */ |
22 |
|
|
23 |
|
int nowarn = 0; /* supress warnings? */ |
24 |
|
|
25 |
< |
int objlim = 5; /* # of objects before split */ |
25 |
> |
int objlim = 6; /* # of objects before split */ |
26 |
|
|
27 |
< |
int resolu = 1024; /* octree resolution limit */ |
27 |
> |
int resolu = 16384; /* octree resolution limit */ |
28 |
|
|
29 |
|
CUBE thescene = {EMPTY, {0.0, 0.0, 0.0}, 0.0}; /* our scene */ |
30 |
|
|
33 |
|
|
34 |
|
double mincusize; /* minimum cube size from resolu */ |
35 |
|
|
36 |
< |
int (*addobjnotify[])() = {NULL}; /* new object notifier functions */ |
36 |
> |
void (*addobjnotify[])() = {NULL}; /* new object notifier functions */ |
37 |
|
|
38 |
|
|
39 |
|
main(argc, argv) /* convert object files to an octree */ |
82 |
|
break; |
83 |
|
} |
84 |
|
breakopt: |
85 |
< |
#ifdef MSDOS |
92 |
< |
setmode(fileno(stdout), O_BINARY); |
93 |
< |
#endif |
85 |
> |
SET_FILE_BINARY(stdout); |
86 |
|
if (infile != NULL) { /* get old octree & objects */ |
87 |
|
if (thescene.cusize > FTINY) |
88 |
|
error(USER, "only one of '-b' or '-i'"); |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
+ |
void |
156 |
|
quit(code) /* exit program */ |
157 |
|
int code; |
158 |
|
{ |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
+ |
void |
164 |
|
cputs() /* interactive error */ |
165 |
|
{ |
166 |
|
/* referenced, but not used */ |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
+ |
void |
171 |
|
wputs(s) /* warning message */ |
172 |
|
char *s; |
173 |
|
{ |
176 |
|
} |
177 |
|
|
178 |
|
|
179 |
+ |
void |
180 |
|
eputs(s) /* put string to stderr */ |
181 |
|
register char *s; |
182 |
|
{ |
191 |
|
inln = 0; |
192 |
|
} |
193 |
|
|
194 |
+ |
/* conflicting def's in param.h */ |
195 |
+ |
#undef tstbit |
196 |
+ |
#undef setbit |
197 |
+ |
#undef clrbit |
198 |
+ |
#undef tglbit |
199 |
|
|
200 |
|
#define bitop(f,i,op) (f[((i)>>3)] op (1<<((i)&7))) |
201 |
|
#define tstbit(f,i) bitop(f,i,&) |
208 |
|
register CUBE *cu; |
209 |
|
OBJECT obj; |
210 |
|
{ |
211 |
< |
CUBE cukid; |
211 |
< |
OCTREE ot; |
212 |
< |
OBJECT oset[MAXSET+1]; |
213 |
< |
unsigned char inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8]; |
214 |
< |
int in; |
215 |
< |
register int i, j; |
211 |
> |
int inc; |
212 |
|
|
213 |
< |
in = (*ofun[objptr(obj)->otype].funp)(objptr(obj), cu); |
213 |
> |
inc = (*ofun[objptr(obj)->otype].funp)(objptr(obj), cu); |
214 |
|
|
215 |
< |
if (in == O_MISS) |
215 |
> |
if (inc == O_MISS) |
216 |
|
return; /* no intersection */ |
217 |
|
|
218 |
|
if (istree(cu->cutree)) { |
219 |
< |
/* do children */ |
219 |
> |
CUBE cukid; /* do children */ |
220 |
> |
int i, j; |
221 |
|
cukid.cusize = cu->cusize * 0.5; |
222 |
|
for (i = 0; i < 8; i++) { |
223 |
|
cukid.cutree = octkid(cu->cutree, i); |
232 |
|
return; |
233 |
|
} |
234 |
|
if (isempty(cu->cutree)) { |
235 |
< |
/* singular set */ |
235 |
> |
OBJECT oset[2]; /* singular set */ |
236 |
|
oset[0] = 1; oset[1] = obj; |
237 |
|
cu->cutree = fullnode(oset); |
238 |
|
return; |
239 |
|
} |
240 |
|
/* add to full node */ |
241 |
+ |
add2full(cu, obj, inc); |
242 |
+ |
} |
243 |
+ |
|
244 |
+ |
|
245 |
+ |
add2full(cu, obj, inc) /* add object to full node */ |
246 |
+ |
register CUBE *cu; |
247 |
+ |
OBJECT obj; |
248 |
+ |
int inc; |
249 |
+ |
{ |
250 |
+ |
OCTREE ot; |
251 |
+ |
OBJECT oset[MAXSET+1]; |
252 |
+ |
CUBE cukid; |
253 |
+ |
unsigned char inflg[(MAXSET+7)/8], volflg[(MAXSET+7)/8]; |
254 |
+ |
register int i, j; |
255 |
+ |
|
256 |
|
objset(oset, cu->cutree); |
257 |
|
cukid.cusize = cu->cusize * 0.5; |
258 |
|
|
259 |
< |
if (in==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { |
259 |
> |
if (inc==O_IN || oset[0] < objlim || cukid.cusize < mincusize) { |
260 |
|
/* add to set */ |
261 |
|
if (oset[0] >= MAXSET) { |
262 |
|
sprintf(errmsg, "set overflow in addobject (%s)", |