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.29 by greg, Tue Apr 22 04:45:25 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: bad exit status\n", inp);
199 >                        exit(1);
200 >                }
201 >        } else
202                  fclose(fp);
203 +        printf("# End conversion from: %s\n", inp);
204   }
205  
206  
# Line 690 | Line 691 | o_plastic(     /* convert a plastic material */
691          puts("\tc");                            /* put diffuse component */
692          d = cxyz[0] + cxyz[1] + cxyz[2];
693          if (d > FTINY)
694 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
695 <        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
694 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
695 >        printf("\trd %.6f\n", cxyz[1]*(1. - fa->farg[3]));
696          if (fa->farg[3] > FTINY) {              /* put specular component */
697                  puts("\tc");
698 <                printf("\trs %.4f %.4f\n", fa->farg[3],
698 >                printf("\trs %.6f %.6f\n", fa->farg[3],
699                                  typ[7]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
700                                                  fa->farg[4]);
701          }
# Line 721 | Line 722 | o_metal(       /* convert a metal material */
722          puts("\tc");                            /* put diffuse component */
723          d = cxyz[0] + cxyz[1] + cxyz[2];
724          if (d > FTINY)
725 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
726 <        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3]));
725 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
726 >        printf("\trd %.6f\n", cxyz[1]*(1. - fa->farg[3]));
727                                                  /* put specular component */
728 <        printf("\trs %.4f %.4f\n", cxyz[1]*fa->farg[3],
728 >        printf("\trs %.6f %.6f\n", cxyz[1]*fa->farg[3],
729                          typ[5]=='2' ? .5*(fa->farg[4] + fa->farg[5]) :
730                                          fa->farg[4]);
731          return(0);
# Line 761 | Line 762 | o_glass(       /* convert a glass material */
762          puts("\tc");
763          d = cxyz[0] + cxyz[1] + cxyz[2];
764          if (d > FTINY)
765 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
766 <        printf("\trs %.4f 0\n", cxyz[1]);
765 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
766 >        printf("\trs %.6f 0\n", cxyz[1]);
767          rgb_cie(cxyz, trgb);                    /* put transmitted component */
768          puts("\tc");
769          d = cxyz[0] + cxyz[1] + cxyz[2];
770          if (d > FTINY)
771 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
772 <        printf("\tts %.4f 0\n", cxyz[1]);
771 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
772 >        printf("\tts %.6f 0\n", cxyz[1]);
773          return(0);
774   }
775  
# Line 795 | Line 796 | o_dielectric(  /* convert a dielectric material */
796          printf("\tir %f 0\n", fa->farg[3]);     /* put index of refraction */
797          printf("\tsides 1\n");
798          puts("\tc");                            /* put reflected component */
799 <        printf("\trs %.4f 0\n", F);
799 >        printf("\trs %.6f 0\n", F);
800          rgb_cie(cxyz, trgb);                    /* put transmitted component */
801          puts("\tc");
802          d = cxyz[0] + cxyz[1] + cxyz[2];
803          if (d > FTINY)
804 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
805 <        printf("\tts %.4f 0\n", cxyz[1]);
804 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
805 >        printf("\tts %.6f 0\n", cxyz[1]);
806          return(0);
807   }
808  
# Line 829 | Line 830 | o_mirror(      /* convert a mirror material */
830          puts("\tc");                            /* put specular component */
831          d = cxyz[0] + cxyz[1] + cxyz[2];
832          if (d > FTINY)
833 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
834 <        printf("\trs %.4f 0\n", cxyz[1]);
833 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
834 >        printf("\trs %.6f 0\n", cxyz[1]);
835          return(0);
836   }
837  
# Line 865 | Line 866 | o_trans(       /* convert a trans material */
866          puts("\tc");                            /* put transmitted diffuse */
867          d = cxyz[0] + cxyz[1] + cxyz[2];
868          if (d > FTINY)
869 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
870 <        printf("\ttd %.4f\n", cxyz[1]*trans*(1. - fa->farg[3])*(1. - tspec));
869 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
870 >        printf("\ttd %.6f\n", cxyz[1]*trans*(1. - fa->farg[3])*(1. - tspec));
871                                                  /* put transmitted specular */
872 <        printf("\tts %.4f %.4f\n", cxyz[1]*trans*tspec*(1. - fa->farg[3]), rough);
872 >        printf("\tts %.6f %.6f\n", cxyz[1]*trans*tspec*(1. - fa->farg[3]), rough);
873                                                  /* put reflected diffuse */
874 <        printf("\trd %.4f\n", cxyz[1]*(1. - fa->farg[3])*(1. - trans));
874 >        printf("\trd %.6f\n", cxyz[1]*(1. - fa->farg[3])*(1. - trans));
875          puts("\tc");                            /* put reflected specular */
876 <        printf("\trs %.4f %.4f\n", fa->farg[3], rough);
876 >        printf("\trs %.6f %.6f\n", fa->farg[3], rough);
877          return(0);
878   }
879  
# Line 896 | Line 897 | o_light(               /* convert a light type */
897          d = cxyz[0] + cxyz[1] + cxyz[2];
898          puts("\tc");
899          if (d > FTINY)
900 <                printf("\t\tcxy %.4f %.4f\n", cxyz[0]/d, cxyz[1]/d);
900 >                printf("\t\tcxy %.6f %.6f\n", cxyz[0]/d, cxyz[1]/d);
901          printf("\ted %.4g\n", cxyz[1]*(PI*WHTEFFICACY));
902          return(0);
903   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines