28 |
|
int save_mats = 1; |
29 |
|
int do_tex = 0; |
30 |
|
int do_norm = 0; |
31 |
+ |
int do_triangulate = 0; |
32 |
|
char *xfm = NULL; |
33 |
|
char cbuf[256]; |
34 |
|
double verteps = -1.; |
87 |
|
case 'r': /* output to Radiance file? */ |
88 |
|
radout = (argv[i][0] == '+'); |
89 |
|
break; |
90 |
+ |
case 'T': /* triangulate faces? */ |
91 |
+ |
do_triangulate = (argv[i][0] == '+'); |
92 |
+ |
break; |
93 |
|
case 'x': /* apply a transform */ |
94 |
|
if (xfm != NULL) { |
95 |
|
fprintf(stderr, "%s: only one '-x' option allowed\n", |
185 |
|
} |
186 |
|
if (verbose) |
187 |
|
fputs("Checking for duplicate faces...\n", stderr); |
188 |
< |
if (findDuplicateFaces(myScene)) |
188 |
> |
if (findDuplicateFaces(myScene)) { |
189 |
|
n = deleteFaces(myScene, FACE_DUPLICATE, 0); |
190 |
< |
if (n) { |
191 |
< |
sprintf(cbuf, "Removed %d duplicate faces", n); |
192 |
< |
addComment(myScene, cbuf); |
190 |
> |
if (n) { |
191 |
> |
sprintf(cbuf, "Removed %d duplicate faces", n); |
192 |
> |
addComment(myScene, cbuf); |
193 |
> |
} |
194 |
|
} |
195 |
+ |
if (do_triangulate) { |
196 |
+ |
if (verbose) |
197 |
+ |
fputs("Making sure all faces are triangles...\n", stderr); |
198 |
+ |
n = triangulateScene(myScene); |
199 |
+ |
if (n > 0) { |
200 |
+ |
sprintf(cbuf, "Added %d faces during triangulation", n); |
201 |
+ |
addComment(myScene, cbuf); |
202 |
+ |
} |
203 |
+ |
} |
204 |
|
if (xfm != NULL) { |
205 |
|
if (verbose) |
206 |
|
fputs("Applying transform...\n", stderr); |
232 |
|
fprintf(stderr, "\t+/-t\t\t\t# keep/remove texture coordinates\n"); |
233 |
|
fprintf(stderr, "\t+/-n\t\t\t# keep/remove vertex normals\n"); |
234 |
|
fprintf(stderr, "\t-c epsilon\t\t# coalesce vertices within epsilon\n"); |
235 |
+ |
fprintf(stderr, "\t+T\t\t\t# turn all faces into triangles\n"); |
236 |
|
fprintf(stderr, "\t-x 'xf spec'\t# apply the quoted transform\n"); |
237 |
|
return(1); |
238 |
|
} |
239 |
|
|
240 |
|
void |
241 |
< |
eputs(char *s) /* put string to stderr */ |
241 |
> |
eputs(const char *s) /* put string to stderr */ |
242 |
|
{ |
243 |
|
static int midline = 0; |
244 |
|
|