6 |
|
*/ |
7 |
|
|
8 |
|
#include "copyright.h" |
9 |
+ |
#include "paths.h" |
10 |
|
#include "platform.h" |
11 |
|
#include "standard.h" |
12 |
+ |
#include "resolu.h" |
13 |
|
#include "cvmesh.h" |
14 |
|
#include "otypes.h" |
15 |
|
|
16 |
< |
extern int o_face(); |
16 |
> |
extern int o_face(); /* XXX should go to a header file */ |
17 |
|
|
18 |
|
int o_default() { return(O_MISS); } |
19 |
|
|
23 |
|
|
24 |
|
int nowarn = 0; /* supress warnings? */ |
25 |
|
|
26 |
< |
int objlim = 15; /* # of objects before split */ |
26 |
> |
int objlim = 9; /* # of objects before split */ |
27 |
|
|
28 |
|
int resolu = 16384; /* octree resolution limit */ |
29 |
|
|
30 |
|
double mincusize; /* minimum cube size from resolu */ |
31 |
|
|
32 |
+ |
static void addface(CUBE *cu, OBJECT obj); |
33 |
+ |
static void add2full(CUBE *cu, OBJECT obj); |
34 |
|
|
35 |
< |
main(argc, argv) /* compile a .OBJ file into a mesh */ |
36 |
< |
int argc; |
37 |
< |
char *argv[]; |
35 |
> |
|
36 |
> |
int |
37 |
> |
main( /* compile a .OBJ file into a mesh */ |
38 |
> |
int argc, |
39 |
> |
char *argv[] |
40 |
> |
) |
41 |
|
{ |
42 |
|
int nmatf = 0; |
43 |
< |
char *matinp[32]; |
43 |
> |
char pathnames[12800]; |
44 |
> |
char *pns = pathnames; |
45 |
> |
char *matinp[128]; |
46 |
> |
char *cp; |
47 |
|
int i, j; |
48 |
|
|
49 |
|
progname = argv[0]; |
60 |
|
case 'a': /* material file */ |
61 |
|
matinp[nmatf++] = argv[++i]; |
62 |
|
break; |
63 |
+ |
case 'l': /* library material */ |
64 |
+ |
cp = getpath(argv[++i], getrlibpath(), R_OK); |
65 |
+ |
if (cp == NULL) { |
66 |
+ |
sprintf(errmsg, |
67 |
+ |
"cannot find library material: '%s'", |
68 |
+ |
argv[i]); |
69 |
+ |
error(USER, errmsg); |
70 |
+ |
} |
71 |
+ |
matinp[nmatf++] = strcpy(pns, cp); |
72 |
+ |
while (*pns++) |
73 |
+ |
; |
74 |
+ |
break; |
75 |
|
case 'w': /* supress warnings */ |
76 |
|
nowarn = 1; |
77 |
|
break; |
80 |
|
error(USER, errmsg); |
81 |
|
break; |
82 |
|
} |
83 |
+ |
|
84 |
+ |
if (i < argc-2) |
85 |
+ |
error(USER, "too many file arguments"); |
86 |
|
/* initialize mesh */ |
87 |
|
cvinit(i==argc-2 ? argv[i+1] : "<stdout>"); |
88 |
|
/* load material input */ |
124 |
|
/* printmeshstats(ourmesh, stderr); */ |
125 |
|
|
126 |
|
quit(0); |
127 |
+ |
return 0; /* pro forma return */ |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
|
void |
132 |
< |
quit(code) /* exit program */ |
133 |
< |
int code; |
132 |
> |
quit( /* exit program */ |
133 |
> |
int code |
134 |
> |
) |
135 |
|
{ |
136 |
|
exit(code); |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
void |
141 |
< |
cputs() /* interactive error */ |
141 |
> |
cputs(void) /* interactive error */ |
142 |
|
{ |
143 |
|
/* referenced, but not used */ |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
|
void |
148 |
< |
wputs(s) /* warning message */ |
149 |
< |
char *s; |
148 |
> |
wputs( /* warning message */ |
149 |
> |
char *s |
150 |
> |
) |
151 |
|
{ |
152 |
|
if (!nowarn) |
153 |
|
eputs(s); |
155 |
|
|
156 |
|
|
157 |
|
void |
158 |
< |
eputs(s) /* put string to stderr */ |
159 |
< |
register char *s; |
158 |
> |
eputs( /* put string to stderr */ |
159 |
> |
register char *s |
160 |
> |
) |
161 |
|
{ |
162 |
|
static int inln = 0; |
163 |
|
|
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
< |
addface(cu, obj) /* add a face to a cube */ |
175 |
< |
register CUBE *cu; |
176 |
< |
OBJECT obj; |
174 |
> |
static void |
175 |
> |
addface( /* add a face to a cube */ |
176 |
> |
register CUBE *cu, |
177 |
> |
OBJECT obj |
178 |
> |
) |
179 |
|
{ |
180 |
|
|
181 |
|
if (o_face(objptr(obj), cu) == O_MISS) |
208 |
|
} |
209 |
|
|
210 |
|
|
211 |
< |
add2full(cu, obj) /* add object to full node */ |
212 |
< |
register CUBE *cu; |
213 |
< |
OBJECT obj; |
211 |
> |
static void |
212 |
> |
add2full( /* add object to full node */ |
213 |
> |
register CUBE *cu, |
214 |
> |
OBJECT obj |
215 |
> |
) |
216 |
|
{ |
217 |
|
OCTREE ot; |
218 |
|
OBJECT oset[MAXSET+1]; |
222 |
|
objset(oset, cu->cutree); |
223 |
|
cukid.cusize = cu->cusize * 0.5; |
224 |
|
|
225 |
< |
if (oset[0] < objlim || cukid.cusize < mincusize) { |
225 |
> |
if (oset[0] < objlim || cukid.cusize < |
226 |
> |
(oset[0] < MAXSET ? mincusize : mincusize/256.0)) { |
227 |
|
/* add to set */ |
228 |
|
if (oset[0] >= MAXSET) { |
229 |
|
sprintf(errmsg, "set overflow in addobject (%s)", |