1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
40 |
|
/* check arguments */ |
41 |
|
if (m->oargs.nfargs != 3 || m->oargs.nsargs > 1) |
42 |
|
objerror(m, USER, "bad number of arguments"); |
43 |
< |
/* check if source ray */ |
44 |
< |
if (r->rsrc >= 0) { /* aiming for somebody */ |
45 |
< |
if (source[r->rsrc].so != r->ro) |
46 |
< |
return; /* but not us */ |
47 |
< |
} else if (m->oargs.nsargs > 0) { /* else call substitute? */ |
48 |
< |
rayshade(r, modifier(m->oargs.sarg[0])); |
49 |
< |
return; |
43 |
> |
/* check for substitute material */ |
44 |
> |
if (m->oargs.nsargs > 0 && |
45 |
> |
(r->rsrc < 0 || source[r->rsrc].so != r->ro)) { |
46 |
> |
if (!strcmp(m->oargs.sarg[0], VOIDID)) { |
47 |
> |
raytrans(r); |
48 |
> |
return(1); |
49 |
> |
} |
50 |
> |
return(rayshade(r, modifier(m->oargs.sarg[0]))); |
51 |
|
} |
52 |
+ |
/* check for bad source ray */ |
53 |
+ |
if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) |
54 |
+ |
return(1); |
55 |
+ |
|
56 |
|
if (r->rod < 0.) /* back is black */ |
57 |
< |
return; |
57 |
> |
return(1); |
58 |
|
/* get modifiers */ |
59 |
|
raytexture(r, m->omod); |
60 |
|
/* assign material color */ |
75 |
|
double pdot; |
76 |
|
|
77 |
|
if (rayorigin(&nr, r, REFLECTED, bright(mcolor)) < 0) |
78 |
< |
return; |
78 |
> |
return(1); |
79 |
|
pdot = raynormal(pnorm, r); /* use textures */ |
80 |
|
for (i = 0; i < 3; i++) |
81 |
|
nr.rdir[i] = r->rdir[i] + 2.*pdot*pnorm[i]; |
82 |
+ |
/* check for penetration */ |
83 |
+ |
if (DOT(nr.rdir, r->ron) <= FTINY) |
84 |
+ |
for (i = 0; i < 3; i++) |
85 |
+ |
nr.rdir[i] = r->rdir[i] + 2.*r->rod*r->ron[i]; |
86 |
|
} |
87 |
|
rayvalue(&nr); |
88 |
|
multcolor(nr.rcol, mcolor); |
89 |
|
addcolor(r->rcol, nr.rcol); |
90 |
+ |
return(1); |
91 |
|
} |
92 |
|
|
93 |
|
|
97 |
|
SRCREC *s; |
98 |
|
int n; |
99 |
|
{ |
100 |
< |
FVECT nv; |
100 |
> |
FVECT nv, sc; |
101 |
|
double od; |
102 |
+ |
register int i, j; |
103 |
|
/* get surface normal and offset */ |
104 |
|
od = getplaneq(nv, o); |
105 |
< |
/* check for behind */ |
106 |
< |
if (DOT(s->sloc, nv) <= (s->sflags & SDISTANT ? FTINY : od+FTINY)) |
105 |
> |
/* check for extreme point for behind */ |
106 |
> |
VCOPY(sc, s->sloc); |
107 |
> |
for (i = s->sflags & SFLAT ? SV : SW; i >= 0; i--) |
108 |
> |
if (DOT(nv, s->ss[i]) > 0.) |
109 |
> |
for (j = 0; j < 3; j++) |
110 |
> |
sc[j] += s->ss[i][j]; |
111 |
> |
else |
112 |
> |
for (j = 0; j < 3; j++) |
113 |
> |
sc[j] -= s->ss[i][j]; |
114 |
> |
if (DOT(sc, nv) <= (s->sflags & SDISTANT ? FTINY : od+FTINY)) |
115 |
|
return(0); |
116 |
|
/* everything OK -- compute projection */ |
117 |
|
mirrorproj(pm, nv, od); |