1 |
– |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Routines for reading instances and converting to OpenGL. |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include "copyright.h" |
9 |
+ |
|
10 |
|
#include "radogl.h" |
11 |
|
#include "octree.h" |
12 |
+ |
#include "platform.h" |
13 |
|
|
14 |
|
#define MAXLEVEL 16 /* maximum instance hierarchy level */ |
15 |
|
|
20 |
|
char octfile[256]; /* octree file path */ |
21 |
|
} OCTINST; /* octree to instantiate */ |
22 |
|
|
23 |
– |
OBJECT nobjects; /* number of objects loaded so far */ |
24 |
– |
|
25 |
– |
extern int free(); |
26 |
– |
|
23 |
|
static double ogetflt(); |
24 |
|
static long ogetint(); |
25 |
|
static char *ogetstr(); |
26 |
< |
static int loadobj(), octerror(), skiptree(); |
26 |
> |
static int loadobj(); |
27 |
> |
static void skiptree(); |
28 |
> |
static void octerror(); |
29 |
|
static OCTINST *getoct(); |
30 |
|
|
31 |
|
static char *infn; /* input file name */ |
39 |
|
static LUTAB ottab = LU_SINIT(free,free); |
40 |
|
|
41 |
|
|
42 |
+ |
int |
43 |
|
o_instance(o) /* convert instance to list call */ |
44 |
|
register OBJREC *o; |
45 |
|
{ |
68 |
|
} |
69 |
|
ot = getoct(o->oargs.sarg[0]); /* get octree reference */ |
70 |
|
if (ot->localmatl &= o->os != NULL) /* set material */ |
71 |
< |
setmaterial(o->os, ot->cent, 0); |
71 |
> |
setmaterial((MATREC *)o->os, ot->cent, 0); |
72 |
|
/* call the assigned list */ |
73 |
|
glCallList(ot->listid); |
74 |
|
|
78 |
|
glPopAttrib(); |
79 |
|
} |
80 |
|
rgl_checkerr("creating instance"); |
81 |
+ |
return(0); |
82 |
|
} |
83 |
|
|
84 |
|
|
124 |
|
getoct(name) /* get/assign octree list id */ |
125 |
|
char *name; |
126 |
|
{ |
127 |
– |
extern char *getpath(), *getlibpath(); |
127 |
|
char *path; |
128 |
|
register LUENT *lp; |
129 |
|
register OCTINST *op; |
137 |
|
strcpy(lp->key, name); |
138 |
|
} |
139 |
|
if ((op = (OCTINST *)lp->data) == NULL) { |
140 |
< |
path = getpath(name, getlibpath(), R_OK); |
140 |
> |
path = getpath(name, getrlibpath(), R_OK); |
141 |
|
if (path == NULL) { |
142 |
|
sprintf(errmsg, "cannot find octree \"%s\"", name); |
143 |
|
error(USER, errmsg); |
169 |
|
sprintf(errmsg, "cannot open octree file \"%s\"", fname); |
170 |
|
error(SYSTEM, errmsg); |
171 |
|
} |
172 |
< |
#ifdef MSDOS |
174 |
< |
setmode(fileno(infp), O_BINARY); |
175 |
< |
#endif |
172 |
> |
SET_FILE_BINARY(infp); |
173 |
|
/* get header */ |
174 |
|
if (checkheader(infp, OCTFMT, NULL) < 0) |
175 |
|
octerror(USER, "not an octree"); |
194 |
|
} |
195 |
|
|
196 |
|
|
197 |
+ |
int |
198 |
|
loadoct(fname) /* read in objects from octree */ |
199 |
|
char *fname; |
200 |
|
{ |
206 |
|
|
207 |
|
infn = fname; |
208 |
|
infp = fopen(fname, "r"); /* assume already checked */ |
209 |
< |
#ifdef MSDOS |
212 |
< |
setmode(fileno(infp), O_BINARY); |
213 |
< |
#endif |
209 |
> |
SET_FILE_BINARY(infp); |
210 |
|
/* skip header */ |
211 |
|
getheader(infp, NULL, NULL); |
212 |
|
/* get format */ |
282 |
|
} |
283 |
|
|
284 |
|
|
285 |
< |
static |
285 |
> |
static void |
286 |
|
skiptree() /* skip octree on input */ |
287 |
|
{ |
288 |
|
register int i; |
307 |
|
} |
308 |
|
|
309 |
|
|
310 |
< |
static |
310 |
> |
static int |
311 |
|
loadobj() /* get next object */ |
312 |
|
{ |
313 |
|
static OBJREC ob; |
380 |
|
} |
381 |
|
|
382 |
|
|
383 |
< |
static |
383 |
> |
static void |
384 |
|
octerror(etyp, msg) /* octree error */ |
385 |
|
int etyp; |
386 |
|
char *msg; |