7 |
|
|
8 |
|
#include "copyright.h" |
9 |
|
|
10 |
+ |
#include <stdio.h> |
11 |
+ |
#include <string.h> |
12 |
+ |
#include <time.h> |
13 |
+ |
|
14 |
+ |
#include "platform.h" |
15 |
+ |
#include "paths.h" |
16 |
+ |
#include "resolu.h" |
17 |
|
#include "radogl.h" |
18 |
|
#include "octree.h" |
19 |
|
|
26 |
|
char octfile[256]; /* octree file path */ |
27 |
|
} OCTINST; /* octree to instantiate */ |
28 |
|
|
29 |
< |
static double ogetflt(); |
30 |
< |
static long ogetint(); |
31 |
< |
static char *ogetstr(); |
32 |
< |
static int loadobj(); |
33 |
< |
static void skiptree(); |
34 |
< |
static void octerror(); |
35 |
< |
static OCTINST *getoct(); |
29 |
> |
static double ogetflt(void); |
30 |
> |
static long ogetint(int); |
31 |
> |
static char *ogetstr(char *); |
32 |
> |
static int loadobj(void); |
33 |
> |
static void skiptree(void); |
34 |
> |
static void octerror(int etyp, char *msg); |
35 |
> |
static OCTINST *getoct(char *); |
36 |
|
|
37 |
|
static char *infn; /* input file name */ |
38 |
|
static FILE *infp; /* input file stream */ |
61 |
|
o->oargs.nsargs-1) |
62 |
|
objerror(o, USER, "bad transform"); |
63 |
|
glPushAttrib(GL_TRANSFORM_BIT); |
64 |
< |
if (xfs.sca < 1.-FTINY | xfs.sca > 1.+FTINY) |
64 |
> |
if ((xfs.sca < 1.-FTINY) | (xfs.sca > 1.+FTINY)) |
65 |
|
glEnable(GL_NORMALIZE); |
66 |
|
glMatrixMode(GL_MODELVIEW); |
67 |
|
glPushMatrix(); |
117 |
|
while (ottab.tsiz) { |
118 |
|
if (!levelsleft--) |
119 |
|
error(USER, "too many octree levels -- instance loop?"); |
120 |
< |
copystruct(&looptab, &ottab); |
120 |
> |
looptab = ottab; |
121 |
|
ottab.tsiz = 0; |
122 |
|
nocts += lu_doall(&looptab, buildoctlist); |
123 |
|
lu_done(&looptab); |
130 |
|
getoct(name) /* get/assign octree list id */ |
131 |
|
char *name; |
132 |
|
{ |
126 |
– |
extern char *getpath(), *getlibpath(); |
133 |
|
char *path; |
134 |
|
register LUENT *lp; |
135 |
|
register OCTINST *op; |
143 |
|
strcpy(lp->key, name); |
144 |
|
} |
145 |
|
if ((op = (OCTINST *)lp->data) == NULL) { |
146 |
< |
path = getpath(name, getlibpath(), R_OK); |
146 |
> |
path = getpath(name, getrlibpath(), R_OK); |
147 |
|
if (path == NULL) { |
148 |
|
sprintf(errmsg, "cannot find octree \"%s\"", name); |
149 |
|
error(USER, errmsg); |
157 |
|
return(op); |
158 |
|
memerr: |
159 |
|
error(SYSTEM, "out of memory in getoct"); |
160 |
+ |
return NULL; /* pro forma return */ |
161 |
|
} |
162 |
|
|
163 |
|
|
176 |
|
sprintf(errmsg, "cannot open octree file \"%s\"", fname); |
177 |
|
error(SYSTEM, errmsg); |
178 |
|
} |
179 |
< |
#ifdef MSDOS |
173 |
< |
setmode(fileno(infp), O_BINARY); |
174 |
< |
#endif |
179 |
> |
SET_FILE_BINARY(infp); |
180 |
|
/* get header */ |
181 |
|
if (checkheader(infp, OCTFMT, NULL) < 0) |
182 |
|
octerror(USER, "not an octree"); |
183 |
|
/* check format */ |
184 |
|
if ((objsize = ogetint(2)-OCTMAGIC) <= 0 || |
185 |
|
objsize > MAXOBJSIZ || objsize > sizeof(long)) |
186 |
< |
octerror("incompatible octree format"); |
186 |
> |
octerror(USER, "incompatible octree format"); |
187 |
|
if (cent != NULL) { /* get boundaries (compute center) */ |
188 |
|
for (i = 0; i < 3; i++) |
189 |
|
cent[i] = atof(ogetstr(sbuf)); |
213 |
|
|
214 |
|
infn = fname; |
215 |
|
infp = fopen(fname, "r"); /* assume already checked */ |
216 |
< |
#ifdef MSDOS |
212 |
< |
setmode(fileno(infp), O_BINARY); |
213 |
< |
#endif |
216 |
> |
SET_FILE_BINARY(infp); |
217 |
|
/* skip header */ |
218 |
|
getheader(infp, NULL, NULL); |
219 |
|
/* get format */ |
340 |
|
/* get name id */ |
341 |
|
ob.oname = ogetstr(idbuf); |
342 |
|
/* get string arguments */ |
343 |
< |
if (ob.oargs.nsargs = ogetint(2)) { |
343 |
> |
if ((ob.oargs.nsargs = ogetint(2))) { |
344 |
|
ob.oargs.sarg = (char **)malloc |
345 |
|
(ob.oargs.nsargs*sizeof(char *)); |
346 |
|
if (ob.oargs.sarg == NULL) |
362 |
|
ob.oargs.iarg = NULL; |
363 |
|
#endif |
364 |
|
/* get real arguments */ |
365 |
< |
if (ob.oargs.nfargs = ogetint(2)) { |
366 |
< |
ob.oargs.farg = (FLOAT *)malloc |
367 |
< |
(ob.oargs.nfargs*sizeof(FLOAT)); |
365 |
> |
if ((ob.oargs.nfargs = ogetint(2))) { |
366 |
> |
ob.oargs.farg = (RREAL *)malloc |
367 |
> |
(ob.oargs.nfargs*sizeof(RREAL)); |
368 |
|
if (ob.oargs.farg == NULL) |
369 |
|
goto memerr; |
370 |
|
for (i = 0; i < ob.oargs.nfargs; i++) |
384 |
|
return(nobjects++); /* return object id */ |
385 |
|
memerr: |
386 |
|
error(SYSTEM, "out of memory in loadobj"); |
387 |
+ |
return OVOID; /* pro forma return */ |
388 |
|
} |
389 |
|
|
390 |
|
|