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.24 by greg, Wed Dec 28 18:35:42 2005 UTC vs.
Revision 2.28 by greg, Sat Dec 28 18:05:14 2019 UTC

# Line 6 | Line 6 | static const char      RCSid[] = "$Id$";
6   */
7  
8   #include <ctype.h>
9 #include <string.h>
10 #include <stdio.h>
9  
10   #include "platform.h"
11   #include "rtmath.h"
# Line 129 | Line 127 | rad2mgf(               /* convert a Radiance file to MGF */
127          char    *inp
128   )
129   {
130 +        char  buf[512];
131          char  mod[128], typ[32], id[128], alias[128];
132          FUNARGS fa;
133          register FILE   *fp;
# Line 689 | Line 688 | o_plastic(     /* convert a plastic material */
688          puts("\tc");                            /* put diffuse component */
689          d = cxyz[0] + cxyz[1] + cxyz[2];
690          if (d > FTINY)
691 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
692 <        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
691 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
692 >        printf("\trd %.6f\n", cxyz[1]*(1. - fa->farg[3]));
693          if (fa->farg[3] > FTINY) {              /* put specular component */
694                  puts("\tc");
695 <                printf("\trs %.4f %.4f\n", fa->farg[3],
695 >                printf("\trs %.6f %.6f\n", fa->farg[3],
696                                  typ[7]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
697                                                  fa->farg[4]);
698          }
# Line 720 | Line 719 | o_metal(       /* convert a metal material */
719          puts("\tc");                            /* put diffuse component */
720          d = cxyz[0] + cxyz[1] + cxyz[2];
721          if (d > FTINY)
722 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
723 <        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
722 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
723 >        printf("\trd %.6f\n", cxyz[1]*(1. - fa->farg[3]));
724                                                  /* put specular component */
725 <        printf("\trs %.4f %.4f\n", cxyz[1]*fa->farg[3],
725 >        printf("\trs %.6f %.6f\n", cxyz[1]*fa->farg[3],
726                          typ[5]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
727                                          fa->farg[4]);
728          return(0);
# Line 760 | Line 759 | o_glass(       /* convert a glass material */
759          puts("\tc");
760          d = cxyz[0] + cxyz[1] + cxyz[2];
761          if (d > FTINY)
762 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
763 <        printf("\trs %.4f 0\n", cxyz[1]);
762 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
763 >        printf("\trs %.6f 0\n", cxyz[1]);
764          rgb_cie(cxyz, trgb);                    /* put transmitted component */
765          puts("\tc");
766          d = cxyz[0] + cxyz[1] + cxyz[2];
767          if (d > FTINY)
768 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
769 <        printf("\tts %.4f 0\n", cxyz[1]);
768 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
769 >        printf("\tts %.6f 0\n", cxyz[1]);
770          return(0);
771   }
772  
# Line 794 | Line 793 | o_dielectric(  /* convert a dielectric material */
793          printf("\tir %f 0\n", fa->farg[3]);     /* put index of refraction */
794          printf("\tsides 1\n");
795          puts("\tc");                            /* put reflected component */
796 <        printf("\trs %.4f 0\n", F);
796 >        printf("\trs %.6f 0\n", F);
797          rgb_cie(cxyz, trgb);                    /* put transmitted component */
798          puts("\tc");
799          d = cxyz[0] + cxyz[1] + cxyz[2];
800          if (d > FTINY)
801 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
802 <        printf("\tts %.4f 0\n", cxyz[1]);
801 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
802 >        printf("\tts %.6f 0\n", cxyz[1]);
803          return(0);
804   }
805  
# Line 828 | Line 827 | o_mirror(      /* convert a mirror material */
827          puts("\tc");                            /* put specular component */
828          d = cxyz[0] + cxyz[1] + cxyz[2];
829          if (d > FTINY)
830 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
831 <        printf("\trs %.4f 0\n", cxyz[1]);
830 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
831 >        printf("\trs %.6f 0\n", cxyz[1]);
832          return(0);
833   }
834  
# Line 845 | Line 844 | o_trans(       /* convert a trans material */
844          COLOR   cxyz, rrgb;
845          double  rough, trans, tspec, d;
846  
847 <        if (typ[4] == '2') {            /* trans2 */
847 >        if (typ[5] == '2') {            /* trans2 */
848                  if (fa->nfargs != 8)
849                          return(-1);
850                  rough = .5*(fa->farg[4] + fa->farg[5]);
# Line 864 | Line 863 | o_trans(       /* convert a trans material */
863          puts("\tc");                            /* put transmitted diffuse */
864          d = cxyz[0] + cxyz[1] + cxyz[2];
865          if (d > FTINY)
866 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
867 <        printf("\ttd %.4f\n", cxyz[1]*trans*(1. - fa->farg[3])*(1. - tspec));
866 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
867 >        printf("\ttd %.6f\n", cxyz[1]*trans*(1. - fa->farg[3])*(1. - tspec));
868                                                  /* put transmitted specular */
869 <        printf("\tts %.4f %.4f\n", cxyz[1]*trans*tspec*(1. - fa->farg[3]), rough);
869 >        printf("\tts %.6f %.6f\n", cxyz[1]*trans*tspec*(1. - fa->farg[3]), rough);
870                                                  /* put reflected diffuse */
871 <        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3])*(1. - trans));
871 >        printf("\trd %.6f\n", cxyz[1]*(1. - fa->farg[3])*(1. - trans));
872          puts("\tc");                            /* put reflected specular */
873 <        printf("\trs %.4f %.4f\n", fa->farg[3], rough);
873 >        printf("\trs %.6f %.6f\n", fa->farg[3], rough);
874          return(0);
875   }
876  
# Line 895 | Line 894 | o_light(               /* convert a light type */
894          d = cxyz[0] + cxyz[1] + cxyz[2];
895          puts("\tc");
896          if (d > FTINY)
897 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
897 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
898          printf("\ted %.4g\n", cxyz[1]*(PI*WHTEFFICACY));
899          return(0);
900   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines