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.11 by greg, Thu Apr 13 15:33:48 1995 UTC

# Line 9 | Line 9 | static char SCCSid[] = "$SunId$ LBL";
9   */
10  
11   #include <stdio.h>
12 + #include <math.h>
13   #include <string.h>
14   #include "fvect.h"
15   #include "object.h"
16   #include "color.h"
17   #include "lookup.h"
18  
19 + #define PI      3.14159265358979323846
20 +
21 + #define C_1SIDEDTHICK   0.005
22 +
23   int     o_face(), o_cone(), o_sphere(), o_ring(), o_cylinder();
24 < int     o_instance(), o_source(), o_illum();
25 < int     o_plastic(), o_metal(), o_glass(), o_mirror(), o_trans(), o_light();
24 > int     o_instance(), o_illum();
25 > int     o_plastic(), o_metal(), o_glass(), o_dielectric(),
26 >        o_mirror(), o_trans(), o_light();
27  
28   extern void     free();
29   extern char     *malloc();
# Line 26 | Line 32 | LUTAB  rmats = LU_SINIT(free,NULL);            /* defined materia
32  
33   LUTAB   rdispatch = LU_SINIT(NULL,NULL);        /* function dispatch table */
34  
35 < char    curmat[80];             /* current material */
35 > char    curmat[80];                             /* current material */
36 > char    curobj[128] = "Untitled";               /* current object name */
37  
38 < double  unit_mult = 1.;         /* units multiplier */
38 > double  unit_mult = 1.;                         /* units multiplier */
39  
40 + #define hasmult         (unit_mult < .999 || unit_mult > 1.001)
41  
42 + /*
43 + * Stuff for tracking and reusing vertices:
44 + */
45 +
46 + char    VKFMT[] = "%+16.9e %+16.9e %+16.9e";
47 + #define VKLEN           64
48 +
49 + #define mkvkey(k,v)     sprintf(k, VKFMT, (v)[0], (v)[1], (v)[2])
50 +
51 + #define NVERTS          256
52 +
53 + long    vclock;         /* incremented at each vertex request */
54 +
55 + struct vert {
56 +        long    lused;          /* when last used (0 if unassigned) */
57 +        FVECT   p;              /* track point position only */
58 + } vert[NVERTS];         /* our vertex cache */
59 +
60 + LUTAB   vertab = LU_SINIT(free,NULL);   /* our vertex lookup table */
61 +
62 +
63   main(argc, argv)
64   int     argc;
65   char    **argv;
# Line 57 | Line 86 | char   **argv;
86                                  goto unkopt;
87                          }
88                          break;
89 +                default:
90 +                        goto unkopt;
91                  }
92          init();
93          if (i >= argc)
# Line 85 | Line 116 | char   *inp;
116          register int    c;
117  
118          if (inp == NULL) {
119 <                inp = "the standard input";
119 >                inp = "standard input";
120                  fp = stdin;
121          } else if (inp[0] == '!') {
122                  if ((fp = popen(inp+1, "r")) == NULL) {
# Line 163 | Line 194 | FUNARGS        *fa;
194                          fprintf(stderr, "%s: bad %s \"%s\"\n", typ, id);
195                          exit(1);
196                  }
197 <        } else if (lu_find(&rmats, mod)->data != NULL)  /* make alias */
198 <                newmat(id, mod);
197 >        } else {                                        /* unsupported */
198 >                o_unsupported(mod, typ, id, fa);
199 >                if (lu_find(&rmats, mod)->data != NULL) /* make alias */
200 >                        newmat(id, mod);
201 >        }
202   }
203  
204  
# Line 209 | Line 243 | char   *id;
243   {
244          if (!strcmp(id, curmat))        /* already set? */
245                  return;
246 +        if (!strcmp(id, VOIDID))        /* cannot set */
247 +                return;
248          printf("m %s\n", id);
249          strcpy(curmat, id);
250   }
251  
252  
253 + setobj(id)                      /* set object name to this one */
254 + char    *id;
255 + {
256 +        register char   *cp, *cp2;
257 +        char    *end = NULL;
258 +        int     diff = 0;
259 +                                /* use all but final suffix */
260 +        for (cp = id; *cp; cp++)
261 +                if (*cp == '.')
262 +                        end = cp;
263 +        if (end == NULL)
264 +                end = cp;
265 +                                /* copy to current object */
266 +        for (cp = id, cp2 = curobj; cp < end; *cp2++ = *cp++)
267 +                diff += *cp != *cp2;
268 +        if (!diff && !*cp2)
269 +                return;
270 +        *cp2 = '\0';
271 +        fputs("o\no ", stdout);
272 +        puts(curobj);
273 + }
274 +
275 +
276   init()                  /* initialize dispatch table and output */
277   {
278 +        lu_init(&vertab, NVERTS);
279          lu_init(&rdispatch, 22);
280          add2dispatch("polygon", o_face);
281          add2dispatch("cone", o_cone);
# Line 231 | Line 291 | init()                 /* initialize dispatch table and output */
291          add2dispatch("metal", o_metal);
292          add2dispatch("metal2", o_metal);
293          add2dispatch("glass", o_glass);
294 +        add2dispatch("dielectric", o_dielectric);
295          add2dispatch("trans", o_trans);
296          add2dispatch("trans2", o_trans);
297          add2dispatch("mirror", o_mirror);
# Line 238 | Line 299 | init()                 /* initialize dispatch table and output */
299          add2dispatch("spotlight", o_light);
300          add2dispatch("glow", o_light);
301          add2dispatch("illum", o_illum);
302 <        puts("# The following was converted from Radiance scene input");
303 <        if (unit_mult < .999 || unit_mult > 1.001)
302 >        puts("# The following was converted from RADIANCE scene input");
303 >        if (hasmult)
304                  printf("xf -s %.4e\n", unit_mult);
305 +        printf("o %s\n", curobj);
306   }
307  
308  
309   uninit()                        /* mark end of MGF file */
310   {
311 <        if (unit_mult < .999 || unit_mult > 1.001)
311 >        puts("o");
312 >        if (hasmult)
313                  puts("xf");
314 <        puts("# End of data converted from Radiance scene input");
314 >        puts("# End of data converted from RADIANCE scene input");
315          lu_done(&rdispatch);
316          lu_done(&rmats);
317 +        lu_done(&vertab);
318   }
319  
320  
321 + clrverts()                      /* clear vertex table */
322 + {
323 +        register int    i;
324 +
325 +        lu_done(&vertab);
326 +        for (i = 0; i < NVERTS; i++)
327 +                vert[i].lused = 0;
328 +        lu_init(&vertab, NVERTS);
329 + }
330 +
331 +
332   add2dispatch(name, func)        /* add function to dispatch table */
333   char    *name;
334   int     (*func)();
# Line 271 | Line 346 | int    (*func)();
346   }
347  
348  
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
349   char *
350 < getvertid(vp)                   /* get/set vertex ID for this point */
350 > getvertid(vname, vp)            /* get/set vertex ID for this point */
351 > char    *vname;
352   FVECT   vp;
353   {
354 <        static char     vname[6];
296 <        char    vkey[VKLEN];
354 >        static char     vkey[VKLEN];
355          register LUENT  *lp;
356          register int    i, vndx;
357  
358 <        if (!vertab.tsiz && !lu_init(&vertab, NVERTS))
301 <                goto memerr;
302 <        clock++;                        /* increment counter */
358 >        vclock++;                       /* increment counter */
359          mkvkey(vkey, vp);
360          if ((lp = lu_find(&vertab, vkey)) == NULL)
361                  goto memerr;
# Line 319 | Line 375 | FVECT  vp;
375                          mkvkey(vkey, vert[vndx].p);
376                          lu_delete(&vertab, vkey);
377                  }
378 <                vert[vndx].lused = clock;                       /* assign it */
379 <                VCOPY(vert[vndx].p, vp);
324 <                printf("v v%d =\np %.15g %.15g %.15g\n",        /* print it */
378 >                VCOPY(vert[vndx].p, vp);                        /* assign it */
379 >                printf("v v%d =\n\tp %.15g %.15g %.15g\n",      /* print it */
380                                  vndx, vp[0], vp[1], vp[2]);
381                  lp->data = (char *)&vert[vndx];                 /* set it */
382          } else
383                  vndx = (struct vert *)lp->data - vert;
384 +        vert[vndx].lused = vclock;              /* record this use */
385          sprintf(vname, "v%d", vndx);
386          return(vname);
387   memerr:
# Line 335 | Line 391 | memerr:
391  
392  
393   int
394 + o_unsupported(mod, typ, id, fa)         /* mark unsupported primitive */
395 + char    *mod, *typ, *id;
396 + FUNARGS *fa;
397 + {
398 +        register int    i;
399 +
400 +        fputs("\n# Unsupported RADIANCE primitive:\n", stdout);
401 +        printf("# %s %s %s", mod, typ, id);
402 +        printf("\n# %d", fa->nsargs);
403 +        for (i = 0; i < fa->nsargs; i++)
404 +                printf(" %s", fa->sarg[i]);
405 + #ifdef IARGS
406 +        printf("\n# %d", fa->niargs);
407 +        for (i = 0; i < fa->niargs; i++)
408 +                printf(" %ld", fa->iarg[i]);
409 + #else
410 +        fputs("\n# 0", stdout);
411 + #endif
412 +        printf("\n# %d", fa->nfargs);
413 +        for (i = 0; i < fa->nfargs; i++)
414 +                printf(" %g", fa->farg[i]);
415 +        fputs("\n\n", stdout);
416 +        return(0);
417 + }
418 +
419 +
420 + int
421   o_face(mod, typ, id, fa)                /* print out a polygon */
422   char    *mod, *typ, *id;
423   FUNARGS *fa;
424   {
425          char    entbuf[512];
426 <        register char   *cp1, *cp2;
426 >        register char   *cp;
427          register int    i;
428  
429          if (fa->nfargs < 9 | fa->nfargs % 3)
430                  return(-1);
431          setmat(mod);
432 <        printf("o %s\n", id);
433 <        cp1 = entbuf;
434 <        *cp1++ = 'f';
432 >        setobj(id);
433 >        cp = entbuf;
434 >        *cp++ = 'f';
435          for (i = 0; i < fa->nfargs; i += 3) {
436 <                cp2 = getvertid(fa->farg + i);
437 <                *cp1++ = ' ';
438 <                while ((*cp1 = *cp2++))
439 <                        cp1++;
436 >                *cp++ = ' ';
437 >                getvertid(cp, fa->farg + i);
438 >                while (*cp)
439 >                        cp++;
440          }
441          puts(entbuf);
359        puts("o");
442          return(0);
443   }
444  
# Line 366 | Line 448 | o_cone(mod, typ, id, fa)       /* print out a cone */
448   char    *mod, *typ, *id;
449   register FUNARGS        *fa;
450   {
451 +        char    v1[6], v2[6];
452 +
453          if (fa->nfargs != 8)
454                  return(-1);
455          setmat(mod);
456 <        printf("o %s\n", id);
457 <        printf("v cv1 =\np %.12g %.12g %.12g\n",
458 <                        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]);
456 >        setobj(id);
457 >        getvertid(v1, fa->farg);
458 >        getvertid(v2, fa->farg + 3);
459          if (typ[1] == 'u')                      /* cup -> inverted cone */
460 <                printf("cone cv1 %.12g cv2 %.12g\n",
461 <                                -fa->farg[6], -fa->farg[7]);
460 >                printf("cone %s %.12g %s %.12g\n",
461 >                                v1, -fa->farg[6], v2, -fa->farg[7]);
462          else
463 <                printf("cone cv1 %.12g cv2 %.12g\n",
464 <                                fa->farg[6], fa->farg[7]);
383 <        puts("o");
463 >                printf("cone %s %.12g %s %.12g\n",
464 >                                v1, fa->farg[6], v2, fa->farg[7]);
465          return(0);
466   }
467  
# Line 390 | Line 471 | o_sphere(mod, typ, id, fa)     /* print out a sphere */
471   char    *mod, *typ, *id;
472   register FUNARGS        *fa;
473   {
474 +        char    cent[6];
475 +
476          if (fa->nfargs != 4)
477                  return(-1);
478          setmat(mod);
479 <        printf("o %s\n", id);
480 <        printf("v cent =\np %.12g %.12g %.12g\n",
481 <                        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");
479 >        setobj(id);
480 >        printf("sph %s %.12g\n", getvertid(cent, fa->farg),
481 >                        typ[0]=='b' ? -fa->farg[3] : fa->farg[3]);
482          return(0);
483   }
484  
# Line 407 | Line 488 | o_cylinder(mod, typ, id, fa)   /* print out a cylinder *
488   char    *mod, *typ, *id;
489   register FUNARGS        *fa;
490   {
491 +        char    v1[6], v2[6];
492 +
493          if (fa->nfargs != 7)
494                  return(-1);
495          setmat(mod);
496 <        printf("o %s\n", id);
497 <        printf("v cv1 =\np %.12g %.12g %.12g\n",
498 <                        fa->farg[0], fa->farg[1], fa->farg[2]);
499 <        printf("v cv2 =\np %.12g %.12g %.12g\n",
500 <                        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");
496 >        setobj(id);
497 >        getvertid(v1, fa->farg);
498 >        getvertid(v2, fa->farg + 3);
499 >        printf("cyl %s %.12g %s\n", v1,
500 >                        typ[0]=='t' ? -fa->farg[6] : fa->farg[6], v2);
501          return(0);
502   }
503  
# Line 430 | Line 510 | register FUNARGS       *fa;
510          if (fa->nfargs != 8)
511                  return(-1);
512          setmat(mod);
513 <        printf("o %s\n", id);
514 <        printf("v cent =\np %.12g %.12g %.12g\n",
513 >        setobj(id);
514 >        printf("v cent =\n\tp %.12g %.12g %.12g\n",
515                          fa->farg[0], fa->farg[1], fa->farg[2]);
516 <        printf("n %.12g %.12g %.12g\n",
516 >        printf("\tn %.12g %.12g %.12g\n",
517                          fa->farg[3], fa->farg[4], fa->farg[5]);
518          if (fa->farg[6] < fa->farg[7])
519                  printf("ring cent %.12g %.12g\n",
# Line 441 | Line 521 | register FUNARGS       *fa;
521          else
522                  printf("ring cent %.12g %.12g\n",
523                                  fa->farg[7], fa->farg[6]);
444        puts("o");
524          return(0);
525   }
526  
# Line 451 | Line 530 | o_instance(mod, typ, id, fa)   /* convert an instance */
530   char    *mod, *typ, *id;
531   FUNARGS *fa;
532   {
533 <        return(0);              /* this is too damned difficult! */
533 >        register int    i;
534 >        register char   *cp;
535 >        char    *start = NULL, *end = NULL;
536 >        /*
537 >         * We don't really know how to do this, so we just create
538 >         * a reference to an undefined MGF file and it's the user's
539 >         * responsibility to create this file and put the appropriate
540 >         * stuff into it.
541 >         */
542 >        if (fa->nsargs < 1)
543 >                return(-1);
544 >        setmat(mod);                    /* only works if surfaces are void */
545 >        setobj(id);
546 >        for (cp = fa->sarg[0]; *cp; cp++)       /* construct MGF file name */
547 >                if (*cp == '/')
548 >                        start = cp+1;
549 >                else if (*cp == '.')
550 >                        end = cp;
551 >        if (start == NULL)
552 >                start = fa->sarg[0];
553 >        if (end == NULL || start >= end)
554 >                end = cp;
555 >        fputs("i ", stdout);                    /* print include entity */
556 >        for (cp = start; cp < end; cp++)
557 >                putchar(*cp);
558 >        fputs(".mgf", stdout);                  /* add MGF suffix */
559 >        for (i = 1; i < fa->nsargs; i++) {      /* add transform */
560 >                putchar(' ');
561 >                fputs(fa->sarg[i], stdout);
562 >        }
563 >        putchar('\n');
564 >        clrverts();                     /* vertex id's no longer reliable */
565 >        return(0);
566   }
567  
568  
569   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
570   o_illum(mod, typ, id, fa)       /* convert an illum material */
571   char    *mod, *typ, *id;
572   FUNARGS *fa;
# Line 475 | Line 577 | FUNARGS        *fa;
577          }
578                                          /* else create invisible material */
579          newmat(id, NULL);
580 <        puts("ts 1 0");
580 >        puts("\tts 1 0");
581          return(0);
582   }
583  
# Line 493 | Line 595 | register FUNARGS       *fa;
595          newmat(id, NULL);
596          rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
597          rgb_cie(cxyz, rrgb);
598 <        puts("c");                              /* put diffuse component */
598 >        puts("\tc");                            /* put diffuse component */
599          d = cxyz[0] + cxyz[1] + cxyz[2];
600          if (d > FTINY)
601 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
602 <        printf("rd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
603 <        puts("c");                              /* put specular component */
604 <        printf("rs %.4f %.4f\n", fa->farg[3],
605 <                        typ[7]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
606 <                                        fa->farg[4]);
601 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
602 >        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
603 >        if (fa->farg[3] > FTINY) {              /* put specular component */
604 >                puts("\tc");
605 >                printf("\trs %.4f %.4f\n", fa->farg[3],
606 >                                typ[7]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
607 >                                                fa->farg[4]);
608 >        }
609          return(0);
610   }
611  
# Line 519 | Line 623 | register FUNARGS       *fa;
623          newmat(id, NULL);
624          rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
625          rgb_cie(cxyz, rrgb);
626 <        puts("c");                              /* put diffuse component */
626 >        puts("\tc");                            /* put diffuse component */
627          d = cxyz[0] + cxyz[1] + cxyz[2];
628          if (d > FTINY)
629 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
630 <        printf("rd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
629 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
630 >        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
631                                                  /* put specular component */
632 <        printf("rs %.4f %.4f\n", cxyz[1]*fa->farg[3],
632 >        printf("\trs %.4f %.4f\n", cxyz[1]*fa->farg[3],
633                          typ[5]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
634                                          fa->farg[4]);
635          return(0);
# Line 546 | Line 650 | register FUNARGS       *fa;
650          newmat(id, NULL);
651          if (fa->nfargs == 4)
652                  nrfr = fa->farg[3];
653 +        printf("\tir %f 0\n", nrfr);
654          F = (1. - nrfr)/(1. + nrfr);            /* use normal incidence */
655          F *= F;
656          for (i = 0; i < 3; i++) {
657 <                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]) /
657 >                trgb[i] = fa->farg[i] * (1. - F)*(1. - F) /
658                                  (1. - F*F*fa->farg[i]*fa->farg[i]);
659 +                rrgb[i] = F * (1. + (1. - 2.*F)*fa->farg[i]) /
660 +                                (1. - F*F*fa->farg[i]*fa->farg[i]);
661          }
662          rgb_cie(cxyz, rrgb);                    /* put reflected component */
663 <        puts("c");
663 >        puts("\tc");
664          d = cxyz[0] + cxyz[1] + cxyz[2];
665          if (d > FTINY)
666 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
667 <        printf("rs %.4f 0\n", cxyz[1]);
666 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
667 >        printf("\trs %.4f 0\n", cxyz[1]);
668          rgb_cie(cxyz, trgb);                    /* put transmitted component */
669 <        puts("c");
669 >        puts("\tc");
670          d = cxyz[0] + cxyz[1] + cxyz[2];
671          if (d > FTINY)
672 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
673 <        printf("ts %.4f 0\n", cxyz[1]);
672 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
673 >        printf("\tts %.4f 0\n", cxyz[1]);
674          return(0);
675   }
676  
677  
678   int
679 + o_dielectric(mod, typ, id, fa)  /* convert a dielectric material */
680 + char    *mod, *typ, *id;
681 + register FUNARGS        *fa;
682 + {
683 +        COLOR   cxyz, trgb;
684 +        double  F, d;
685 +        register int    i;
686 +
687 +        if (fa->nfargs != 5)
688 +                return(-1);
689 +        newmat(id, NULL);
690 +        F = (1. - fa->farg[3])/(1. + fa->farg[3]);      /* normal incidence */
691 +        F *= F;
692 +        for (i = 0; i < 3; i++)
693 +                trgb[i] = (1. - F)*pow(fa->farg[i], C_1SIDEDTHICK/unit_mult);
694 +        printf("\tir %f 0\n", fa->farg[3]);     /* put index of refraction */
695 +        printf("\tsides 1\n");
696 +        puts("\tc");                            /* put reflected component */
697 +        printf("\trs %.4f 0\n", F);
698 +        rgb_cie(cxyz, trgb);                    /* put transmitted component */
699 +        puts("\tc");
700 +        d = cxyz[0] + cxyz[1] + cxyz[2];
701 +        if (d > FTINY)
702 +                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
703 +        printf("\tts %.4f 0\n", cxyz[1]);
704 +        return(0);
705 + }
706 +
707 +
708 + int
709   o_mirror(mod, typ, id, fa)      /* convert a mirror material */
710   char    *mod, *typ, *id;
711   register FUNARGS        *fa;
# Line 586 | Line 722 | register FUNARGS       *fa;
722          newmat(id, NULL);
723          rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
724          rgb_cie(cxyz, rrgb);
725 <        puts("c");                              /* put specular component */
725 >        puts("\tc");                            /* put specular component */
726          d = cxyz[0] + cxyz[1] + cxyz[2];
727          if (d > FTINY)
728 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
729 <        printf("rs %.4f 0\n", cxyz[1]);
728 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
729 >        printf("\trs %.4f 0\n", cxyz[1]);
730          return(0);
731   }
732  
# Line 619 | Line 755 | register FUNARGS       *fa;
755          newmat(id, NULL);
756          rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
757          rgb_cie(cxyz, rrgb);
758 <        puts("c");                              /* put transmitted diffuse */
758 >        puts("\tc");                            /* put transmitted diffuse */
759          d = cxyz[0] + cxyz[1] + cxyz[2];
760          if (d > FTINY)
761 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
762 <        printf("td %.4f\n", cxyz[1]*trans*(1. - fa->farg[3])*(1. - tspec));
761 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
762 >        printf("\ttd %.4f\n", cxyz[1]*trans*(1. - fa->farg[3])*(1. - tspec));
763                                                  /* put transmitted specular */
764 <        printf("ts %.4f %.4f\n", cxyz[1]*trans*tspec*(1. - fa->farg[3]), rough);
764 >        printf("\tts %.4f %.4f\n", cxyz[1]*trans*tspec*(1. - fa->farg[3]), rough);
765                                                  /* put reflected diffuse */
766 <        printf("rd %.4f\n", cxyz[1]*(1. - fa->farg[3])*(1. - trans));
767 <        puts("c");                              /* put reflected specular */
768 <        printf("rs %.4f %.4f\n", fa->farg[3], rough);
766 >        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3])*(1. - trans));
767 >        puts("\tc");                            /* put reflected specular */
768 >        printf("\trs %.4f %.4f\n", fa->farg[3], rough);
769          return(0);
770   }
771  
# Line 648 | Line 784 | register FUNARGS       *fa;
784          rrgb[0] = fa->farg[0]; rrgb[1] = fa->farg[1]; rrgb[2] = fa->farg[2];
785          rgb_cie(cxyz, rrgb);
786          d = cxyz[0] + cxyz[1] + cxyz[2];
787 <        puts("c");
787 >        puts("\tc");
788          if (d > FTINY)
789 <                printf("cxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
790 <        printf("ed %.4g\n", cxyz[1]);
789 >                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
790 >        printf("\ted %.4g\n", cxyz[1]*(PI*WHTEFFICACY));
791          return(0);
792   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines