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 |
|
|
13 |
+ |
#define MAXLEVEL 16 /* maximum instance hierarchy level */ |
14 |
+ |
|
15 |
|
typedef struct { |
16 |
|
int listid; /* our list id */ |
17 |
|
short localmatl; /* uses local material only */ |
19 |
|
char octfile[256]; /* octree file path */ |
20 |
|
} OCTINST; /* octree to instantiate */ |
21 |
|
|
21 |
– |
OBJECT nobjects; /* number of objects loaded so far */ |
22 |
– |
|
23 |
– |
extern int free(); |
24 |
– |
|
22 |
|
static double ogetflt(); |
23 |
|
static long ogetint(); |
24 |
|
static char *ogetstr(); |
25 |
< |
static int loadobj(), octerror(), skiptree(); |
25 |
> |
static int loadobj(); |
26 |
> |
static void skiptree(); |
27 |
> |
static void octerror(); |
28 |
|
static OCTINST *getoct(); |
29 |
|
|
30 |
|
static char *infn; /* input file name */ |
32 |
|
static int objsize; /* size of stored OBJECT's */ |
33 |
|
static short otypmap[NUMOTYPE+8]; /* object type map */ |
34 |
|
|
35 |
< |
static long imhash(mod) char *mod; {return((long)mod);} |
35 |
> |
static unsigned long imhash(mod) char *mod; {return((unsigned long)mod);} |
36 |
|
static LUTAB imtab = {imhash,NULL,NULL,NULL,0,NULL,0}; |
37 |
|
|
38 |
|
static LUTAB ottab = LU_SINIT(free,free); |
39 |
|
|
40 |
|
|
41 |
+ |
int |
42 |
|
o_instance(o) /* convert instance to list call */ |
43 |
|
register OBJREC *o; |
44 |
|
{ |
67 |
|
} |
68 |
|
ot = getoct(o->oargs.sarg[0]); /* get octree reference */ |
69 |
|
if (ot->localmatl &= o->os != NULL) /* set material */ |
70 |
< |
setmaterial(o->os, ot->cent, 0); |
70 |
> |
setmaterial((MATREC *)o->os, ot->cent, 0); |
71 |
|
/* call the assigned list */ |
72 |
|
glCallList(ot->listid); |
73 |
|
|
74 |
|
if (o->oargs.nsargs > 1) { /* end transform */ |
75 |
+ |
glMatrixMode(GL_MODELVIEW); |
76 |
|
glPopMatrix(); |
77 |
|
glPopAttrib(); |
78 |
|
} |
79 |
|
rgl_checkerr("creating instance"); |
80 |
+ |
return(0); |
81 |
|
} |
82 |
|
|
83 |
|
|
103 |
|
int |
104 |
|
loadoctrees() /* load octrees we've saved up */ |
105 |
|
{ |
106 |
+ |
int levelsleft = MAXLEVEL; |
107 |
|
int nocts = 0; |
108 |
|
LUTAB looptab; |
109 |
|
/* loop through new octree references */ |
110 |
|
while (ottab.tsiz) { |
111 |
+ |
if (!levelsleft--) |
112 |
+ |
error(USER, "too many octree levels -- instance loop?"); |
113 |
|
copystruct(&looptab, &ottab); |
114 |
|
ottab.tsiz = 0; |
115 |
|
nocts += lu_doall(&looptab, buildoctlist); |
123 |
|
getoct(name) /* get/assign octree list id */ |
124 |
|
char *name; |
125 |
|
{ |
121 |
– |
extern char *getpath(), *getlibpath(); |
126 |
|
char *path; |
127 |
|
register LUENT *lp; |
128 |
|
register OCTINST *op; |
136 |
|
strcpy(lp->key, name); |
137 |
|
} |
138 |
|
if ((op = (OCTINST *)lp->data) == NULL) { |
139 |
< |
path = getpath(name, getlibpath(), R_OK); |
139 |
> |
path = getpath(name, getrlibpath(), R_OK); |
140 |
|
if (path == NULL) { |
141 |
|
sprintf(errmsg, "cannot find octree \"%s\"", name); |
142 |
|
error(USER, errmsg); |
195 |
|
} |
196 |
|
|
197 |
|
|
198 |
+ |
int |
199 |
|
loadoct(fname) /* read in objects from octree */ |
200 |
|
char *fname; |
201 |
|
{ |
285 |
|
} |
286 |
|
|
287 |
|
|
288 |
< |
static |
288 |
> |
static void |
289 |
|
skiptree() /* skip octree on input */ |
290 |
|
{ |
291 |
|
register int i; |
310 |
|
} |
311 |
|
|
312 |
|
|
313 |
< |
static |
313 |
> |
static int |
314 |
|
loadobj() /* get next object */ |
315 |
|
{ |
316 |
|
static OBJREC ob; |
383 |
|
} |
384 |
|
|
385 |
|
|
386 |
< |
static |
386 |
> |
static void |
387 |
|
octerror(etyp, msg) /* octree error */ |
388 |
|
int etyp; |
389 |
|
char *msg; |