19 |
|
static long ogetint(); |
20 |
|
static char *ogetstr(); |
21 |
|
static int nonsurfinset(); |
22 |
< |
static int getobj(), octerror(), skiptree(); |
22 |
> |
static int octerror(), skiptree(); |
23 |
|
static OCTREE getfullnode(), gettree(); |
24 |
|
|
25 |
|
static char *infn; /* input file specification */ |
27 |
|
static int objsize; /* size of stored OBJECT's */ |
28 |
|
static OBJECT objorig; /* zeroeth object */ |
29 |
|
static OBJECT fnobjects; /* number of objects in this file */ |
30 |
– |
static short otypmap[NUMOTYPE+8]; /* object type map */ |
30 |
|
|
31 |
|
|
32 |
|
int |
38 |
|
{ |
39 |
|
char sbuf[512]; |
40 |
|
int nf; |
41 |
< |
register int i; |
41 |
> |
int i; |
42 |
|
long m; |
43 |
|
|
44 |
|
if (inpspec == NULL) { |
100 |
|
|
101 |
|
if (load & IO_SCENE) /* get the scene */ |
102 |
|
if (nf == 0) { |
103 |
< |
for (i = 0; *ogetstr(sbuf); i++) |
104 |
< |
if ((otypmap[i] = otype(sbuf)) < 0) { |
105 |
< |
sprintf(errmsg, "unknown type \"%s\"", sbuf); |
107 |
< |
octerror(WARNING, errmsg); |
108 |
< |
} |
109 |
< |
while (getobj() != OVOID) |
110 |
< |
; |
103 |
> |
/* load binary scene data */ |
104 |
> |
readscene(infp, objsize); |
105 |
> |
|
106 |
|
} else { /* consistency checks */ |
107 |
|
/* check object count */ |
108 |
|
if (nobjects != objorig+fnobjects) |
239 |
|
default: |
240 |
|
octerror(USER, "damaged octree"); |
241 |
|
} |
247 |
– |
} |
248 |
– |
|
249 |
– |
|
250 |
– |
static |
251 |
– |
getobj() /* get next object */ |
252 |
– |
{ |
253 |
– |
char sbuf[MAXSTR]; |
254 |
– |
int obj; |
255 |
– |
register int i; |
256 |
– |
register long m; |
257 |
– |
register OBJREC *objp; |
258 |
– |
|
259 |
– |
i = ogetint(1); |
260 |
– |
if (i == -1) |
261 |
– |
return(OVOID); /* terminator */ |
262 |
– |
if ((obj = newobject()) == OVOID) |
263 |
– |
error(SYSTEM, "out of object space"); |
264 |
– |
objp = objptr(obj); |
265 |
– |
if ((objp->otype = otypmap[i]) < 0) |
266 |
– |
octerror(USER, "reference to unknown type"); |
267 |
– |
if ((m = ogetint(objsize)) != OVOID) { |
268 |
– |
m += objorig; |
269 |
– |
if ((OBJECT)m != m) |
270 |
– |
octerror(USER, "too many objects"); |
271 |
– |
} |
272 |
– |
objp->omod = m; |
273 |
– |
objp->oname = savqstr(ogetstr(sbuf)); |
274 |
– |
if (objp->oargs.nsargs = ogetint(2)) { |
275 |
– |
objp->oargs.sarg = (char **)malloc |
276 |
– |
(objp->oargs.nsargs*sizeof(char *)); |
277 |
– |
if (objp->oargs.sarg == NULL) |
278 |
– |
goto memerr; |
279 |
– |
for (i = 0; i < objp->oargs.nsargs; i++) |
280 |
– |
objp->oargs.sarg[i] = savestr(ogetstr(sbuf)); |
281 |
– |
} else |
282 |
– |
objp->oargs.sarg = NULL; |
283 |
– |
#ifdef IARGS |
284 |
– |
if (objp->oargs.niargs = ogetint(2)) { |
285 |
– |
objp->oargs.iarg = (long *)malloc |
286 |
– |
(objp->oargs.niargs*sizeof(long)); |
287 |
– |
if (objp->oargs.iarg == NULL) |
288 |
– |
goto memerr; |
289 |
– |
for (i = 0; i < objp->oargs.niargs; i++) |
290 |
– |
objp->oargs.iarg[i] = ogetint(4); |
291 |
– |
} else |
292 |
– |
objp->oargs.iarg = NULL; |
293 |
– |
#endif |
294 |
– |
if (objp->oargs.nfargs = ogetint(2)) { |
295 |
– |
objp->oargs.farg = (FLOAT *)malloc |
296 |
– |
(objp->oargs.nfargs*sizeof(FLOAT)); |
297 |
– |
if (objp->oargs.farg == NULL) |
298 |
– |
goto memerr; |
299 |
– |
for (i = 0; i < objp->oargs.nfargs; i++) |
300 |
– |
objp->oargs.farg[i] = ogetflt(); |
301 |
– |
} else |
302 |
– |
objp->oargs.farg = NULL; |
303 |
– |
/* initialize */ |
304 |
– |
objp->os = NULL; |
305 |
– |
/* insert */ |
306 |
– |
insertobject(obj); |
307 |
– |
return(obj); |
308 |
– |
memerr: |
309 |
– |
error(SYSTEM, "out of memory in getobj"); |
242 |
|
} |
243 |
|
|
244 |
|
|