ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/rad2mgf.c
(Generate patch)

Comparing ray/src/cv/rad2mgf.c (file contents):
Revision 2.1 by greg, Thu Jul 7 17:30:33 1994 UTC vs.
Revision 2.21 by schorsch, Mon Oct 27 10:26:45 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1994 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Convert Radiance scene description to MGF
6   */
7  
8 < #include <stdio.h>
8 > #include "platform.h"
9 > #include "standard.h"
10 > #include <ctype.h>
11   #include <string.h>
12 < #include "fvect.h"
12 > #include <stdio.h>
13 >
14 > #include "rtprocess.h"
15   #include "object.h"
16   #include "color.h"
17   #include "lookup.h"
18  
19 + #define C_1SIDEDTHICK   0.005
20 +
21   int     o_face(), o_cone(), o_sphere(), o_ring(), o_cylinder();
22 < int     o_instance(), o_source(), o_illum();
23 < int     o_plastic(), o_metal(), o_glass(), o_mirror(), o_trans(), o_light();
22 > int     o_instance(), o_illum();
23 > int     o_plastic(), o_metal(), o_glass(), o_dielectric(),
24 >        o_mirror(), o_trans(), o_light();
25  
22 extern void     free();
23 extern char     *malloc();
24
26   LUTAB   rmats = LU_SINIT(free,NULL);            /* defined material table */
27  
28   LUTAB   rdispatch = LU_SINIT(NULL,NULL);        /* function dispatch table */
29  
30 < char    curmat[80];             /* current material */
30 > char    curmat[80];                             /* current material */
31 > char    curobj[128] = "Untitled";               /* current object name */
32  
33 < double  unit_mult = 1.;         /* units multiplier */
33 > double  unit_mult = 1.;                         /* units multiplier */
34  
35 + #define hasmult         (unit_mult < .999 || unit_mult > 1.001)
36  
37 + /*
38 + * Stuff for tracking and reusing vertices:
39 + */
40 +
41 + char    VKFMT[] = "%+16.9e %+16.9e %+16.9e";
42 + #define VKLEN           64
43 +
44 + #define mkvkey(k,v)     sprintf(k, VKFMT, (v)[0], (v)[1], (v)[2])
45 +
46 + #define NVERTS          256
47 +
48 + long    vclock;         /* incremented at each vertex request */
49 +
50 + struct vert {
51 +        long    lused;          /* when last used (0 if unassigned) */
52 +        FVECT   p;              /* track point position only */
53 + } vert[NVERTS];         /* our vertex cache */
54 +
55 + LUTAB   vertab = LU_SINIT(free,NULL);   /* our vertex lookup table */
56 +
57 +
58   main(argc, argv)
59   int     argc;
60   char    **argv;
# Line 57 | Line 81 | char   **argv;
81                                  goto unkopt;
82                          }
83                          break;
84 +                default:
85 +                        goto unkopt;
86                  }
87          init();
88          if (i >= argc)
# Line 85 | Line 111 | char   *inp;
111          register int    c;
112  
113          if (inp == NULL) {
114 <                inp = "the standard input";
114 >                inp = "standard input";
115                  fp = stdin;
116          } else if (inp[0] == '!') {
117                  if ((fp = popen(inp+1, "r")) == NULL) {
# Line 163 | Line 189 | FUNARGS        *fa;
189                          fprintf(stderr, "%s: bad %s \"%s\"\n", typ, id);
190                          exit(1);
191                  }
192 <        } else if (lu_find(&rmats, mod)->data != NULL)  /* make alias */
193 <                newmat(id, mod);
192 >        } else {                                        /* unsupported */
193 >                o_unsupported(mod, typ, id, fa);
194 >                if (lu_find(&rmats, mod)->data != NULL) /* make alias */
195 >                        newmat(id, mod);
196 >        }
197   }
198  
199  
# Line 209 | Line 238 | char   *id;
238   {
239          if (!strcmp(id, curmat))        /* already set? */
240                  return;
241 +        if (!strcmp(id, VOIDID))        /* cannot set */
242 +                return;
243          printf("m %s\n", id);
244          strcpy(curmat, id);
245   }
246  
247  
248 + setobj(id)                      /* set object name to this one */
249 + char    *id;
250 + {
251 +        register char   *cp, *cp2;
252 +        char    *end = NULL;
253 +        int     diff = 0;
254 +                                /* use all but final suffix */
255 +        for (cp = id; *cp; cp++)
256 +                if (*cp == '.')
257 +                        end = cp;
258 +        if (end == NULL)
259 +                end = cp;
260 +                                /* copy to current object */
261 +        cp2 = curobj;
262 +        if (!isalpha(*id)) {    /* start with letter */
263 +                diff = *cp2 != 'O';
264 +                *cp2++ = 'O';
265 +        }
266 +        for (cp = id; cp < end; *cp2++ = *cp++) {
267 +                if ((*cp < '!') | (*cp > '~'))  /* limit to visible chars */
268 +                        *cp = '?';
269 +                diff += *cp != *cp2;
270 +        }
271 +        if (!diff && !*cp2)
272 +                return;
273 +        *cp2 = '\0';
274 +        fputs("o\no ", stdout);
275 +        puts(curobj);
276 + }
277 +
278 +
279   init()                  /* initialize dispatch table and output */
280   {
281 +        lu_init(&vertab, NVERTS);
282          lu_init(&rdispatch, 22);
283          add2dispatch("polygon", o_face);
284          add2dispatch("cone", o_cone);
# Line 226 | Line 289 | init()                 /* initialize dispatch table and output */
289          add2dispatch("tube", o_cylinder);
290          add2dispatch("ring", o_ring);
291          add2dispatch("instance", o_instance);
292 +        add2dispatch("mesh", o_instance);
293          add2dispatch("plastic", o_plastic);
294          add2dispatch("plastic2", o_plastic);
295          add2dispatch("metal", o_metal);
296          add2dispatch("metal2", o_metal);
297          add2dispatch("glass", o_glass);
298 +        add2dispatch("dielectric", o_dielectric);
299          add2dispatch("trans", o_trans);
300          add2dispatch("trans2", o_trans);
301          add2dispatch("mirror", o_mirror);
# Line 238 | Line 303 | init()                 /* initialize dispatch table and output */
303          add2dispatch("spotlight", o_light);
304          add2dispatch("glow", o_light);
305          add2dispatch("illum", o_illum);
306 <        puts("# The following was converted from Radiance scene input");
307 <        if (unit_mult < .999 || unit_mult > 1.001)
306 >        puts("# The following was converted from RADIANCE scene input");
307 >        if (hasmult)
308                  printf("xf -s %.4e\n", unit_mult);
309 +        printf("o %s\n", curobj);
310   }
311  
312  
313   uninit()                        /* mark end of MGF file */
314   {
315 <        if (unit_mult < .999 || unit_mult > 1.001)
315 >        puts("o");
316 >        if (hasmult)
317                  puts("xf");
318 <        puts("# End of data converted from Radiance scene input");
318 >        puts("# End of data converted from RADIANCE scene input");
319          lu_done(&rdispatch);
320          lu_done(&rmats);
321 +        lu_done(&vertab);
322   }
323  
324  
325 + clrverts()                      /* clear vertex table */
326 + {
327 +        register int    i;
328 +
329 +        lu_done(&vertab);
330 +        for (i = 0; i < NVERTS; i++)
331 +                vert[i].lused = 0;
332 +        lu_init(&vertab, NVERTS);
333 + }
334 +
335 +
336   add2dispatch(name, func)        /* add function to dispatch table */
337   char    *name;
338   int     (*func)();
# Line 271 | Line 350 | int    (*func)();
350   }
351  
352  
274 char    VKFMT[] = "%+1.9e %+1.9e %+1.9e";
275 #define VKLEN           64
276
277 #define mkvkey(k,v)     sprintf(k, VKFMT, (v)[0], (v)[1], (v)[2])
278
279 #define NVERTS          256
280
281 long    clock;          /* incremented at each vertex request */
282
283 struct vert {
284        long    lused;          /* when last used (0 if unassigned) */
285        FVECT   p;              /* track point position only */
286 } vert[NVERTS];
287
288 LUTAB   vertab = LU_SINIT(free,NULL);   /* our vertex lookup table */
289
290
353   char *
354 < getvertid(vp)                   /* get/set vertex ID for this point */
354 > getvertid(vname, vp)            /* get/set vertex ID for this point */
355 > char    *vname;
356   FVECT   vp;
357   {
358 <        static char     vname[6];
296 <        char    vkey[VKLEN];
358 >        static char     vkey[VKLEN];
359          register LUENT  *lp;
360          register int    i, vndx;
361  
362 <        if (!vertab.tsiz && !lu_init(&vertab, NVERTS))
301 <                goto memerr;
302 <        clock++;                        /* increment counter */
362 >        vclock++;                       /* increment counter */
363          mkvkey(vkey, vp);
364          if ((lp = lu_find(&vertab, vkey)) == NULL)
365                  goto memerr;
# Line 319 | Line 379 | FVECT  vp;
379                          mkvkey(vkey, vert[vndx].p);
380                          lu_delete(&vertab, vkey);
381                  }
382 <                vert[vndx].lused = clock;                       /* assign it */
383 <                VCOPY(vert[vndx].p, vp);
324 <                printf("v v%d =\np %.15g %.15g %.15g\n",        /* print it */
382 >                VCOPY(vert[vndx].p, vp);                        /* assign it */
383 >                printf("v v%d =\n\tp %.15g %.15g %.15g\n",      /* print it */
384                                  vndx, vp[0], vp[1], vp[2]);
385                  lp->data = (char *)&vert[vndx];                 /* set it */
386          } else
387                  vndx = (struct vert *)lp->data - vert;
388 +        vert[vndx].lused = vclock;              /* record this use */
389          sprintf(vname, "v%d", vndx);
390          return(vname);
391   memerr:
# Line 335 | Line 395 | memerr:
395  
396  
397   int
398 + o_unsupported(mod, typ, id, fa)         /* mark unsupported primitive */
399 + char    *mod, *typ, *id;
400 + FUNARGS *fa;
401 + {
402 +        register int    i;
403 +
404 +        fputs("\n# Unsupported RADIANCE primitive:\n", stdout);
405 +        printf("# %s %s %s", mod, typ, id);
406 +        printf("\n# %d", fa->nsargs);
407 +        for (i = 0; i < fa->nsargs; i++)
408 +                printf(" %s", fa->sarg[i]);
409 + #ifdef IARGS
410 +        printf("\n# %d", fa->niargs);
411 +        for (i = 0; i < fa->niargs; i++)
412 +                printf(" %ld", fa->iarg[i]);
413 + #else
414 +        fputs("\n# 0", stdout);
415 + #endif
416 +        printf("\n# %d", fa->nfargs);
417 +        for (i = 0; i < fa->nfargs; i++)
418 +                printf(" %g", fa->farg[i]);
419 +        fputs("\n\n", stdout);
420 +        return(0);
421 + }
422 +
423 +
424 + int
425   o_face(mod, typ, id, fa)                /* print out a polygon */
426   char    *mod, *typ, *id;
427   FUNARGS *fa;
428   {
429 <        char    entbuf[512];
430 <        register char   *cp1, *cp2;
429 >        char    entbuf[2048], *linestart;
430 >        register char   *cp;
431          register int    i;
432  
433 <        if (fa->nfargs < 9 | fa->nfargs % 3)
433 >        if ((fa->nfargs < 9) | (fa->nfargs % 3))
434                  return(-1);
435          setmat(mod);
436 <        printf("o %s\n", id);
437 <        cp1 = entbuf;
438 <        *cp1++ = 'f';
436 >        setobj(id);
437 >        cp = linestart = entbuf;
438 >        *cp++ = 'f';
439          for (i = 0; i < fa->nfargs; i += 3) {
440 <                cp2 = getvertid(fa->farg + i);
441 <                *cp1++ = ' ';
442 <                while ((*cp1 = *cp2++))
443 <                        cp1++;
440 >                *cp++ = ' ';
441 >                if (cp - linestart > 72) {
442 >                        *cp++ = '\\'; *cp++ = '\n';
443 >                        linestart = cp;
444 >                        *cp++ = ' '; *cp++ = ' ';
445 >                }
446 >                getvertid(cp, fa->farg + i);
447 >                while (*cp)
448 >                        cp++;
449          }
450          puts(entbuf);
359        puts("o");
451          return(0);
452   }
453  
# Line 366 | Line 457 | o_cone(mod, typ, id, fa)       /* print out a cone */
457   char    *mod, *typ, *id;
458   register FUNARGS        *fa;
459   {
460 +        char    v1[6], v2[6];
461 +
462          if (fa->nfargs != 8)
463                  return(-1);
464          setmat(mod);
465 <        printf("o %s\n", id);
466 <        printf("v cv1 =\np %.12g %.12g %.12g\n",
467 <                        fa->farg[0], fa->farg[1], fa->farg[2]);
375 <        printf("v cv2 =\np %.12g %.12g %.12g\n",
376 <                        fa->farg[3], fa->farg[4], fa->farg[5]);
465 >        setobj(id);
466 >        getvertid(v1, fa->farg);
467 >        getvertid(v2, fa->farg + 3);
468          if (typ[1] == 'u')                      /* cup -> inverted cone */
469 <                printf("cone cv1 %.12g cv2 %.12g\n",
470 <                                -fa->farg[6], -fa->farg[7]);
469 >                printf("cone %s %.12g %s %.12g\n",
470 >                                v1, -fa->farg[6], v2, -fa->farg[7]);
471          else
472 <                printf("cone cv1 %.12g cv2 %.12g\n",
473 <                                fa->farg[6], fa->farg[7]);
383 <        puts("o");
472 >                printf("cone %s %.12g %s %.12g\n",
473 >                                v1, fa->farg[6], v2, fa->farg[7]);
474          return(0);
475   }
476  
# Line 390 | Line 480 | o_sphere(mod, typ, id, fa)     /* print out a sphere */
480   char    *mod, *typ, *id;
481   register FUNARGS        *fa;
482   {
483 +        char    cent[6];
484 +
485          if (fa->nfargs != 4)
486                  return(-1);
487          setmat(mod);
488 <        printf("o %s\n", id);
489 <        printf("v cent =\np %.12g %.12g %.12g\n",
490 <                        fa->farg[0], fa->farg[1], fa->farg[2]);
399 <        printf("sph cent %.12g\n", typ[0]=='b' ? -fa->farg[3] : fa->farg[3]);
400 <        puts("o");
488 >        setobj(id);
489 >        printf("sph %s %.12g\n", getvertid(cent, fa->farg),
490 >                        typ[0]=='b' ? -fa->farg[3] : fa->farg[3]);
491          return(0);
492   }
493  
# Line 407 | Line 497 | o_cylinder(mod, typ, id, fa)   /* print out a cylinder *
497   char    *mod, *typ, *id;
498   register FUNARGS        *fa;
499   {
500 +        char    v1[6], v2[6];
501 +
502          if (fa->nfargs != 7)
503                  return(-1);
504          setmat(mod);
505 <        printf("o %s\n", id);
506 <        printf("v cv1 =\np %.12g %.12g %.12g\n",
507 <                        fa->farg[0], fa->farg[1], fa->farg[2]);
508 <        printf("v cv2 =\np %.12g %.12g %.12g\n",
509 <                        fa->farg[3], fa->farg[4], fa->farg[5]);
418 <        printf("cyl cv1 %.12g cv2\n",
419 <                        typ[0]=='t' ? -fa->farg[6] : fa->farg[6]);
420 <        puts("o");
505 >        setobj(id);
506 >        getvertid(v1, fa->farg);
507 >        getvertid(v2, fa->farg + 3);
508 >        printf("cyl %s %.12g %s\n", v1,
509 >                        typ[0]=='t' ? -fa->farg[6] : fa->farg[6], v2);
510          return(0);
511   }
512  
# Line 430 | Line 519 | register FUNARGS       *fa;
519          if (fa->nfargs != 8)
520                  return(-1);
521          setmat(mod);
522 <        printf("o %s\n", id);
523 <        printf("v cent =\np %.12g %.12g %.12g\n",
522 >        setobj(id);
523 >        printf("v cent =\n\tp %.12g %.12g %.12g\n",
524                          fa->farg[0], fa->farg[1], fa->farg[2]);
525 <        printf("n %.12g %.12g %.12g\n",
525 >        printf("\tn %.12g %.12g %.12g\n",
526                          fa->farg[3], fa->farg[4], fa->farg[5]);
527          if (fa->farg[6] < fa->farg[7])
528                  printf("ring cent %.12g %.12g\n",
# Line 441 | Line 530 | register FUNARGS       *fa;
530          else
531                  printf("ring cent %.12g %.12g\n",
532                                  fa->farg[7], fa->farg[6]);
444        puts("o");
533          return(0);
534   }
535  
536  
537   int
538 < o_instance(mod, typ, id, fa)    /* convert an instance */
538 > o_instance(mod, typ, id, fa)    /* convert an instance (or mesh) */
539   char    *mod, *typ, *id;
540   FUNARGS *fa;
541   {
542 <        return(0);              /* this is too damned difficult! */
542 >        register int    i;
543 >        register char   *cp;
544 >        char    *start = NULL, *end = NULL;
545 >        /*
546 >         * We don't really know how to do this, so we just create
547 >         * a reference to an undefined MGF file and it's the user's
548 >         * responsibility to create this file and put the appropriate
549 >         * stuff into it.
550 >         */
551 >        if (fa->nsargs < 1)
552 >                return(-1);
553 >        setmat(mod);                    /* only works if surfaces are void */
554 >        setobj(id);
555 >        for (cp = fa->sarg[0]; *cp; cp++)       /* construct MGF file name */
556 >                if (*cp == '/')
557 >                        start = cp+1;
558 >                else if (*cp == '.')
559 >                        end = cp;
560 >        if (start == NULL)
561 >                start = fa->sarg[0];
562 >        if (end == NULL || start >= end)
563 >                end = cp;
564 >        fputs("i ", stdout);                    /* print include entity */
565 >        for (cp = start; cp < end; cp++)
566 >                putchar(*cp);
567 >        fputs(".mgf", stdout);                  /* add MGF suffix */
568 >        for (i = 1; i < fa->nsargs; i++) {      /* add transform */
569 >                putchar(' ');
570 >                fputs(fa->sarg[i], stdout);
571 >        }
572 >        putchar('\n');
573 >        clrverts();                     /* vertex id's no longer reliable */
574 >        return(0);
575   }
576  
577  
578   int
459 o_source(mod, typ, id, fa)      /* convert a source */
460 char    *mod, *typ, *id;
461 FUNARGS *fa;
462 {
463        return(0);              /* there is no MGF equivalent! */
464 }
465
466
467 int
579   o_illum(mod, typ, id, fa)       /* convert an illum material */
580   char    *mod, *typ, *id;
581   FUNARGS *fa;
# Line 475 | Line 586 | FUNARGS        *fa;
586          }
587                                          /* else create invisible material */
588          newmat(id, NULL);
589 <        puts("ts 1 0");
589 >        puts("\tts 1 0");
590          return(0);
591   }
592  
# Line 493 | Line 604 | register FUNARGS       *fa;
604          newmat(id, NULL);
605          rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
606          rgb_cie(cxyz, rrgb);
607 <        puts("c");                              /* put diffuse component */
607 >        puts("\tc");                            /* put diffuse component */
608          d = cxyz[0] + cxyz[1] + cxyz[2];
609          if (d > FTINY)
610 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
611 <        printf("rd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
612 <        puts("c");                              /* put specular component */
613 <        printf("rs %.4f %.4f\n", fa->farg[3],
614 <                        typ[7]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
615 <                                        fa->farg[4]);
610 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
611 >        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
612 >        if (fa->farg[3] > FTINY) {              /* put specular component */
613 >                puts("\tc");
614 >                printf("\trs %.4f %.4f\n", fa->farg[3],
615 >                                typ[7]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
616 >                                                fa->farg[4]);
617 >        }
618          return(0);
619   }
620  
# Line 519 | Line 632 | register FUNARGS       *fa;
632          newmat(id, NULL);
633          rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
634          rgb_cie(cxyz, rrgb);
635 <        puts("c");                              /* put diffuse component */
635 >        puts("\tc");                            /* put diffuse component */
636          d = cxyz[0] + cxyz[1] + cxyz[2];
637          if (d > FTINY)
638 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
639 <        printf("rd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
638 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
639 >        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
640                                                  /* put specular component */
641 <        printf("rs %.4f %.4f\n", cxyz[1]*fa->farg[3],
641 >        printf("\trs %.4f %.4f\n", cxyz[1]*fa->farg[3],
642                          typ[5]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
643                                          fa->farg[4]);
644          return(0);
# Line 546 | Line 659 | register FUNARGS       *fa;
659          newmat(id, NULL);
660          if (fa->nfargs == 4)
661                  nrfr = fa->farg[3];
662 +        printf("\tir %f 0\n", nrfr);
663          F = (1. - nrfr)/(1. + nrfr);            /* use normal incidence */
664          F *= F;
665          for (i = 0; i < 3; i++) {
666 <                rrgb[i] = (1. - F)*(1. - F)/(1. - F*F*fa->farg[i]*fa->farg[i]);
553 <                trgb[i] = F * (1. + (1. - 2.*F)*fa->farg[i]) /
666 >                trgb[i] = fa->farg[i] * (1. - F)*(1. - F) /
667                                  (1. - F*F*fa->farg[i]*fa->farg[i]);
668 +                rrgb[i] = F * (1. + (1. - 2.*F)*fa->farg[i]) /
669 +                                (1. - F*F*fa->farg[i]*fa->farg[i]);
670          }
671          rgb_cie(cxyz, rrgb);                    /* put reflected component */
672 <        puts("c");
672 >        puts("\tc");
673          d = cxyz[0] + cxyz[1] + cxyz[2];
674          if (d > FTINY)
675 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
676 <        printf("rs %.4f 0\n", cxyz[1]);
675 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
676 >        printf("\trs %.4f 0\n", cxyz[1]);
677          rgb_cie(cxyz, trgb);                    /* put transmitted component */
678 <        puts("c");
678 >        puts("\tc");
679          d = cxyz[0] + cxyz[1] + cxyz[2];
680          if (d > FTINY)
681 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
682 <        printf("ts %.4f 0\n", cxyz[1]);
681 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
682 >        printf("\tts %.4f 0\n", cxyz[1]);
683          return(0);
684   }
685  
686  
687   int
688 + o_dielectric(mod, typ, id, fa)  /* convert a dielectric material */
689 + char    *mod, *typ, *id;
690 + register FUNARGS        *fa;
691 + {
692 +        COLOR   cxyz, trgb;
693 +        double  F, d;
694 +        register int    i;
695 +
696 +        if (fa->nfargs != 5)
697 +                return(-1);
698 +        newmat(id, NULL);
699 +        F = (1. - fa->farg[3])/(1. + fa->farg[3]);      /* normal incidence */
700 +        F *= F;
701 +        for (i = 0; i < 3; i++)
702 +                trgb[i] = (1. - F)*pow(fa->farg[i], C_1SIDEDTHICK/unit_mult);
703 +        printf("\tir %f 0\n", fa->farg[3]);     /* put index of refraction */
704 +        printf("\tsides 1\n");
705 +        puts("\tc");                            /* put reflected component */
706 +        printf("\trs %.4f 0\n", F);
707 +        rgb_cie(cxyz, trgb);                    /* put transmitted component */
708 +        puts("\tc");
709 +        d = cxyz[0] + cxyz[1] + cxyz[2];
710 +        if (d > FTINY)
711 +                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
712 +        printf("\tts %.4f 0\n", cxyz[1]);
713 +        return(0);
714 + }
715 +
716 +
717 + int
718   o_mirror(mod, typ, id, fa)      /* convert a mirror material */
719   char    *mod, *typ, *id;
720   register FUNARGS        *fa;
# Line 586 | Line 731 | register FUNARGS       *fa;
731          newmat(id, NULL);
732          rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
733          rgb_cie(cxyz, rrgb);
734 <        puts("c");                              /* put specular component */
734 >        puts("\tc");                            /* put specular component */
735          d = cxyz[0] + cxyz[1] + cxyz[2];
736          if (d > FTINY)
737 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
738 <        printf("rs %.4f 0\n", cxyz[1]);
737 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
738 >        printf("\trs %.4f 0\n", cxyz[1]);
739          return(0);
740   }
741  
# Line 619 | Line 764 | register FUNARGS       *fa;
764          newmat(id, NULL);
765          rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
766          rgb_cie(cxyz, rrgb);
767 <        puts("c");                              /* put transmitted diffuse */
767 >        puts("\tc");                            /* put transmitted diffuse */
768          d = cxyz[0] + cxyz[1] + cxyz[2];
769          if (d > FTINY)
770 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
771 <        printf("td %.4f\n", cxyz[1]*trans*(1. - fa->farg[3])*(1. - tspec));
770 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
771 >        printf("\ttd %.4f\n", cxyz[1]*trans*(1. - fa->farg[3])*(1. - tspec));
772                                                  /* put transmitted specular */
773 <        printf("ts %.4f %.4f\n", cxyz[1]*trans*tspec*(1. - fa->farg[3]), rough);
773 >        printf("\tts %.4f %.4f\n", cxyz[1]*trans*tspec*(1. - fa->farg[3]), rough);
774                                                  /* put reflected diffuse */
775 <        printf("rd %.4f\n", cxyz[1]*(1. - fa->farg[3])*(1. - trans));
776 <        puts("c");                              /* put reflected specular */
777 <        printf("rs %.4f %.4f\n", fa->farg[3], rough);
775 >        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3])*(1. - trans));
776 >        puts("\tc");                            /* put reflected specular */
777 >        printf("\trs %.4f %.4f\n", fa->farg[3], rough);
778          return(0);
779   }
780  
# Line 648 | Line 793 | register FUNARGS       *fa;
793          rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
794          rgb_cie(cxyz, rrgb);
795          d = cxyz[0] + cxyz[1] + cxyz[2];
796 <        puts("c");
796 >        puts("\tc");
797          if (d > FTINY)
798 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
799 <        printf("ed %.4g\n", cxyz[1]);
798 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
799 >        printf("\ted %.4g\n", cxyz[1]*(PI*WHTEFFICACY));
800          return(0);
801   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines