| 29 |
|
VSMATERIAL mirror_vs = {mir_proj, 1}; |
| 30 |
|
|
| 31 |
|
|
| 32 |
< |
extern int |
| 32 |
> |
int |
| 33 |
|
m_mirror( /* shade mirrored ray */ |
| 34 |
< |
register OBJREC *m, |
| 35 |
< |
register RAY *r |
| 34 |
> |
OBJREC *m, |
| 35 |
> |
RAY *r |
| 36 |
|
) |
| 37 |
|
{ |
| 38 |
|
COLOR mcolor; |
| 39 |
|
RAY nr; |
| 40 |
|
int rpure = 1; |
| 41 |
< |
register int i; |
| 41 |
> |
int i; |
| 42 |
|
/* check arguments */ |
| 43 |
|
if (m->oargs.nfargs != 3 || m->oargs.nsargs > 1) |
| 44 |
|
objerror(m, USER, "bad number of arguments"); |
| 45 |
|
/* check for substitute material */ |
| 46 |
< |
if (m->oargs.nsargs > 0 && |
| 46 |
> |
/* but avoid double-counting */ |
| 47 |
> |
if (m->oargs.nsargs > 0 && !(r->crtype & (AMBIENT|SPECULAR)) && |
| 48 |
|
(r->rsrc < 0 || source[r->rsrc].so != r->ro)) { |
| 49 |
|
if (!strcmp(m->oargs.sarg[0], VOIDID)) { |
| 50 |
|
raytrans(r); |
| 56 |
|
if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) |
| 57 |
|
return(1); |
| 58 |
|
|
| 59 |
< |
if (r->rod < 0.) /* back is black */ |
| 59 |
> |
if (r->rod < 0.) { /* back is black */ |
| 60 |
> |
if (!backvis) |
| 61 |
> |
raytrans(r); /* unless back visibility is off */ |
| 62 |
|
return(1); |
| 63 |
+ |
} |
| 64 |
|
/* get modifiers */ |
| 65 |
|
raytexture(r, m->omod); |
| 66 |
|
/* assign material color */ |
| 82 |
|
|
| 83 |
|
if (rayorigin(&nr, REFLECTED, r, mcolor) < 0) |
| 84 |
|
return(1); |
| 85 |
< |
if (DOT(r->pert,r->pert) > FTINY*FTINY) { |
| 85 |
> |
if (!(r->crtype & AMBIENT) && |
| 86 |
> |
DOT(r->pert,r->pert) > FTINY*FTINY) { |
| 87 |
|
pdot = raynormal(pnorm, r); /* use textures */ |
| 88 |
|
for (i = 0; i < 3; i++) |
| 89 |
|
nr.rdir[i] = r->rdir[i] + 2.*pdot*pnorm[i]; |
| 94 |
|
for (i = 0; i < 3; i++) |
| 95 |
|
nr.rdir[i] = r->rdir[i] + 2.*r->rod*r->ron[i]; |
| 96 |
|
} |
| 97 |
+ |
checknorm(nr.rdir); |
| 98 |
|
rayvalue(&nr); |
| 99 |
|
multcolor(nr.rcol, nr.rcoef); |
| 100 |
|
addcolor(r->rcol, nr.rcol); |
| 107 |
|
static int |
| 108 |
|
mir_proj( /* compute a mirror's projection */ |
| 109 |
|
MAT4 pm, |
| 110 |
< |
register OBJREC *o, |
| 110 |
> |
OBJREC *o, |
| 111 |
|
SRCREC *s, |
| 112 |
|
int n |
| 113 |
|
) |
| 143 |
|
|
| 144 |
|
static void |
| 145 |
|
mirrorproj( /* get mirror projection for surface */ |
| 146 |
< |
register MAT4 m, |
| 146 |
> |
MAT4 m, |
| 147 |
|
FVECT nv, |
| 148 |
|
double offs |
| 149 |
|
) |
| 150 |
|
{ |
| 151 |
< |
register int i, j; |
| 151 |
> |
int i, j; |
| 152 |
|
/* assign matrix */ |
| 153 |
|
setident4(m); |
| 154 |
|
for (j = 0; j < 3; j++) { |