ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/mkillum3.c
(Generate patch)

Comparing ray/src/gen/mkillum3.c (file contents):
Revision 1.2 by greg, Thu Jul 25 10:59:09 1991 UTC vs.
Revision 1.7 by greg, Wed Oct 30 12:30:32 1991 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10  
11   #include  "mkillum.h"
12  
13 < #define  brt(col)       (.295*(col)[0] + .636*(col)[1] + .070*(col)[2])
13 > #define  brt(col)       (.263*(col)[0]+.655*(col)[1]+.082*(col)[2])
14  
15   char    DATORD[] = "RGB";               /* data ordering */
16   char    DATSUF[] = ".dat";              /* data file suffix */
# Line 96 | Line 96 | FVECT  u, v, w;
96          FILE  *dfp;
97          int  i;
98  
99        average(il, da, n*m);
99          if (il->flags & IL_COLDST) {
100                  printf("\n%s %s %s%s", VOIDID, ofun[PAT_CDATA].funame,
101                                  il->matname, DSTSUF);
102                  printf("\n9 red green blue");
103                  for (i = 0; i < 3; i++) {
104                          dfp = dfopen(il, DATORD[i]);
105 <                        fprintf(dfp, "2\n1 0 %d\n0 %f %d\n", n, 2.*PI, m);
106 <                        colorout(i, da, n*m, 1./il->nsamps/il->col[i], dfp);
105 >                        fprintf(dfp, "2\n%f %f %d\n%f %f %d\n",
106 >                                        1.-.5/n, .5/n, n,
107 >                                        0., 2.*PI, m+1);
108 >                        colorout(i, da, n, m, 1./il->nsamps/il->col[i], dfp);
109                          fclose(dfp);
110                          printf(" %s", dfname(il, DATORD[i]));
111                  }
# Line 113 | Line 114 | FVECT  u, v, w;
114                                  il->matname, DSTSUF);
115                  printf("\n5 noop");
116                  dfp = dfopen(il, 0);
117 <                fprintf(dfp, "2\n1 0 %d\n0 %f %d\n", n, 2.*PI, m);
118 <                brightout(da, n*m, 1./il->nsamps/brt(il->col), dfp);
117 >                fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", 1.-.5/n, .5/n, n,
118 >                                0., 2.*PI, m+1);
119 >                brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp);
120                  fclose(dfp);
121                  printf(" %s", dfname(il, 0));
122          }
# Line 135 | Line 137 | int  n, m;
137          FILE  *dfp;
138          int  i;
139  
138        average(il, da, n*m);
140          if (il->flags & IL_COLDST) {
141                  printf("\n%s %s %s%s", VOIDID, ofun[PAT_CDATA].funame,
142                                  il->matname, DSTSUF);
143                  printf("\n9 red green blue");
144                  for (i = 0; i < 3; i++) {
145                          dfp = dfopen(il, DATORD[i]);
146 <                        fprintf(dfp, "2\n1 -1 %d\n0 %f %d\n", n, 2.*PI, m);
147 <                        colorout(i, da, n*m, 1./il->nsamps/il->col[i], dfp);
146 >                        fprintf(dfp, "2\n%f %f %d\n%f %f %d\n",
147 >                                        1.-1./n, -1.+1./n, n,
148 >                                        0., 2.*PI, m+1);
149 >                        colorout(i, da, n, m, 1./il->nsamps/il->col[i], dfp);
150                          fclose(dfp);
151                          printf(" %s", dfname(il, DATORD[i]));
152                  }
# Line 152 | Line 155 | int  n, m;
155                                  il->matname, DSTSUF);
156                  printf("\n5 noop");
157                  dfp = dfopen(il, 0);
158 <                fprintf(dfp, "2\n1 -1 %d\n0 %f %d\n", n, 2.*PI, m);
159 <                brightout(da, n*m, 1./il->nsamps/brt(il->col), dfp);
158 >                fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", 1.-1./n, -1.+1./n, n,
159 >                                0., 2.*PI, m+1);
160 >                brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp);
161                  fclose(dfp);
162                  printf(" %s", dfname(il, 0));
163          }
# Line 169 | Line 173 | OBJREC  *ob;
173   {
174          double  cout[3];
175  
176 <        printf("\n%s%s %s %s", il->matname, DSTSUF,
177 <                        ofun[il->flags&IL_LIGHT?MAT_LIGHT:MAT_ILLUM].funame,
176 >        if (il->sampdens <= 0)
177 >                printf("\n%s ", VOIDID);
178 >        else
179 >                printf("\n%s%s ", il->matname, DSTSUF);
180 >        printf("%s %s", ofun[il->flags&IL_LIGHT?MAT_LIGHT:MAT_ILLUM].funame,
181                          il->matname);
182          if (il->flags & IL_LIGHT || !strcmp(il->altmat,VOIDID))
183                  printf("\n0");
# Line 183 | Line 190 | OBJREC  *ob;
190          } else {
191                  cout[0] = cout[1] = cout[2] = brt(il->col);
192          }
193 <        if (il->flags & IL_LIGHT)
187 <                printf("\n3 %f %f %f\n", cout[0], cout[1], cout[2]);
188 <        else
189 <                printf("\n4 %f %f %f 0\n", cout[0], cout[1], cout[2]);
193 >        printf("\n0\n3 %f %f %f\n", cout[0], cout[1], cout[2]);
194  
195          printobj(il->matname, ob);
196   }
# Line 208 | Line 212 | int  n;
212          }
213          for (i = 0; i < 3; i++)
214                  il->col[i] /= (double)n*il->nsamps;
215 +
216 +        return(brt(il->col) > il->minbrt+FTINY);
217   }
218  
219  
220 < colorout(p, da, n, mult, fp)    /* put out color distribution data */
220 > static int      colmcnt = 0;    /* count of columns written */
221 >
222 > fputnum(d, fp)                  /* put out a number to fp */
223 > double  d;
224 > FILE  *fp;
225 > {
226 >        if (colmcnt++ % 6 == 0)
227 >                putc('\n', fp);
228 >        fprintf(fp, " %11e", d);
229 > }
230 >
231 >
232 > fputeol(fp)                     /* write end of line to fp */
233 > register FILE  *fp;
234 > {
235 >        putc('\n', fp);
236 >        colmcnt = 0;
237 > }
238 >
239 >
240 > colorout(p, da, n, m, mult, fp) /* put out color distribution data */
241   int  p;
242   register float  *da;
243 < int  n;
243 > int  n, m;
244   double  mult;
245   FILE  *fp;
246   {
247 <        register int  i;
247 >        register int  i, j;
248  
249          for (i = 0; i < n; i++) {
250 <                if (i%6 == 0)
251 <                        putc('\n', fp);
252 <                fprintf(fp, " %11e", mult*da[p]);
253 <                da += 3;
250 >                for (j = 0; j < m; j++) {
251 >                        fputnum(mult*da[p], fp);
252 >                        da += 3;
253 >                }
254 >                fputnum(mult*da[p-3*m], fp);    /* wrap phi */
255          }
256 <        putc('\n', fp);
256 >        fputeol(fp);
257   }
258  
259  
260 < brightout(da, n, mult, fp)      /* put out brightness distribution data */
260 > brightout(da, n, m, mult, fp)   /* put out brightness distribution data */
261   register float  *da;
262 < int  n;
262 > int  n, m;
263   double  mult;
264   FILE  *fp;
265   {
266 <        register int  i;
266 >        register int  i, j;
267  
268          for (i = 0; i < n; i++) {
269 <                if (i%6 == 0)
270 <                        putc('\n', fp);
271 <                fprintf(fp, " %11e", mult*brt(da));
272 <                da += 3;
269 >                for (j = 0; j < m; j++) {
270 >                        fputnum(mult*brt(da), fp);
271 >                        da += 3;
272 >                }
273 >                fputnum(mult*brt(da-3*m), fp);  /* wrap phi */
274          }
275 <        putc('\n', fp);
275 >        fputeol(fp);
276   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines