| 26 |
|
sprintf(errmsg, "(%s): cannot make illum for %s \"%s\"", |
| 27 |
|
nm, ofun[ob->otype].funame, ob->oname); |
| 28 |
|
error(WARNING, errmsg); |
| 29 |
< |
if (!(il->flags & IL_LIGHT)) |
| 30 |
< |
printobj(il->altmat, ob); |
| 29 |
> |
printobj(il->altmat, ob); |
| 30 |
|
} |
| 31 |
|
|
| 32 |
|
|
| 55 |
|
return; |
| 56 |
|
} |
| 57 |
|
/* set up sampling */ |
| 58 |
< |
n = PI * il->sampdens; |
| 59 |
< |
nalt = sqrt(n/PI) + .5; |
| 60 |
< |
nazi = PI*nalt + .5; |
| 58 |
> |
if (il->sampdens <= 0) |
| 59 |
> |
nalt = nazi = 1; |
| 60 |
> |
else { |
| 61 |
> |
n = PI * il->sampdens; |
| 62 |
> |
nalt = sqrt(n/PI) + .5; |
| 63 |
> |
nazi = PI*nalt + .5; |
| 64 |
> |
} |
| 65 |
|
n = nalt*nazi; |
| 66 |
|
distarr = (float *)calloc(n, 3*sizeof(float)); |
| 67 |
|
if (distarr == NULL) |
| 85 |
|
for (i = 0; i < il->nsamps; i++) { |
| 86 |
|
/* random direction */ |
| 87 |
|
h = ilhash(dim, 3) + i; |
| 88 |
< |
peano(sp, 2, urand(h), .02); |
| 88 |
> |
multisamp(sp, 2, urand(h)); |
| 89 |
|
r1 = (dim[1] + sp[0])/nalt; |
| 90 |
< |
r2 = (dim[2] + sp[1])/nazi; |
| 90 |
> |
r2 = (dim[2] + sp[1] - .5)/nazi; |
| 91 |
|
flatdir(dn, r1, r2); |
| 92 |
|
for (j = 0; j < 3; j++) |
| 93 |
|
dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*fa->norm[j]; |
| 94 |
|
/* random location */ |
| 95 |
|
do { |
| 96 |
< |
peano(sp, 2, urand(h+nmisses), .01); |
| 96 |
> |
multisamp(sp, 2, urand(h+4862+nmisses)); |
| 97 |
|
r1 = ur[0] + (ur[1]-ur[0]) * sp[0]; |
| 98 |
|
r2 = vr[0] + (vr[1]-vr[0]) * sp[1]; |
| 99 |
|
for (j = 0; j < 3; j++) |
| 114 |
|
raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt); |
| 115 |
|
} |
| 116 |
|
rayflush(rt); |
| 117 |
< |
/* write out the face w/ distribution */ |
| 118 |
< |
flatout(il, distarr, nalt, nazi, u, v, fa->norm); |
| 119 |
< |
illumout(il, ob); |
| 117 |
> |
/* write out the face and its distribution */ |
| 118 |
> |
if (average(il, distarr, nalt*nazi)) { |
| 119 |
> |
if (il->sampdens > 0) |
| 120 |
> |
flatout(il, distarr, nalt, nazi, u, v, fa->norm); |
| 121 |
> |
illumout(il, ob); |
| 122 |
> |
} else |
| 123 |
> |
printobj(il->altmat, ob); |
| 124 |
|
/* clean up */ |
| 125 |
|
freeface(ob); |
| 126 |
|
free((char *)distarr); |
| 145 |
|
if (ob->oargs.nfargs != 4) |
| 146 |
|
objerror(ob, USER, "bad # of arguments"); |
| 147 |
|
/* set up sampling */ |
| 148 |
< |
n = 4.*PI * il->sampdens; |
| 149 |
< |
nalt = sqrt(n/PI) + .5; |
| 150 |
< |
nazi = PI*nalt + .5; |
| 148 |
> |
if (il->sampdens <= 0) |
| 149 |
> |
nalt = nazi = 1; |
| 150 |
> |
else { |
| 151 |
> |
n = 4.*PI * il->sampdens; |
| 152 |
> |
nalt = sqrt(n/PI) + .5; |
| 153 |
> |
nazi = PI*nalt + .5; |
| 154 |
> |
} |
| 155 |
|
n = nalt*nazi; |
| 156 |
|
distarr = (float *)calloc(n, 3*sizeof(float)); |
| 157 |
|
if (distarr == NULL) |
| 162 |
|
for (dim[2] = 0; dim[2] < nazi; dim[2]++) |
| 163 |
|
for (i = 0; i < il->nsamps; i++) { |
| 164 |
|
/* next sample point */ |
| 165 |
< |
peano(sp, 4, urand(ilhash(dim,3)+i), .02); |
| 165 |
> |
multisamp(sp, 4, urand(ilhash(dim,3)+i)); |
| 166 |
|
/* random direction */ |
| 167 |
|
r1 = (dim[1] + sp[0])/nalt; |
| 168 |
< |
r2 = (dim[2] + sp[1])/nazi; |
| 168 |
> |
r2 = (dim[2] + sp[1] - .5)/nazi; |
| 169 |
|
rounddir(dir, r1, r2); |
| 170 |
|
/* random location */ |
| 171 |
|
mkaxes(u, v, dir); /* yuck! */ |
| 183 |
|
raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt); |
| 184 |
|
} |
| 185 |
|
rayflush(rt); |
| 186 |
< |
/* write out the sphere w/ distribution */ |
| 187 |
< |
roundout(il, distarr, nalt, nazi); |
| 188 |
< |
illumout(il, ob); |
| 186 |
> |
/* write out the sphere and its distribution */ |
| 187 |
> |
if (average(il, distarr, nalt*nazi)) { |
| 188 |
> |
if (il->sampdens > 0) |
| 189 |
> |
roundout(il, distarr, nalt, nazi); |
| 190 |
> |
else |
| 191 |
> |
objerror(ob, WARNING, "diffuse distribution"); |
| 192 |
> |
illumout(il, ob); |
| 193 |
> |
} else |
| 194 |
> |
printobj(il->altmat, ob); |
| 195 |
|
/* clean up */ |
| 196 |
|
free((char *)distarr); |
| 197 |
|
} |
| 214 |
|
/* get/check arguments */ |
| 215 |
|
co = getcone(ob, 0); |
| 216 |
|
/* set up sampling */ |
| 217 |
< |
n = PI * il->sampdens; |
| 218 |
< |
nalt = sqrt(n/PI) + .5; |
| 219 |
< |
nazi = PI*nalt + .5; |
| 217 |
> |
if (il->sampdens <= 0) |
| 218 |
> |
nalt = nazi = 1; |
| 219 |
> |
else { |
| 220 |
> |
n = PI * il->sampdens; |
| 221 |
> |
nalt = sqrt(n/PI) + .5; |
| 222 |
> |
nazi = PI*nalt + .5; |
| 223 |
> |
} |
| 224 |
|
n = nalt*nazi; |
| 225 |
|
distarr = (float *)calloc(n, 3*sizeof(float)); |
| 226 |
|
if (distarr == NULL) |
| 232 |
|
for (dim[2] = 0; dim[2] < nazi; dim[2]++) |
| 233 |
|
for (i = 0; i < il->nsamps; i++) { |
| 234 |
|
/* next sample point */ |
| 235 |
< |
peano(sp, 4, urand(ilhash(dim,3)+i), .02); |
| 235 |
> |
multisamp(sp, 4, urand(ilhash(dim,3)+i)); |
| 236 |
|
/* random direction */ |
| 237 |
|
r1 = (dim[1] + sp[0])/nalt; |
| 238 |
< |
r2 = (dim[2] + sp[1])/nalt; |
| 238 |
> |
r2 = (dim[2] + sp[1] - .5)/nazi; |
| 239 |
|
flatdir(dn, r1, r2); |
| 240 |
|
for (j = 0; j < 3; j++) |
| 241 |
|
dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*co->ad[j]; |
| 253 |
|
raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt); |
| 254 |
|
} |
| 255 |
|
rayflush(rt); |
| 256 |
< |
/* write out the ring w/ distribution */ |
| 257 |
< |
flatout(il, distarr, nalt, nazi, u, v, co->ad); |
| 258 |
< |
illumout(il, ob); |
| 256 |
> |
/* write out the ring and its distribution */ |
| 257 |
> |
if (average(il, distarr, nalt*nazi)) { |
| 258 |
> |
if (il->sampdens > 0) |
| 259 |
> |
flatout(il, distarr, nalt, nazi, u, v, co->ad); |
| 260 |
> |
illumout(il, ob); |
| 261 |
> |
} else |
| 262 |
> |
printobj(il->altmat, ob); |
| 263 |
|
/* clean up */ |
| 264 |
|
freecone(ob); |
| 265 |
|
free((char *)distarr); |
| 290 |
|
if (rt->nrays <= 0) |
| 291 |
|
return; |
| 292 |
|
bzero(rt->buf+6*rt->nrays, 6*sizeof(float)); |
| 293 |
+ |
errno = 0; |
| 294 |
|
if ( process(rt->pd, (char *)rt->buf, (char *)rt->buf, |
| 295 |
|
3*sizeof(float)*rt->nrays, |
| 296 |
|
6*sizeof(float)*(rt->nrays+1)) < |