1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Initialize ofun[] list for renderers |
6 |
|
*/ |
7 |
|
|
8 |
< |
#include "standard.h" |
8 |
> |
#include "copyright.h" |
9 |
|
|
10 |
+ |
#include "ray.h" |
11 |
|
#include "otypes.h" |
12 |
< |
|
12 |
> |
#include "rtotypes.h" |
13 |
|
#include "otspecial.h" |
14 |
|
|
17 |
– |
extern int o_sphere(); |
18 |
– |
extern int o_face(); |
19 |
– |
extern int o_cone(); |
20 |
– |
extern int o_instance(); |
21 |
– |
extern int m_light(); |
22 |
– |
extern int m_normal(); |
23 |
– |
extern int m_aniso(); |
24 |
– |
extern int m_dielectric(); |
25 |
– |
extern int m_mist(); |
26 |
– |
extern int m_glass(); |
27 |
– |
extern int m_clip(); |
28 |
– |
extern int m_mirror(); |
29 |
– |
extern int m_direct(); |
30 |
– |
extern int m_brdf(); |
31 |
– |
extern int m_brdf2(); |
32 |
– |
extern int t_func(), t_data(); |
33 |
– |
extern int p_cfunc(), p_bfunc(); |
34 |
– |
extern int p_pdata(), p_cdata(), p_bdata(); |
35 |
– |
extern int mx_func(), mx_data(), mx_pdata(); |
36 |
– |
extern int do_text(); |
15 |
|
|
16 |
|
FUN ofun[NUMOTYPE] = INIT_OTYPE; |
17 |
|
|
18 |
|
|
19 |
< |
initotypes() /* initialize ofun array */ |
19 |
> |
void |
20 |
> |
initotypes(void) /* initialize ofun array */ |
21 |
|
{ |
22 |
|
ofun[OBJ_SPHERE].funp = |
23 |
|
ofun[OBJ_BUBBLE].funp = o_sphere; |
28 |
|
ofun[OBJ_TUBE].funp = |
29 |
|
ofun[OBJ_RING].funp = o_cone; |
30 |
|
ofun[OBJ_INSTANCE].funp = o_instance; |
31 |
+ |
ofun[OBJ_MESH].funp = o_mesh; |
32 |
+ |
ofun[MOD_ALIAS].funp = m_alias; |
33 |
|
ofun[MAT_LIGHT].funp = |
34 |
|
ofun[MAT_ILLUM].funp = |
35 |
|
ofun[MAT_GLOW].funp = |
36 |
|
ofun[MAT_SPOT].funp = m_light; |
37 |
+ |
ofun[MAT_LIGHT].flags |= T_OPAQUE; |
38 |
+ |
ofun[MAT_SPOT].flags |= T_OPAQUE; |
39 |
|
ofun[MAT_PLASTIC].funp = |
40 |
|
ofun[MAT_METAL].funp = |
41 |
|
ofun[MAT_TRANS].funp = m_normal; |
42 |
< |
ofun[MAT_TRANS].flags |= T_IRR_IGN; |
42 |
> |
ofun[MAT_PLASTIC].flags |= T_OPAQUE; |
43 |
> |
ofun[MAT_METAL].flags |= T_OPAQUE; |
44 |
> |
ofun[MAT_TRANS].flags |= T_TRANSP; |
45 |
|
ofun[MAT_PLASTIC2].funp = |
46 |
|
ofun[MAT_METAL2].funp = |
47 |
|
ofun[MAT_TRANS2].funp = m_aniso; |
48 |
< |
ofun[MAT_TRANS2].flags |= T_IRR_IGN; |
48 |
> |
ofun[MAT_PLASTIC2].flags |= T_OPAQUE; |
49 |
> |
ofun[MAT_METAL2].flags |= T_OPAQUE; |
50 |
> |
ofun[MAT_TRANS2].flags |= T_TRANSP; |
51 |
> |
ofun[MAT_ASHIKHMIN].funp = m_ashikhmin; |
52 |
> |
ofun[MAT_ASHIKHMIN].flags |= T_OPAQUE; |
53 |
|
ofun[MAT_DIELECTRIC].funp = |
54 |
|
ofun[MAT_INTERFACE].funp = m_dielectric; |
55 |
< |
ofun[MAT_DIELECTRIC].flags |= T_IRR_IGN; |
56 |
< |
ofun[MAT_INTERFACE].flags |= T_IRR_IGN; |
55 |
> |
ofun[MAT_DIELECTRIC].flags |= T_TRANSP; |
56 |
> |
ofun[MAT_INTERFACE].flags |= T_TRANSP; |
57 |
|
ofun[MAT_MIST].funp = m_mist; |
58 |
< |
ofun[MAT_MIST].flags |= T_IRR_IGN; |
58 |
> |
ofun[MAT_MIST].flags |= T_TRANSP; |
59 |
|
ofun[MAT_GLASS].funp = m_glass; |
60 |
< |
ofun[MAT_GLASS].flags |= T_IRR_IGN; |
60 |
> |
ofun[MAT_GLASS].flags |= T_TRANSP; |
61 |
|
ofun[MAT_MIRROR].funp = m_mirror; |
62 |
|
ofun[MAT_DIRECT1].funp = |
63 |
|
ofun[MAT_DIRECT2].funp = m_direct; |
64 |
|
ofun[MAT_CLIP].funp = m_clip; |
65 |
|
ofun[MAT_BRTDF].funp = m_brdf; |
66 |
+ |
ofun[MAT_BSDF].funp = |
67 |
+ |
ofun[MAT_ABSDF].funp = m_bsdf; |
68 |
+ |
ofun[MAT_ABSDF].flags |= T_TRANSP; |
69 |
|
ofun[MAT_PFUNC].funp = |
70 |
|
ofun[MAT_MFUNC].funp = |
71 |
|
ofun[MAT_PDATA].funp = |
72 |
|
ofun[MAT_MDATA].funp = |
73 |
|
ofun[MAT_TFUNC].funp = |
74 |
|
ofun[MAT_TDATA].funp = m_brdf2; |
75 |
+ |
ofun[MAT_PFUNC].flags |= T_OPAQUE; |
76 |
+ |
ofun[MAT_MFUNC].flags |= T_OPAQUE; |
77 |
+ |
ofun[MAT_TFUNC].flags |= T_OPAQUE; |
78 |
+ |
ofun[MAT_PDATA].flags |= T_OPAQUE; |
79 |
+ |
ofun[MAT_MDATA].flags |= T_OPAQUE; |
80 |
+ |
ofun[MAT_TDATA].flags |= T_OPAQUE; |
81 |
|
ofun[TEX_FUNC].funp = t_func; |
82 |
|
ofun[TEX_DATA].funp = t_data; |
83 |
|
ofun[PAT_CFUNC].funp = p_cfunc; |
84 |
|
ofun[PAT_BFUNC].funp = p_bfunc; |
85 |
|
ofun[PAT_CPICT].funp = p_pdata; |
86 |
|
ofun[PAT_CDATA].funp = p_cdata; |
87 |
+ |
ofun[PAT_SPECTRUM].funp = p_spectrum; |
88 |
+ |
ofun[PAT_SPECFILE].funp = p_specfile; |
89 |
+ |
ofun[PAT_SPECFUNC].funp = p_specfunc; |
90 |
+ |
ofun[PAT_SPECDATA].funp = p_specdata; |
91 |
+ |
ofun[PAT_SPECPICT].funp = p_specpict; |
92 |
|
ofun[PAT_BDATA].funp = p_bdata; |
93 |
|
ofun[PAT_CTEXT].funp = |
94 |
|
ofun[PAT_BTEXT].funp = |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
< |
o_default() /* default action is error */ |
102 |
> |
int |
103 |
> |
o_default(OBJREC *o, RAY *r) /* default action is error */ |
104 |
|
{ |
105 |
< |
error(INTERNAL, "unexpected object call"); |
105 |
> |
objerror(o, CONSISTENCY, "unexpected object call"); |
106 |
> |
/* unused call to load freeobjmem.o */ |
107 |
> |
free_objs(0, 0); |
108 |
> |
return(0); |
109 |
> |
} |
110 |
> |
|
111 |
> |
|
112 |
> |
OBJREC * |
113 |
> |
findmaterial(OBJREC *o) /* find an object's actual material */ |
114 |
> |
{ |
115 |
> |
OBJECT obj = OVOID; |
116 |
> |
|
117 |
> |
while (!ismaterial(o->otype)) { |
118 |
> |
if (o->otype == MOD_ALIAS && o->oargs.nsargs) { |
119 |
> |
OBJREC *ao = o; |
120 |
> |
if (obj == OVOID) |
121 |
> |
obj = objndx(o); |
122 |
> |
do { |
123 |
> |
if (!ao->oargs.nsargs) |
124 |
> |
obj = ao->omod; |
125 |
> |
else |
126 |
> |
obj = lastmod(obj, ao->oargs.sarg[0]); |
127 |
> |
if (obj == OVOID) |
128 |
> |
objerror(ao, USER, "bad reference"); |
129 |
> |
ao = objptr(obj); |
130 |
> |
} while (ao->otype == MOD_ALIAS); |
131 |
> |
/* check if aliased to material */ |
132 |
> |
if (ismaterial(ao->otype)) |
133 |
> |
return(ao); |
134 |
> |
} |
135 |
> |
if (o->omod == OVOID) { |
136 |
> |
/* void mixture de facto material? */ |
137 |
> |
if (ismixture(o->otype)) |
138 |
> |
break; |
139 |
> |
return(NULL); /* else no material found */ |
140 |
> |
} |
141 |
> |
obj = o->omod; |
142 |
> |
o = objptr(obj); |
143 |
> |
} |
144 |
> |
return(o); |
145 |
|
} |