--- ray/src/gen/replmarks.c 2005/03/17 06:38:45 2.13 +++ ray/src/gen/replmarks.c 2008/01/25 02:11:13 2.15 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: replmarks.c,v 2.13 2005/03/17 06:38:45 greg Exp $"; +static const char RCSid[] = "$Id: replmarks.c,v 2.15 2008/01/25 02:11:13 greg Exp $"; #endif /* * Replace markers in Radiance scene description with objects or instances. @@ -202,7 +202,9 @@ cvobject( /* convert an object */ int i, n; register int j; - if (fscanf(fin, "%s %s %s", buf, typ, nam) != 3) + if (fgetword(buf, sizeof(buf), fin) == NULL || + fgetword(typ, sizeof(typ), fin) == NULL || + fgetword(nam, sizeof(nam), fin) == NULL) goto readerr; if (!strcmp(typ, "polygon")) for (j = 0; j < nmarkers; j++) @@ -210,11 +212,13 @@ cvobject( /* convert an object */ replace(fname, &marker[j], nam, fin); return; } - printf("\n%s %s %s\n", buf, typ, nam); + putchar('\n'); fputword(buf, stdout); + printf(" %s ", typ); + fputword(nam, stdout); putchar('\n'); if (!strcmp(typ, "alias")) { /* alias special case */ - if (fscanf(fin, "%s", buf) != 1) + if (fgetword(buf, sizeof(buf), fin) == NULL) goto readerr; - printf("\t%s\n", buf); + putchar('\t'); fputword(buf, stdout); putchar('\n'); return; } for (i = 0; i < 3; i++) { /* pass along arguments */ @@ -387,6 +391,14 @@ addrot( /* compute rotation (x,y,z) => (xp,yp,zp) */ int n; double theta; + if (yp[2]*yp[2] + zp[2]*zp[2] < 2.*FTINY*FTINY) { + /* Special case for X' along Z-axis */ + theta = -atan2(yp[0], yp[1]); + sprintf(xf, " -ry %f -rz %f", + xp[2] < 0.0 ? 90.0 : -90.0, + theta*(180./PI)); + return(4); + } n = 0; theta = atan2(yp[2], zp[2]); if (!FEQ(theta,0.0)) {