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