--- ray/src/cv/rad2mgf.c 1998/09/04 09:09:58 2.14 +++ ray/src/cv/rad2mgf.c 2003/10/27 10:26:45 2.21 @@ -1,16 +1,17 @@ -/* Copyright (c) 1995 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: rad2mgf.c,v 2.21 2003/10/27 10:26:45 schorsch Exp $"; #endif - /* * Convert Radiance scene description to MGF */ +#include "platform.h" #include "standard.h" #include #include +#include + +#include "rtprocess.h" #include "object.h" #include "color.h" #include "lookup.h" @@ -22,8 +23,6 @@ int o_instance(), o_illum(); int o_plastic(), o_metal(), o_glass(), o_dielectric(), o_mirror(), o_trans(), o_light(); -extern int free(); - LUTAB rmats = LU_SINIT(free,NULL); /* defined material table */ LUTAB rdispatch = LU_SINIT(NULL,NULL); /* function dispatch table */ @@ -265,7 +264,7 @@ char *id; *cp2++ = 'O'; } for (cp = id; cp < end; *cp2++ = *cp++) { - if (*cp < '!' | *cp > '~') /* limit to visible chars */ + if ((*cp < '!') | (*cp > '~')) /* limit to visible chars */ *cp = '?'; diff += *cp != *cp2; } @@ -290,6 +289,7 @@ init() /* initialize dispatch table and output */ add2dispatch("tube", o_cylinder); add2dispatch("ring", o_ring); add2dispatch("instance", o_instance); + add2dispatch("mesh", o_instance); add2dispatch("plastic", o_plastic); add2dispatch("plastic2", o_plastic); add2dispatch("metal", o_metal); @@ -426,18 +426,23 @@ o_face(mod, typ, id, fa) /* print out a polygon */ char *mod, *typ, *id; FUNARGS *fa; { - char entbuf[2048]; + char entbuf[2048], *linestart; register char *cp; register int i; - if (fa->nfargs < 9 | fa->nfargs % 3) + if ((fa->nfargs < 9) | (fa->nfargs % 3)) return(-1); setmat(mod); setobj(id); - cp = entbuf; + cp = linestart = entbuf; *cp++ = 'f'; for (i = 0; i < fa->nfargs; i += 3) { *cp++ = ' '; + if (cp - linestart > 72) { + *cp++ = '\\'; *cp++ = '\n'; + linestart = cp; + *cp++ = ' '; *cp++ = ' '; + } getvertid(cp, fa->farg + i); while (*cp) cp++; @@ -530,7 +535,7 @@ register FUNARGS *fa; int -o_instance(mod, typ, id, fa) /* convert an instance */ +o_instance(mod, typ, id, fa) /* convert an instance (or mesh) */ char *mod, *typ, *id; FUNARGS *fa; {