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.3 by greg, Thu Jul 25 12:52:21 1991 UTC vs.
Revision 2.3 by greg, Thu Mar 12 11:44:01 1992 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 24 | Line 24 | register OBJREC  *obj;
24   {
25          register int  i;
26  
27 +        if (issurface(obj->otype) && !strcmp(mod, VOIDID))
28 +                return;         /* don't print void surfaces */
29          printf("\n%s %s %s", mod, ofun[obj->otype].funame, obj->oname);
30          printf("\n%d", obj->oargs.nsargs);
31          for (i = 0; i < obj->oargs.nsargs; i++)
# Line 96 | Line 98 | FVECT  u, v, w;
98          FILE  *dfp;
99          int  i;
100  
99        average(il, da, n*m);
101          if (il->flags & IL_COLDST) {
102                  printf("\n%s %s %s%s", VOIDID, ofun[PAT_CDATA].funame,
103                                  il->matname, DSTSUF);
104                  printf("\n9 red green blue");
105                  for (i = 0; i < 3; i++) {
106                          dfp = dfopen(il, DATORD[i]);
107 <                        fprintf(dfp, "2\n1 0 %d\n0 %f %d\n", n, 2.*PI, m);
108 <                        colorout(i, da, n*m, 1./il->nsamps/il->col[i], dfp);
107 >                        fprintf(dfp, "2\n%f %f %d\n%f %f %d\n",
108 >                                        1.-.5/n, .5/n, n,
109 >                                        0., 2.*PI, m+1);
110 >                        colorout(i, da, n, m, 1./il->nsamps/il->col[i], dfp);
111                          fclose(dfp);
112                          printf(" %s", dfname(il, DATORD[i]));
113                  }
114          } else {
115                  printf("\n%s %s %s%s", VOIDID, ofun[PAT_BDATA].funame,
116                                  il->matname, DSTSUF);
117 <                printf("\n5 noop");
117 >                printf("\n5 noneg");
118                  dfp = dfopen(il, 0);
119 <                fprintf(dfp, "2\n1 0 %d\n0 %f %d\n", n, 2.*PI, m);
120 <                brightout(da, n*m, 1./il->nsamps/brt(il->col), dfp);
119 >                fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", 1.-.5/n, .5/n, n,
120 >                                0., 2.*PI, m+1);
121 >                brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp);
122                  fclose(dfp);
123                  printf(" %s", dfname(il, 0));
124          }
# Line 135 | Line 139 | int  n, m;
139          FILE  *dfp;
140          int  i;
141  
138        average(il, da, n*m);
142          if (il->flags & IL_COLDST) {
143                  printf("\n%s %s %s%s", VOIDID, ofun[PAT_CDATA].funame,
144                                  il->matname, DSTSUF);
145                  printf("\n9 red green blue");
146                  for (i = 0; i < 3; i++) {
147                          dfp = dfopen(il, DATORD[i]);
148 <                        fprintf(dfp, "2\n1 -1 %d\n0 %f %d\n", n, 2.*PI, m);
149 <                        colorout(i, da, n*m, 1./il->nsamps/il->col[i], dfp);
148 >                        fprintf(dfp, "2\n%f %f %d\n%f %f %d\n",
149 >                                        1.-1./n, -1.+1./n, n,
150 >                                        0., 2.*PI, m+1);
151 >                        colorout(i, da, n, m, 1./il->nsamps/il->col[i], dfp);
152                          fclose(dfp);
153                          printf(" %s", dfname(il, DATORD[i]));
154                  }
155          } else {
156                  printf("\n%s %s %s%s", VOIDID, ofun[PAT_BDATA].funame,
157                                  il->matname, DSTSUF);
158 <                printf("\n5 noop");
158 >                printf("\n5 noneg");
159                  dfp = dfopen(il, 0);
160 <                fprintf(dfp, "2\n1 -1 %d\n0 %f %d\n", n, 2.*PI, m);
161 <                brightout(da, n*m, 1./il->nsamps/brt(il->col), dfp);
160 >                fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", 1.-1./n, -1.+1./n, n,
161 >                                0., 2.*PI, m+1);
162 >                brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp);
163                  fclose(dfp);
164                  printf(" %s", dfname(il, 0));
165          }
# Line 169 | Line 175 | OBJREC  *ob;
175   {
176          double  cout[3];
177  
178 <        printf("\n%s%s %s %s", il->matname, DSTSUF,
179 <                        ofun[il->flags&IL_LIGHT?MAT_LIGHT:MAT_ILLUM].funame,
178 >        if (il->sampdens <= 0)
179 >                printf("\n%s ", VOIDID);
180 >        else
181 >                printf("\n%s%s ", il->matname, DSTSUF);
182 >        printf("%s %s", ofun[il->flags&IL_LIGHT?MAT_LIGHT:MAT_ILLUM].funame,
183                          il->matname);
184          if (il->flags & IL_LIGHT || !strcmp(il->altmat,VOIDID))
185                  printf("\n0");
# Line 205 | Line 214 | int  n;
214          }
215          for (i = 0; i < 3; i++)
216                  il->col[i] /= (double)n*il->nsamps;
217 +
218 +        return(brt(il->col) > il->minbrt+FTINY);
219   }
220  
221  
222 < colorout(p, da, n, mult, fp)    /* put out color distribution data */
222 > static int      colmcnt = 0;    /* count of columns written */
223 >
224 > fputnum(d, fp)                  /* put out a number to fp */
225 > double  d;
226 > FILE  *fp;
227 > {
228 >        if (colmcnt++ % 6 == 0)
229 >                putc('\n', fp);
230 >        fprintf(fp, " %11e", d);
231 > }
232 >
233 >
234 > fputeol(fp)                     /* write end of line to fp */
235 > register FILE  *fp;
236 > {
237 >        putc('\n', fp);
238 >        colmcnt = 0;
239 > }
240 >
241 >
242 > colorout(p, da, n, m, mult, fp) /* put out color distribution data */
243   int  p;
244   register float  *da;
245 < int  n;
245 > int  n, m;
246   double  mult;
247   FILE  *fp;
248   {
249 <        register int  i;
249 >        register int  i, j;
250  
251          for (i = 0; i < n; i++) {
252 <                if (i%6 == 0)
253 <                        putc('\n', fp);
254 <                fprintf(fp, " %11e", mult*da[p]);
255 <                da += 3;
252 >                for (j = 0; j < m; j++) {
253 >                        fputnum(mult*da[p], fp);
254 >                        da += 3;
255 >                }
256 >                fputnum(mult*da[p-3*m], fp);    /* wrap phi */
257          }
258 <        putc('\n', fp);
258 >        fputeol(fp);
259   }
260  
261  
262 < brightout(da, n, mult, fp)      /* put out brightness distribution data */
262 > brightout(da, n, m, mult, fp)   /* put out brightness distribution data */
263   register float  *da;
264 < int  n;
264 > int  n, m;
265   double  mult;
266   FILE  *fp;
267   {
268 <        register int  i;
268 >        register int  i, j;
269  
270          for (i = 0; i < n; i++) {
271 <                if (i%6 == 0)
272 <                        putc('\n', fp);
273 <                fprintf(fp, " %11e", mult*brt(da));
274 <                da += 3;
271 >                for (j = 0; j < m; j++) {
272 >                        fputnum(mult*brt(da), fp);
273 >                        da += 3;
274 >                }
275 >                fputnum(mult*brt(da-3*m), fp);  /* wrap phi */
276          }
277 <        putc('\n', fp);
277 >        fputeol(fp);
278   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines