| 10 |
|
#include <stdlib.h> |
| 11 |
|
#include <string.h> |
| 12 |
|
#include "rtio.h" |
| 13 |
+ |
#include "paths.h" |
| 14 |
|
#include "objutil.h" |
| 15 |
|
|
| 15 |
– |
const char *progname; |
| 16 |
|
int verbose = 0; |
| 17 |
|
|
| 18 |
|
int |
| 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; |
| 36 |
< |
|
| 37 |
< |
progname = argv[0]; |
| 36 |
> |
/* set global progname */ |
| 37 |
> |
fixargv0(argv[0]); |
| 38 |
|
/* process options */ |
| 39 |
|
for (i = 1; i < argc && (argv[i][0] == '-' || argv[i][0] == '+'); i++) |
| 40 |
|
switch (argv[i][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 |
|
|