56 |
|
return; |
57 |
|
} |
58 |
|
/* set up sampling */ |
59 |
< |
n = PI * il->sampdens; |
60 |
< |
nalt = sqrt(n/PI) + .5; |
61 |
< |
nazi = PI*nalt + .5; |
59 |
> |
if (il->sampdens <= 0) |
60 |
> |
nalt = nazi = 1; |
61 |
> |
else { |
62 |
> |
n = PI * il->sampdens; |
63 |
> |
nalt = sqrt(n/PI) + .5; |
64 |
> |
nazi = PI*nalt + .5; |
65 |
> |
} |
66 |
|
n = nalt*nazi; |
67 |
|
distarr = (float *)calloc(n, 3*sizeof(float)); |
68 |
|
if (distarr == NULL) |
86 |
|
for (i = 0; i < il->nsamps; i++) { |
87 |
|
/* random direction */ |
88 |
|
h = ilhash(dim, 3) + i; |
89 |
< |
peano(sp, 2, urand(h), .02); |
89 |
> |
multisamp(sp, 2, urand(h)); |
90 |
|
r1 = (dim[1] + sp[0])/nalt; |
91 |
|
r2 = (dim[2] + sp[1])/nazi; |
92 |
|
flatdir(dn, r1, r2); |
94 |
|
dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*fa->norm[j]; |
95 |
|
/* random location */ |
96 |
|
do { |
97 |
< |
peano(sp, 2, urand(h+nmisses), .01); |
97 |
> |
multisamp(sp, 2, urand(h+4862+nmisses)); |
98 |
|
r1 = ur[0] + (ur[1]-ur[0]) * sp[0]; |
99 |
|
r2 = vr[0] + (vr[1]-vr[0]) * sp[1]; |
100 |
|
for (j = 0; j < 3; j++) |
115 |
|
raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt); |
116 |
|
} |
117 |
|
rayflush(rt); |
118 |
< |
/* write out the face w/ distribution */ |
119 |
< |
flatout(il, distarr, nalt, nazi, u, v, fa->norm); |
118 |
> |
/* write out the face and its distribution */ |
119 |
> |
average(il, distarr, nalt*nazi); |
120 |
> |
if (il->sampdens > 0) |
121 |
> |
flatout(il, distarr, nalt, nazi, u, v, fa->norm); |
122 |
|
illumout(il, ob); |
123 |
|
/* clean up */ |
124 |
|
freeface(ob); |
144 |
|
if (ob->oargs.nfargs != 4) |
145 |
|
objerror(ob, USER, "bad # of arguments"); |
146 |
|
/* set up sampling */ |
147 |
< |
n = 4.*PI * il->sampdens; |
148 |
< |
nalt = sqrt(n/PI) + .5; |
149 |
< |
nazi = PI*nalt + .5; |
147 |
> |
if (il->sampdens <= 0) |
148 |
> |
nalt = nazi = 1; |
149 |
> |
else { |
150 |
> |
n = 4.*PI * il->sampdens; |
151 |
> |
nalt = sqrt(n/PI) + .5; |
152 |
> |
nazi = PI*nalt + .5; |
153 |
> |
} |
154 |
|
n = nalt*nazi; |
155 |
|
distarr = (float *)calloc(n, 3*sizeof(float)); |
156 |
|
if (distarr == NULL) |
161 |
|
for (dim[2] = 0; dim[2] < nazi; dim[2]++) |
162 |
|
for (i = 0; i < il->nsamps; i++) { |
163 |
|
/* next sample point */ |
164 |
< |
peano(sp, 4, urand(ilhash(dim,3)+i), .02); |
164 |
> |
multisamp(sp, 4, urand(ilhash(dim,3)+i)); |
165 |
|
/* random direction */ |
166 |
|
r1 = (dim[1] + sp[0])/nalt; |
167 |
|
r2 = (dim[2] + sp[1])/nazi; |
182 |
|
raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt); |
183 |
|
} |
184 |
|
rayflush(rt); |
185 |
< |
/* write out the sphere w/ distribution */ |
186 |
< |
roundout(il, distarr, nalt, nazi); |
185 |
> |
/* write out the sphere and its distribution */ |
186 |
> |
average(il, distarr, nalt*nazi); |
187 |
> |
if (il->sampdens > 0) |
188 |
> |
roundout(il, distarr, nalt, nazi); |
189 |
> |
else |
190 |
> |
objerror(ob, WARNING, "diffuse distribution"); |
191 |
|
illumout(il, ob); |
192 |
|
/* clean up */ |
193 |
|
free((char *)distarr); |
211 |
|
/* get/check arguments */ |
212 |
|
co = getcone(ob, 0); |
213 |
|
/* set up sampling */ |
214 |
< |
n = PI * il->sampdens; |
215 |
< |
nalt = sqrt(n/PI) + .5; |
216 |
< |
nazi = PI*nalt + .5; |
214 |
> |
if (il->sampdens <= 0) |
215 |
> |
nalt = nazi = 1; |
216 |
> |
else { |
217 |
> |
n = PI * il->sampdens; |
218 |
> |
nalt = sqrt(n/PI) + .5; |
219 |
> |
nazi = PI*nalt + .5; |
220 |
> |
} |
221 |
|
n = nalt*nazi; |
222 |
|
distarr = (float *)calloc(n, 3*sizeof(float)); |
223 |
|
if (distarr == NULL) |
229 |
|
for (dim[2] = 0; dim[2] < nazi; dim[2]++) |
230 |
|
for (i = 0; i < il->nsamps; i++) { |
231 |
|
/* next sample point */ |
232 |
< |
peano(sp, 4, urand(ilhash(dim,3)+i), .02); |
232 |
> |
multisamp(sp, 4, urand(ilhash(dim,3)+i)); |
233 |
|
/* random direction */ |
234 |
|
r1 = (dim[1] + sp[0])/nalt; |
235 |
|
r2 = (dim[2] + sp[1])/nalt; |
250 |
|
raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt); |
251 |
|
} |
252 |
|
rayflush(rt); |
253 |
< |
/* write out the ring w/ distribution */ |
254 |
< |
flatout(il, distarr, nalt, nazi, u, v, co->ad); |
253 |
> |
/* write out the ring and its distribution */ |
254 |
> |
average(il, distarr, nalt*nazi); |
255 |
> |
if (il->sampdens > 0) |
256 |
> |
flatout(il, distarr, nalt, nazi, u, v, co->ad); |
257 |
|
illumout(il, ob); |
258 |
|
/* clean up */ |
259 |
|
freecone(ob); |