| 34 |
|
{0, 5, NULL, Lambfa}, NULL, |
| 35 |
|
}; /* a Lambertian surface */ |
| 36 |
|
|
| 37 |
+ |
static OBJREC Aftplane; /* aft clipping plane object */ |
| 38 |
+ |
|
| 39 |
|
static int raymove(), checkset(), checkhit(); |
| 40 |
|
|
| 41 |
|
#define MAXLOOP 128 /* modifier loop detection */ |
| 69 |
|
r->rweight = ro->rweight * rw; |
| 70 |
|
r->crtype = ro->crtype | (r->rtype = rt); |
| 71 |
|
VCOPY(r->rorg, ro->rop); |
| 72 |
+ |
r->rmax = 0.0; |
| 73 |
|
} |
| 74 |
|
rayclear(r); |
| 75 |
|
return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1); |
| 81 |
|
{ |
| 82 |
|
r->rno = raynum++; |
| 83 |
|
r->newcset = r->clipset; |
| 84 |
< |
r->ro = NULL; |
| 85 |
< |
r->rot = FHUGE; |
| 84 |
> |
if (r->rmax > FTINY) { |
| 85 |
> |
r->ro = &Aftplane; |
| 86 |
> |
r->rot = r->rmax; |
| 87 |
> |
r->rop[0] = r->rorg[0] + r->rot*r->rdir[0]; |
| 88 |
> |
r->rop[1] = r->rorg[1] + r->rot*r->rdir[1]; |
| 89 |
> |
r->rop[2] = r->rorg[2] + r->rot*r->rdir[2]; |
| 90 |
> |
} else { |
| 91 |
> |
r->ro = NULL; |
| 92 |
> |
r->rot = FHUGE; |
| 93 |
> |
} |
| 94 |
|
r->pert[0] = r->pert[1] = r->pert[2] = 0.0; |
| 95 |
|
setcolor(r->pcol, 1.0, 1.0, 1.0); |
| 96 |
|
setcolor(r->rcol, 0.0, 0.0, 0.0); |
| 106 |
|
|
| 107 |
|
if (localhit(r, &thescene)) |
| 108 |
|
gotmat = raycont(r); |
| 109 |
< |
else if (sourcehit(r)) |
| 109 |
> |
else if (r->ro == &Aftplane) { |
| 110 |
> |
r->ro = NULL; |
| 111 |
> |
r->rot = FHUGE; |
| 112 |
> |
} else if (sourcehit(r)) |
| 113 |
|
gotmat = rayshade(r, r->ro->omod); |
| 114 |
|
|
| 115 |
< |
if (!gotmat) |
| 115 |
> |
if (r->ro != NULL && !gotmat) |
| 116 |
|
objerror(r->ro, USER, "material not found"); |
| 117 |
|
|
| 118 |
|
if (trace != NULL) |
| 170 |
|
if (irr_ignore(m->otype)) { |
| 171 |
|
depth--; |
| 172 |
|
raytrans(r); |
| 173 |
< |
return; |
| 173 |
> |
return(1); |
| 174 |
|
} |
| 175 |
|
if (!islight(m->otype)) |
| 176 |
|
m = &Lamb; |
| 202 |
|
} |
| 203 |
|
******/ |
| 204 |
|
if ((*ofun[m->otype].funp)(m, r)) |
| 205 |
< |
objerror(USER, r->ro, "conflicting materials"); |
| 205 |
> |
objerror(r->ro, USER, "conflicting materials"); |
| 206 |
|
} |
| 207 |
|
depth--; /* end here */ |
| 208 |
|
} |
| 214 |
|
double coef; |
| 215 |
|
{ |
| 216 |
|
RAY fr, br; |
| 203 |
– |
COLOR ctmp; |
| 217 |
|
int foremat, backmat; |
| 218 |
|
register int i; |
| 219 |
|
/* clip coefficient */ |
| 221 |
|
coef = 1.0; |
| 222 |
|
else if (coef < 0.0) |
| 223 |
|
coef = 0.0; |
| 224 |
+ |
/* compute foreground and background */ |
| 225 |
+ |
foremat = backmat = -1; |
| 226 |
|
/* foreground */ |
| 227 |
|
copystruct(&fr, r); |
| 213 |
– |
fr.pert[0] = fr.pert[1] = fr.pert[2] = 0.0; |
| 214 |
– |
setcolor(fr.pcol, 1.0, 1.0, 1.0); |
| 215 |
– |
setcolor(fr.rcol, 0.0, 0.0, 0.0); |
| 228 |
|
if (fore != OVOID && coef > FTINY) |
| 229 |
|
foremat = rayshade(&fr, fore); |
| 218 |
– |
else |
| 219 |
– |
foremat = 0; |
| 230 |
|
/* background */ |
| 231 |
|
copystruct(&br, r); |
| 222 |
– |
br.pert[0] = br.pert[1] = br.pert[2] = 0.0; |
| 223 |
– |
setcolor(br.pcol, 1.0, 1.0, 1.0); |
| 224 |
– |
setcolor(br.rcol, 0.0, 0.0, 0.0); |
| 232 |
|
if (back != OVOID && coef < 1.0-FTINY) |
| 233 |
|
backmat = rayshade(&br, back); |
| 227 |
– |
else |
| 228 |
– |
backmat = foremat; |
| 234 |
|
/* check */ |
| 235 |
< |
if (backmat != foremat) |
| 236 |
< |
objerror(USER, r->ro, "mixing material with non-material"); |
| 237 |
< |
/* sum perturbations */ |
| 235 |
> |
if (foremat < 0) |
| 236 |
> |
if (backmat < 0) |
| 237 |
> |
foremat = backmat = 0; |
| 238 |
> |
else |
| 239 |
> |
foremat = backmat; |
| 240 |
> |
else if (backmat < 0) |
| 241 |
> |
backmat = foremat; |
| 242 |
> |
if ((foremat==0) != (backmat==0)) |
| 243 |
> |
objerror(r->ro, USER, "mixing material with non-material"); |
| 244 |
> |
/* mix perturbations */ |
| 245 |
|
for (i = 0; i < 3; i++) |
| 246 |
< |
r->pert[i] += coef*fr.pert[i] + (1.0-coef)*br.pert[i]; |
| 247 |
< |
/* multiply pattern colors */ |
| 246 |
> |
r->pert[i] = coef*fr.pert[i] + (1.0-coef)*br.pert[i]; |
| 247 |
> |
/* mix pattern colors */ |
| 248 |
|
scalecolor(fr.pcol, coef); |
| 249 |
|
scalecolor(br.pcol, 1.0-coef); |
| 250 |
< |
copycolor(ctmp, fr.pcol); |
| 251 |
< |
addcolor(ctmp, br.pcol); |
| 252 |
< |
multcolor(r->pcol, ctmp); |
| 253 |
< |
/* sum returned ray values */ |
| 254 |
< |
scalecolor(fr.rcol, coef); |
| 255 |
< |
scalecolor(br.rcol, 1.0-coef); |
| 256 |
< |
addcolor(r->rcol, fr.rcol); |
| 257 |
< |
addcolor(r->rcol, br.rcol); |
| 250 |
> |
copycolor(r->pcol, fr.pcol); |
| 251 |
> |
addcolor(r->pcol, br.pcol); |
| 252 |
> |
/* mix returned ray values */ |
| 253 |
> |
if (foremat) { |
| 254 |
> |
scalecolor(fr.rcol, coef); |
| 255 |
> |
scalecolor(br.rcol, 1.0-coef); |
| 256 |
> |
copycolor(r->rcol, fr.rcol); |
| 257 |
> |
addcolor(r->rcol, br.rcol); |
| 258 |
> |
r->rt = bright(fr.rcol) > bright(br.rcol) ? fr.rt : br.rt; |
| 259 |
> |
} |
| 260 |
|
/* return value tells if material */ |
| 261 |
|
return(foremat); |
| 262 |
|
} |
| 392 |
|
return(0); |
| 393 |
|
} |
| 394 |
|
cxset[0] = 0; |
| 395 |
< |
return(raymove(curpos, cxset, sflags, r, scene) == RAYHIT); |
| 395 |
> |
return(raymove(curpos, cxset, sflags, r, scene) == RAYHIT && |
| 396 |
> |
r->ro != &Aftplane); |
| 397 |
|
} |
| 398 |
|
|
| 399 |
|
|