270 |
|
int libs = 0; |
271 |
|
float vue_version = 1.0; |
272 |
|
Matrix *ani_matrix = NULL; |
273 |
+ |
int no_opt = FALSE; |
274 |
+ |
FILE *meshf = NULL; |
275 |
|
|
276 |
|
|
277 |
|
void process_args (int argc, char *argv[]); |
354 |
|
|
355 |
|
int main (int argc, char *argv[]) |
356 |
|
{ |
357 |
+ |
char meshfname[128]; |
358 |
|
Material *m; |
359 |
|
int i; |
360 |
|
|
361 |
|
process_args (argc, argv); |
362 |
|
|
363 |
< |
if (format != RAW) { |
363 |
> |
if (!no_opt) { |
364 |
|
opt_set_format (format); |
365 |
|
opt_set_dec (4); |
366 |
|
opt_set_bound (bound); |
367 |
|
opt_set_smooth (smooth); |
368 |
|
opt_set_quiet (!verbose); |
369 |
|
opt_set_fname (outname, ""); |
370 |
+ |
} else if (format == MGF) { |
371 |
+ |
strcpy(meshfname, outname); |
372 |
+ |
add_ext(meshfname, "inc", 1); |
373 |
+ |
if (!strcmp(meshfname, outname)) { |
374 |
+ |
printf ("Output and mesh file names are identical!\n"); |
375 |
+ |
exit (1); |
376 |
+ |
} |
377 |
+ |
if ((meshf = fopen (meshfname, "w")) == NULL) { |
378 |
+ |
printf ("Cannot open mesh output file %s!\n", meshfname); |
379 |
+ |
exit (1); |
380 |
+ |
} |
381 |
|
} |
382 |
|
|
383 |
|
if ((in = fopen (inname, "rb")) == NULL) { |
421 |
|
if (frame >= 0) |
422 |
|
save_animation(); |
423 |
|
|
424 |
< |
if (format != RAW) { |
424 |
> |
if (!no_opt) { |
425 |
|
write_summary (out); |
426 |
|
fflush (out); |
427 |
|
|
428 |
|
opt_finish(); |
429 |
+ |
} else if (meshf != NULL) { |
430 |
+ |
fclose(meshf); |
431 |
+ |
fprintf (out, "i %s\n", meshfname); |
432 |
|
} |
433 |
|
|
434 |
|
fclose (out); |
553 |
|
|
554 |
|
if ((strlen(vuename) > 0) != (frame >= 0)) |
555 |
|
abortmsg ("The -a and -f parameters must be used together", 1); |
556 |
+ |
|
557 |
+ |
if (format == RAW || (format == MGF && smooth < 0.1)) |
558 |
+ |
no_opt = TRUE; |
559 |
|
} |
560 |
|
|
561 |
|
|
1600 |
|
/* Write a mesh file */ |
1601 |
|
void write_mesh (FILE *f, Mesh *mesh) |
1602 |
|
{ |
1603 |
+ |
FILE *fi; |
1604 |
|
int i; |
1605 |
+ |
char curmat[80]; |
1606 |
|
Vector va, vb, vc; |
1607 |
|
Summary *new_summary; |
1608 |
|
Matrix obj_matrix; |
1629 |
|
} |
1630 |
|
|
1631 |
|
switch (format) { |
1632 |
+ |
case MGF: |
1633 |
+ |
if (no_opt) { |
1634 |
+ |
if (mesh->name[0]) fprintf (meshf, "o %s\n", mesh->name); |
1635 |
+ |
for (i = 0; i < mesh->vertices; i++) { |
1636 |
+ |
vect_copy(va, mesh->vertex[i]); |
1637 |
+ |
if (ani_matrix != NULL) |
1638 |
+ |
vect_transform (va, va, obj_matrix); |
1639 |
+ |
fprintf (meshf, "v v%d =\n\tp %.5f %.5f %.5f\n", |
1640 |
+ |
i, va[X], va[Y], va[Z]); |
1641 |
+ |
} |
1642 |
+ |
curmat[0] = '\0'; |
1643 |
+ |
for (i = 0; i < mesh->faces; i++) { |
1644 |
+ |
if (strcmp(mesh->mtl[i]->name, curmat)) { |
1645 |
+ |
strcpy(curmat, mesh->mtl[i]->name); |
1646 |
+ |
fprintf (meshf, "m %s\n", curmat); |
1647 |
+ |
} |
1648 |
+ |
fprintf (meshf, "f v%d v%d v%d\n", mesh->face[i].a, |
1649 |
+ |
mesh->face[i].b, mesh->face[i].c); |
1650 |
+ |
} |
1651 |
+ |
if (mesh->name[0]) fprintf (meshf, "o\n"); |
1652 |
+ |
break; |
1653 |
+ |
} |
1654 |
+ |
/*FALL THROUGH*/ |
1655 |
|
case POV10: |
1656 |
|
case POV20: |
1657 |
|
case VIVID: |
1658 |
|
case POLYRAY: |
1614 |
– |
case MGF: |
1659 |
|
opt_set_vert (mesh->vertices); |
1660 |
|
|
1661 |
|
for (i = 0; i < mesh->faces; i++) { |