16 |
|
|
17 |
|
#include <ctype.h> |
18 |
|
|
19 |
+ |
#include <string.h> |
20 |
+ |
|
21 |
|
#include "parser.h" |
22 |
|
|
23 |
|
#include "lookup.h" |
24 |
|
|
25 |
|
#define O_INV1 1 /* Inventor 1.0 output */ |
26 |
|
#define O_INV2 2 /* Inventor 2.0 output */ |
27 |
< |
#define O_VRML 3 /* VRML output */ |
27 |
> |
#define O_VRML1 3 /* VRML 1.0 output */ |
28 |
|
|
29 |
|
#define MAXID 48 /* maximum identifier length */ |
30 |
|
|
99 |
|
/* get options and print format line */ |
100 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
101 |
|
if (!strcmp(argv[i], "-vrml")) |
102 |
< |
outtype = O_VRML; |
102 |
> |
outtype = O_VRML1; |
103 |
|
else if (!strcmp(argv[i], "-1")) |
104 |
|
outtype = O_INV1; |
105 |
|
else if (!strcmp(argv[i], "-2")) |
113 |
|
case O_INV2: |
114 |
|
printf("#Inventor V2.0 ascii\n"); |
115 |
|
break; |
116 |
< |
case O_VRML: |
117 |
< |
printf("#VRML 1.0 ascii\n"); |
116 |
> |
case O_VRML1: |
117 |
> |
printf("#VRML V1.0 ascii\n"); |
118 |
|
break; |
119 |
|
} |
120 |
|
printf("## Translated from MGF Version %d.%d\n", MG_VMAJOR, MG_VMINOR); |
340 |
|
mgf2rgb(&c_cmaterial->rs_c, c_cmaterial->rs, rgbval); |
341 |
|
printf("%sspecularColor %.4f %.4f %.4f\n", tabs, |
342 |
|
rgbval[0], rgbval[1], rgbval[2]); |
343 |
< |
printf("%sshininess %.3f\n", tabs, 1.-c_cmaterial->rs_a); |
343 |
> |
printf("%sshininess %.3f\n", tabs, 1.-sqrt(c_cmaterial->rs_a)); |
344 |
|
} |
345 |
|
if (c_cmaterial->ed > FTINY) { |
346 |
|
mgf2rgb(&c_cmaterial->ed_c, 1.0, rgbval); |
470 |
|
va[1] = v2->p[1] - v1->p[1]; |
471 |
|
va[2] = v2->p[2] - v1->p[2]; |
472 |
|
length = sqrt(DOT(va,va)); |
473 |
< |
angle = acos(va[1]/length); |
473 |
> |
if (va[1] >= length) |
474 |
> |
angle = 0.; |
475 |
> |
else if (va[1] <= -length) |
476 |
> |
angle = PI; |
477 |
> |
else |
478 |
> |
angle = acos(va[1]/length); |
479 |
|
printf("%sTranslation { translation %13.9g %13.9g %13.9g }\n", tabs, |
480 |
|
.5*(v1->p[0]+v2->p[0]), .5*(v1->p[1]+v2->p[1]), |
481 |
|
.5*(v1->p[2]+v2->p[2])); |