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