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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines