--- ray/src/cv/mgflib/mgf2inv.c 1995/12/05 10:34:12 1.3 +++ ray/src/cv/mgflib/mgf2inv.c 1997/05/22 08:41:04 1.7 @@ -16,13 +16,15 @@ static char SCCSid[] = "$SunId$ LBL"; #include +#include + #include "parser.h" #include "lookup.h" #define O_INV1 1 /* Inventor 1.0 output */ #define O_INV2 2 /* Inventor 2.0 output */ -#define O_VRML 3 /* VRML output */ +#define O_VRML1 3 /* VRML 1.0 output */ #define MAXID 48 /* maximum identifier length */ @@ -97,7 +99,7 @@ char *argv[]; /* get options and print format line */ for (i = 1; i < argc && argv[i][0] == '-'; i++) if (!strcmp(argv[i], "-vrml")) - outtype = O_VRML; + outtype = O_VRML1; else if (!strcmp(argv[i], "-1")) outtype = O_INV1; else if (!strcmp(argv[i], "-2")) @@ -111,8 +113,8 @@ char *argv[]; case O_INV2: printf("#Inventor V2.0 ascii\n"); break; - case O_VRML: - printf("#VRML 1.0 ascii\n"); + case O_VRML1: + printf("#VRML V1.0 ascii\n"); break; } printf("## Translated from MGF Version %d.%d\n", MG_VMAJOR, MG_VMINOR); @@ -338,7 +340,7 @@ put_material() /* put out current material */ mgf2rgb(&c_cmaterial->rs_c, c_cmaterial->rs, rgbval); printf("%sspecularColor %.4f %.4f %.4f\n", tabs, rgbval[0], rgbval[1], rgbval[2]); - printf("%sshininess %.3f\n", tabs, 1.-c_cmaterial->rs_a); + printf("%sshininess %.3f\n", tabs, 1.-sqrt(c_cmaterial->rs_a)); } if (c_cmaterial->ed > FTINY) { mgf2rgb(&c_cmaterial->ed_c, 1.0, rgbval); @@ -468,7 +470,12 @@ char **av; va[1] = v2->p[1] - v1->p[1]; va[2] = v2->p[2] - v1->p[2]; length = sqrt(DOT(va,va)); - angle = acos(va[1]/length); + if (va[1] >= length) + angle = 0.; + else if (va[1] <= -length) + angle = PI; + else + angle = acos(va[1]/length); printf("%sTranslation { translation %13.9g %13.9g %13.9g }\n", tabs, .5*(v1->p[0]+v2->p[0]), .5*(v1->p[1]+v2->p[1]), .5*(v1->p[2]+v2->p[2]));