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.6 by greg, Fri Sep 2 16:21:00 1994 UTC vs.
Revision 2.10 by greg, Thu Apr 13 14:43:30 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();
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 37 | Line 43 | double unit_mult = 1.;                         /* units multiplier */
43   * Stuff for tracking and reusing vertices:
44   */
45  
46 < char    VKFMT[] = "%+1.9e %+1.9e %+1.9e";
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    clock;          /* incremented at each vertex request */
53 > long    vclock;         /* incremented at each vertex request */
54  
55   struct vert {
56          long    lused;          /* when last used (0 if unassigned) */
# Line 282 | Line 288 | init()                 /* initialize dispatch table and output */
288          add2dispatch("metal", o_metal);
289          add2dispatch("metal2", o_metal);
290          add2dispatch("glass", o_glass);
291 +        add2dispatch("dielectric", o_dielectric);
292          add2dispatch("trans", o_trans);
293          add2dispatch("trans2", o_trans);
294          add2dispatch("mirror", o_mirror);
# Line 341 | Line 348 | getvertid(vname, vp)           /* get/set vertex ID for this po
348   char    *vname;
349   FVECT   vp;
350   {
351 <        char    vkey[VKLEN];
351 >        static char     vkey[VKLEN];
352          register LUENT  *lp;
353          register int    i, vndx;
354  
355 <        clock++;                        /* increment counter */
355 >        vclock++;                       /* increment counter */
356          mkvkey(vkey, vp);
357          if ((lp = lu_find(&vertab, vkey)) == NULL)
358                  goto memerr;
# Line 371 | Line 378 | FVECT  vp;
378                  lp->data = (char *)&vert[vndx];                 /* set it */
379          } else
380                  vndx = (struct vert *)lp->data - vert;
381 <        vert[vndx].lused = clock;               /* record this use */
381 >        vert[vndx].lused = vclock;              /* record this use */
382          sprintf(vname, "v%d", vndx);
383          return(vname);
384   memerr:
# Line 622 | Line 629 | register FUNARGS       *fa;
629          newmat(id, NULL);
630          if (fa->nfargs == 4)
631                  nrfr = fa->farg[3];
632 +        printf("\tir %f 0\n", nrfr);
633          F = (1. - nrfr)/(1. + nrfr);            /* use normal incidence */
634          F *= F;
635          for (i = 0; i < 3; i++) {
# Line 647 | Line 655 | register FUNARGS       *fa;
655  
656  
657   int
658 + o_dielectric(mod, typ, id, fa)  /* convert a dielectric material */
659 + char    *mod, *typ, *id;
660 + register FUNARGS        *fa;
661 + {
662 +        COLOR   cxyz, trgb;
663 +        double  F, d;
664 +        register int    i;
665 +
666 +        if (fa->nfargs != 5)
667 +                return(-1);
668 +        newmat(id, NULL);
669 +        F = (1. - fa->farg[3])/(1. + fa->farg[3]);      /* normal incidence */
670 +        F *= F;
671 +        for (i = 0; i < 3; i++)
672 +                trgb[i] = (1. - F)*pow(fa->farg[i], C_1SIDEDTHICK/unit_mult);
673 +        printf("\tir %f 0\n", fa->farg[3]);     /* put index of refraction */
674 +        printf("\tsides 1\n");
675 +        puts("\tc");                            /* put reflected component */
676 +        printf("\trs %.4f 0\n", F);
677 +        rgb_cie(cxyz, trgb);                    /* put transmitted component */
678 +        puts("\tc");
679 +        d = cxyz[0] + cxyz[1] + cxyz[2];
680 +        if (d > FTINY)
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_mirror(mod, typ, id, fa)      /* convert a mirror material */
689   char    *mod, *typ, *id;
690   register FUNARGS        *fa;
# Line 728 | Line 766 | register FUNARGS       *fa;
766          puts("\tc");
767          if (d > FTINY)
768                  printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
769 <        printf("\ted %.4g\n", cxyz[1]*WHTEFFICACY);
769 >        printf("\ted %.4g\n", cxyz[1]*(PI*WHTEFFICACY));
770          return(0);
771   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines