6 |
|
*/ |
7 |
|
|
8 |
|
#include <ctype.h> |
9 |
– |
#include <string.h> |
10 |
– |
#include <stdio.h> |
9 |
|
|
10 |
|
#include "platform.h" |
11 |
|
#include "rtmath.h" |
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 |
|
|
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 |
|
} |
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); |
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
} |