| 48 |
|
|
| 49 |
|
if (m->otype != MAT_LIGHT && |
| 50 |
|
m->otype != MAT_ILLUM && |
| 51 |
< |
m->otype != MAT_GLOW) |
| 51 |
> |
m->otype != MAT_GLOW && |
| 52 |
> |
m->otype != MAT_SPOT) |
| 53 |
|
continue; |
| 54 |
|
|
| 55 |
< |
if (m->oargs.nfargs != 3) |
| 55 |
> |
if (m->oargs.nfargs != (m->otype == MAT_GLOW ? 4 : |
| 56 |
> |
m->otype == MAT_SPOT ? 7 : 3)) |
| 57 |
|
objerror(m, USER, "bad # arguments"); |
| 58 |
|
|
| 59 |
< |
if (m->otype == MAT_GLOW && o->otype != OBJ_SOURCE) |
| 59 |
> |
if (m->otype == MAT_GLOW && |
| 60 |
> |
o->otype != OBJ_SOURCE && |
| 61 |
> |
m->oargs.farg[3] <= FTINY) |
| 62 |
|
continue; /* don't bother */ |
| 63 |
|
|
| 64 |
|
if (source == NULL) |
| 71 |
|
|
| 72 |
|
newsource(&source[nsources], o); |
| 73 |
|
|
| 74 |
< |
if (m->otype == MAT_GLOW) |
| 75 |
< |
source[nsources].sflags |= SSKIP; |
| 76 |
< |
|
| 74 |
> |
if (m->otype == MAT_GLOW) { |
| 75 |
> |
source[nsources].sflags |= SPROX; |
| 76 |
> |
source[nsources].sl.prox = m->oargs.farg[3]; |
| 77 |
> |
if (o->otype == OBJ_SOURCE) |
| 78 |
> |
source[nsources].sflags |= SSKIP; |
| 79 |
> |
} else if (m->otype == MAT_SPOT) { |
| 80 |
> |
source[nsources].sflags |= SSPOT; |
| 81 |
> |
source[nsources].sl.s = makespot(m); |
| 82 |
> |
} |
| 83 |
|
nsources++; |
| 84 |
|
} |
| 85 |
|
} |
| 97 |
|
register int i; |
| 98 |
|
|
| 99 |
|
src->sflags = 0; |
| 100 |
< |
src->nhits = src->ntests = 1; /* start with hit probability = 1 */ |
| 100 |
> |
src->nhits = 1; src->ntests = 2; /* start probability = 1/2 */ |
| 101 |
|
src->so = so; |
| 102 |
|
|
| 103 |
|
switch (so->otype) { |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
|
| 152 |
+ |
SPOT * |
| 153 |
+ |
makespot(m) /* make a spotlight */ |
| 154 |
+ |
register OBJREC *m; |
| 155 |
+ |
{ |
| 156 |
+ |
extern double cos(); |
| 157 |
+ |
register SPOT *ns; |
| 158 |
+ |
|
| 159 |
+ |
if ((ns = (SPOT *)malloc(sizeof(SPOT))) == NULL) |
| 160 |
+ |
error(SYSTEM, "out of memory in makespot"); |
| 161 |
+ |
ns->siz = 2.0*PI * (1.0 - cos(PI/180.0/2.0 * m->oargs.farg[3])); |
| 162 |
+ |
VCOPY(ns->aim, m->oargs.farg+4); |
| 163 |
+ |
if ((ns->flen = normalize(ns->aim)) == 0.0) |
| 164 |
+ |
objerror(m, USER, "zero focus vector"); |
| 165 |
+ |
return(ns); |
| 166 |
+ |
} |
| 167 |
+ |
|
| 168 |
+ |
|
| 169 |
|
double |
| 170 |
|
srcray(sr, r, sn) /* send a ray to a source, return domega */ |
| 171 |
|
register RAY *sr; /* returned source ray */ |
| 226 |
|
return(source[sn].ss2); |
| 227 |
|
|
| 228 |
|
else { |
| 229 |
+ |
/* check proximity */ |
| 230 |
+ |
if (source[sn].sflags & SPROX && |
| 231 |
+ |
d > source[sn].sl.prox) |
| 232 |
+ |
return(0.0); |
| 233 |
|
|
| 234 |
|
if (norm != NULL) |
| 235 |
|
ddot /= d; |
| 236 |
|
else |
| 237 |
|
ddot = 1.0; |
| 238 |
+ |
/* check angle */ |
| 239 |
+ |
if (source[sn].sflags & SSPOT) { |
| 240 |
+ |
if (source[sn].sl.s->siz < 2.0*PI * |
| 241 |
+ |
(1.0 + DOT(source[sn].sl.s->aim,sr->rdir))) |
| 242 |
+ |
return(0.0); |
| 243 |
+ |
d += source[sn].sl.s->flen; |
| 244 |
+ |
} |
| 245 |
|
/* return domega */ |
| 246 |
|
return(ddot*source[sn].ss2/(d*d)); |
| 247 |
|
} |
| 312 |
|
for (sn = 0; sn < nsources; sn++) { |
| 313 |
|
srccnt[sn].sno = sn; |
| 314 |
|
setcolor(srccnt[sn].val, 0.0, 0.0, 0.0); |
| 315 |
+ |
srccnt[sn].brt = 0.0; |
| 316 |
|
/* get source ray */ |
| 317 |
|
if ((srccnt[sn].dom = srcray(&sr, r, sn)) == 0.0) |
| 318 |
|
continue; |
| 392 |
|
source[r->rsrc].so!=r->ro) |
| 393 |
|
|
| 394 |
|
#define badambient(m, r) ((r->crtype&(AMBIENT|SHADOW))==AMBIENT && \ |
| 395 |
< |
!(r->rtype&REFLECTED)) /* hack! */ |
| 395 |
> |
!(r->rtype&REFLECTED) && /* hack! */\ |
| 396 |
> |
!(m->otype==MAT_GLOW&&r->rot>m->oargs.farg[3])) |
| 397 |
|
|
| 398 |
|
#define passillum(m, r) (m->otype==MAT_ILLUM && \ |
| 399 |
|
!(r->rsrc>=0&&source[r->rsrc].so==r->ro)) |