26 |
|
|
27 |
|
FILE *matfp; /* material output file */ |
28 |
|
|
29 |
+ |
int dospectra = 0; /* output spectral colors? */ |
30 |
|
|
31 |
+ |
|
32 |
|
extern int r_comment(int ac, char **av); |
33 |
|
extern int r_color(int ac, char **av); |
34 |
|
extern int r_cone(int ac, char **av); |
109 |
|
} |
110 |
|
printf(" %s", argv[i]); |
111 |
|
break; |
112 |
+ |
case 's': /* spectral color output? */ |
113 |
+ |
dospectra = !dospectra; |
114 |
+ |
break; |
115 |
|
default: |
116 |
|
goto userr; |
117 |
|
} |
137 |
|
} |
138 |
|
exit(0); |
139 |
|
userr: |
140 |
< |
fprintf(stderr, "Usage: %s [-g dist][-e mult][-m matf] [file.mgf] ..\n", |
140 |
> |
fprintf(stderr, "Usage: %s [-s][-g dist][-e mult][-m matf] [file.mgf] ..\n", |
141 |
|
argv[0]); |
142 |
|
exit(1); |
143 |
|
} |
691 |
|
{ |
692 |
|
static char spname[128]; |
693 |
|
double mult; |
694 |
< |
int i; |
694 |
> |
int cbeg, cend, i; |
695 |
|
|
696 |
< |
if (!(clr->flags & C_CDSPEC)) { /* not defined spectrally? */ |
696 |
> |
if (!dospectra | !(clr->flags & C_CDSPEC)) { |
697 |
|
cvtcolor(radrgb, clr, intensity); |
698 |
< |
return("void"); |
698 |
> |
return("void"); /* just use RGB */ |
699 |
|
} |
700 |
|
setcolor(radrgb, intensity, intensity, intensity); |
701 |
+ |
for (cbeg = 0; cbeg < C_CNSS; cbeg++) /* trim zeros off beginning */ |
702 |
+ |
if (clr->ssamp[cbeg]) |
703 |
+ |
break; |
704 |
+ |
if (cbeg >= C_CNSS) /* should never happen! */ |
705 |
+ |
return("void"); |
706 |
|
if (clr->client_data != NULL) { /* get name if available */ |
707 |
|
strcpy(spname, (char *)clr->client_data); |
708 |
|
strcat(spname, "*"); /* make sure it's special */ |
711 |
|
} else |
712 |
|
strcpy(spname, "spec*"); |
713 |
|
c_ccvt(clr, C_CSEFF); /* else output spectrum prim */ |
714 |
+ |
for (cend = 0; !clr->ssamp[C_CNSS-1-cend]; cend++) |
715 |
+ |
; /* trim zeros off end */ |
716 |
|
fprintf(matfp, "\nvoid spectrum %s\n0\n0\n", spname); |
717 |
< |
fprintf(matfp, "%d %d %d", C_CNSS+2, C_CMINWL, C_CMAXWL); |
717 |
> |
fprintf(matfp, "%d %d %d", C_CNSS+2-cbeg-cend, |
718 |
> |
C_CMINWL+cbeg*C_CWLI, C_CMAXWL-cend*C_CWLI); |
719 |
|
mult = (C_CNSS*c_dfcolor.eff)/(clr->ssum*clr->eff); |
720 |
< |
for (i = 0; i < C_CNSS; i++) { |
721 |
< |
if (!((i+1)%6)) fputc('\n', matfp); |
720 |
> |
for (i = cbeg; i < C_CNSS-cend; i++) { |
721 |
> |
if (!((i-cbeg+1)%6)) fputc('\n', matfp); |
722 |
|
fprintf(matfp, "\t%.5f", clr->ssamp[i]*mult); |
723 |
|
} |
724 |
|
fputc('\n', matfp); |