| 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.; |
| 35 |
|
int i, n; |
| 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", |
| 96 |
+ |
argv[0]); |
| 97 |
+ |
exit(1); |
| 98 |
+ |
} |
| 99 |
+ |
xfm = argv[++i]; |
| 100 |
+ |
break; |
| 101 |
|
default: |
| 102 |
|
fprintf(stderr, "%s: unknown option: %s\n", |
| 103 |
|
argv[0], argv[i]); |
| 191 |
|
sprintf(cbuf, "Removed %d duplicate faces", n); |
| 192 |
|
addComment(myScene, cbuf); |
| 193 |
|
} |
| 194 |
+ |
if (do_triangulate) { |
| 195 |
+ |
if (verbose) |
| 196 |
+ |
fputs("Making sure all faces are triangles...\n", stderr); |
| 197 |
+ |
n = triangulateScene(myScene); |
| 198 |
+ |
if (n > 0) { |
| 199 |
+ |
sprintf(cbuf, "Added %d faces during triangulation", n); |
| 200 |
+ |
addComment(myScene, cbuf); |
| 201 |
+ |
} |
| 202 |
+ |
} |
| 203 |
+ |
if (xfm != NULL) { |
| 204 |
+ |
if (verbose) |
| 205 |
+ |
fputs("Applying transform...\n", stderr); |
| 206 |
+ |
if (!xfmScene(myScene, xfm)) { |
| 207 |
+ |
fprintf(stderr, "%s: transform error\n", argv[0]); |
| 208 |
+ |
exit(1); |
| 209 |
+ |
} |
| 210 |
+ |
} |
| 211 |
|
if (verbose) |
| 212 |
|
fputs("Writing out scene...\n", stderr); |
| 213 |
|
|
| 231 |
|
fprintf(stderr, "\t+/-t\t\t\t# keep/remove texture coordinates\n"); |
| 232 |
|
fprintf(stderr, "\t+/-n\t\t\t# keep/remove vertex normals\n"); |
| 233 |
|
fprintf(stderr, "\t-c epsilon\t\t# coalesce vertices within epsilon\n"); |
| 234 |
+ |
fprintf(stderr, "\t+T\t\t\t# turn all faces into triangles\n"); |
| 235 |
+ |
fprintf(stderr, "\t-x 'xf spec'\t# apply the quoted transform\n"); |
| 236 |
|
return(1); |
| 237 |
|
} |
| 238 |
|
|
| 239 |
|
void |
| 240 |
< |
eputs(char *s) /* put string to stderr */ |
| 240 |
> |
eputs(const char *s) /* put string to stderr */ |
| 241 |
|
{ |
| 242 |
|
static int midline = 0; |
| 243 |
|
|