31 |
|
int argc; |
32 |
|
char *argv[]; |
33 |
|
{ |
34 |
< |
int i; |
34 |
> |
int nmatf = 0; |
35 |
> |
char *matinp[32]; |
36 |
> |
int i, j; |
37 |
|
|
38 |
|
progname = argv[0]; |
39 |
|
ofun[OBJ_FACE].funp = o_face; |
46 |
|
case 'r': /* resolution limit */ |
47 |
|
resolu = atoi(argv[++i]); |
48 |
|
break; |
49 |
+ |
case 'a': /* material file */ |
50 |
+ |
matinp[nmatf++] = argv[++i]; |
51 |
+ |
break; |
52 |
|
case 'w': /* supress warnings */ |
53 |
|
nowarn = 1; |
54 |
|
break; |
59 |
|
} |
60 |
|
/* initialize mesh */ |
61 |
|
cvinit(i==argc-2 ? argv[i+1] : "<stdout>"); |
62 |
< |
|
63 |
< |
if (i == argc) /* read .OBJ file into triangles */ |
62 |
> |
/* load material input */ |
63 |
> |
for (j = 0; j < nmatf; j++) |
64 |
> |
readobj(matinp[j]); |
65 |
> |
/* read .OBJ file into triangles */ |
66 |
> |
if (i == argc) |
67 |
|
wfreadobj(NULL); |
68 |
|
else |
69 |
|
wfreadobj(argv[i]); |
84 |
|
mincusize = ourmesh->mcube.cusize / resolu - FTINY; |
85 |
|
|
86 |
|
for (i = 0; i < nobjects; i++) /* add triangles to octree */ |
87 |
< |
addface(&ourmesh->mcube, i); |
87 |
> |
if (objptr(i)->otype == OBJ_FACE) |
88 |
> |
addface(&ourmesh->mcube, i); |
89 |
|
|
90 |
|
/* optimize octree */ |
91 |
|
ourmesh->mcube.cutree = combine(ourmesh->mcube.cutree); |
97 |
|
|
98 |
|
writemesh(ourmesh, stdout); /* write mesh to output */ |
99 |
|
|
100 |
< |
printmeshstats(ourmesh, stderr); |
100 |
> |
/* printmeshstats(ourmesh, stderr); */ |
101 |
|
|
102 |
|
quit(0); |
103 |
|
} |
147 |
|
register CUBE *cu; |
148 |
|
OBJECT obj; |
149 |
|
{ |
141 |
– |
CUBE cukid; |
142 |
– |
OCTREE ot; |
143 |
– |
OBJECT oset[MAXSET+1]; |
144 |
– |
register int i, j; |
150 |
|
|
151 |
|
if (o_face(objptr(obj), cu) == O_MISS) |
152 |
|
return; |
153 |
|
|
154 |
|
if (istree(cu->cutree)) { |
155 |
< |
/* do children */ |
155 |
> |
CUBE cukid; /* do children */ |
156 |
> |
int i, j; |
157 |
|
cukid.cusize = cu->cusize * 0.5; |
158 |
|
for (i = 0; i < 8; i++) { |
159 |
|
cukid.cutree = octkid(cu->cutree, i); |
168 |
|
return; |
169 |
|
} |
170 |
|
if (isempty(cu->cutree)) { |
171 |
< |
/* singular set */ |
171 |
> |
OBJECT oset[2]; /* singular set */ |
172 |
|
oset[0] = 1; oset[1] = obj; |
173 |
|
cu->cutree = fullnode(oset); |
174 |
|
return; |
175 |
|
} |
176 |
|
/* add to full node */ |
177 |
+ |
add2full(cu, obj); |
178 |
+ |
} |
179 |
+ |
|
180 |
+ |
|
181 |
+ |
add2full(cu, obj) /* add object to full node */ |
182 |
+ |
register CUBE *cu; |
183 |
+ |
OBJECT obj; |
184 |
+ |
{ |
185 |
+ |
OCTREE ot; |
186 |
+ |
OBJECT oset[MAXSET+1]; |
187 |
+ |
CUBE cukid; |
188 |
+ |
register int i, j; |
189 |
+ |
|
190 |
|
objset(oset, cu->cutree); |
191 |
|
cukid.cusize = cu->cusize * 0.5; |
192 |
|
|
193 |
|
if (oset[0] < objlim || cukid.cusize < mincusize) { |
194 |
|
/* add to set */ |
195 |
|
if (oset[0] >= MAXSET) { |
196 |
< |
sprintf(errmsg, "set overflow in addface (%s)", |
196 |
> |
sprintf(errmsg, "set overflow in addobject (%s)", |
197 |
|
objptr(obj)->oname); |
198 |
|
error(INTERNAL, errmsg); |
199 |
|
} |