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.26 by greg, Tue Oct 25 23:23:17 2011 UTC vs.
Revision 2.30 by greg, Tue Apr 22 14:51:29 2025 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 195 | Line 193 | rad2mgf(               /* convert a Radiance file to MGF */
193                          }
194                          break;
195                  }
196 <        printf("# End conversion from: %s\n", inp);
197 <        if (inp[0] == '!')
198 <                pclose(fp);
199 <        else
196 >        if (inp[0] == '!') {
197 >                if (pclose(fp) != 0)
198 >                        fprintf(stderr, "%s: warning - bad exit status\n", inp);
199 >        } else
200                  fclose(fp);
201 +        printf("# End conversion from: %s\n", inp);
202   }
203  
204  
# Line 690 | Line 689 | o_plastic(     /* convert a plastic material */
689          puts("\tc");                            /* put diffuse component */
690          d = cxyz[0] + cxyz[1] + cxyz[2];
691          if (d > FTINY)
692 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
693 <        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
692 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
693 >        printf("\trd %.6f\n", cxyz[1]*(1. - fa->farg[3]));
694          if (fa->farg[3] > FTINY) {              /* put specular component */
695                  puts("\tc");
696 <                printf("\trs %.4f %.4f\n", fa->farg[3],
696 >                printf("\trs %.6f %.6f\n", fa->farg[3],
697                                  typ[7]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
698                                                  fa->farg[4]);
699          }
# Line 721 | Line 720 | o_metal(       /* convert a metal material */
720          puts("\tc");                            /* put diffuse component */
721          d = cxyz[0] + cxyz[1] + cxyz[2];
722          if (d > FTINY)
723 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
724 <        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
723 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
724 >        printf("\trd %.6f\n", cxyz[1]*(1. - fa->farg[3]));
725                                                  /* put specular component */
726 <        printf("\trs %.4f %.4f\n", cxyz[1]*fa->farg[3],
726 >        printf("\trs %.6f %.6f\n", cxyz[1]*fa->farg[3],
727                          typ[5]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
728                                          fa->farg[4]);
729          return(0);
# Line 761 | Line 760 | o_glass(       /* convert a glass material */
760          puts("\tc");
761          d = cxyz[0] + cxyz[1] + cxyz[2];
762          if (d > FTINY)
763 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
764 <        printf("\trs %.4f 0\n", cxyz[1]);
763 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
764 >        printf("\trs %.6f 0\n", cxyz[1]);
765          rgb_cie(cxyz, trgb);                    /* put transmitted component */
766          puts("\tc");
767          d = cxyz[0] + cxyz[1] + cxyz[2];
768          if (d > FTINY)
769 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
770 <        printf("\tts %.4f 0\n", cxyz[1]);
769 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
770 >        printf("\tts %.6f 0\n", cxyz[1]);
771          return(0);
772   }
773  
# Line 795 | Line 794 | o_dielectric(  /* convert a dielectric material */
794          printf("\tir %f 0\n", fa->farg[3]);     /* put index of refraction */
795          printf("\tsides 1\n");
796          puts("\tc");                            /* put reflected component */
797 <        printf("\trs %.4f 0\n", F);
797 >        printf("\trs %.6f 0\n", F);
798          rgb_cie(cxyz, trgb);                    /* put transmitted component */
799          puts("\tc");
800          d = cxyz[0] + cxyz[1] + cxyz[2];
801          if (d > FTINY)
802 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
803 <        printf("\tts %.4f 0\n", cxyz[1]);
802 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
803 >        printf("\tts %.6f 0\n", cxyz[1]);
804          return(0);
805   }
806  
# Line 829 | Line 828 | o_mirror(      /* convert a mirror material */
828          puts("\tc");                            /* put specular component */
829          d = cxyz[0] + cxyz[1] + cxyz[2];
830          if (d > FTINY)
831 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
832 <        printf("\trs %.4f 0\n", cxyz[1]);
831 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
832 >        printf("\trs %.6f 0\n", cxyz[1]);
833          return(0);
834   }
835  
# Line 865 | Line 864 | o_trans(       /* convert a trans material */
864          puts("\tc");                            /* put transmitted diffuse */
865          d = cxyz[0] + cxyz[1] + cxyz[2];
866          if (d > FTINY)
867 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
868 <        printf("\ttd %.4f\n", cxyz[1]*trans*(1. - fa->farg[3])*(1. - tspec));
867 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
868 >        printf("\ttd %.6f\n", cxyz[1]*trans*(1. - fa->farg[3])*(1. - tspec));
869                                                  /* put transmitted specular */
870 <        printf("\tts %.4f %.4f\n", cxyz[1]*trans*tspec*(1. - fa->farg[3]), rough);
870 >        printf("\tts %.6f %.6f\n", cxyz[1]*trans*tspec*(1. - fa->farg[3]), rough);
871                                                  /* put reflected diffuse */
872 <        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3])*(1. - trans));
872 >        printf("\trd %.6f\n", cxyz[1]*(1. - fa->farg[3])*(1. - trans));
873          puts("\tc");                            /* put reflected specular */
874 <        printf("\trs %.4f %.4f\n", fa->farg[3], rough);
874 >        printf("\trs %.6f %.6f\n", fa->farg[3], rough);
875          return(0);
876   }
877  
# Line 896 | Line 895 | o_light(               /* convert a light type */
895          d = cxyz[0] + cxyz[1] + cxyz[2];
896          puts("\tc");
897          if (d > FTINY)
898 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
898 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
899          printf("\ted %.4g\n", cxyz[1]*(PI*WHTEFFICACY));
900          return(0);
901   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines