Panda3D
eggMaterial.I
1 // Filename: eggMaterial.I
2 // Created by: drose (29Jan99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: EggMaterial::set_diff
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE void EggMaterial::
22 set_diff(const LColor &diff) {
23  _diff = diff;
24  _flags |= F_diff;
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: EggMaterial::clear_diff
29 // Access: Public
30 // Description:
31 ////////////////////////////////////////////////////////////////////
32 INLINE void EggMaterial::
33 clear_diff() {
34  _flags &= ~F_diff;
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: EggMaterial::has_diff
39 // Access: Public
40 // Description:
41 ////////////////////////////////////////////////////////////////////
42 INLINE bool EggMaterial::
43 has_diff() const {
44  return (_flags & F_diff) != 0;
45 }
46 
47 ////////////////////////////////////////////////////////////////////
48 // Function: EggMaterial::get_diff
49 // Access: Public
50 // Description: It is legal to call this even if has_diff() returns
51 // false. If so, it simply returns the default diff
52 // color.
53 ////////////////////////////////////////////////////////////////////
54 INLINE LColor EggMaterial::
55 get_diff() const {
56  if (has_diff()) {
57  return _diff;
58  } else {
59  return LColor(1.0, 1.0, 1.0, 1.0);
60  }
61 }
62 
63 ////////////////////////////////////////////////////////////////////
64 // Function: EggMaterial::set_amb
65 // Access: Public
66 // Description:
67 ////////////////////////////////////////////////////////////////////
68 INLINE void EggMaterial::
69 set_amb(const LColor &amb) {
70  _amb = amb;
71  _flags |= F_amb;
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: EggMaterial::clear_amb
76 // Access: Public
77 // Description:
78 ////////////////////////////////////////////////////////////////////
79 INLINE void EggMaterial::
80 clear_amb() {
81  _flags &= ~F_amb;
82 }
83 
84 ////////////////////////////////////////////////////////////////////
85 // Function: EggMaterial::has_amb
86 // Access: Public
87 // Description:
88 ////////////////////////////////////////////////////////////////////
89 INLINE bool EggMaterial::
90 has_amb() const {
91  return (_flags & F_amb) != 0;
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function: EggMaterial::get_amb
96 // Access: Public
97 // Description: It is legal to call this even if has_amb() returns
98 // false. If so, it simply returns the default amb
99 // color.
100 ////////////////////////////////////////////////////////////////////
101 INLINE LColor EggMaterial::
102 get_amb() const {
103  if (has_amb()) {
104  return _amb;
105  } else {
106  return LColor(1.0, 1.0, 1.0, 1.0);
107  }
108 }
109 
110 ////////////////////////////////////////////////////////////////////
111 // Function: EggMaterial::set_emit
112 // Access: Public
113 // Description:
114 ////////////////////////////////////////////////////////////////////
115 INLINE void EggMaterial::
116 set_emit(const LColor &emit) {
117  _emit = emit;
118  _flags |= F_emit;
119 }
120 
121 ////////////////////////////////////////////////////////////////////
122 // Function: EggMaterial::clear_emit
123 // Access: Public
124 // Description:
125 ////////////////////////////////////////////////////////////////////
126 INLINE void EggMaterial::
127 clear_emit() {
128  _flags &= ~F_emit;
129 }
130 
131 ////////////////////////////////////////////////////////////////////
132 // Function: EggMaterial::has_emit
133 // Access: Public
134 // Description:
135 ////////////////////////////////////////////////////////////////////
136 INLINE bool EggMaterial::
137 has_emit() const {
138  return (_flags & F_emit) != 0;
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: EggMaterial::get_emit
143 // Access: Public
144 // Description: It is legal to call this even if has_emit() returns
145 // false. If so, it simply returns the default emit
146 // color.
147 ////////////////////////////////////////////////////////////////////
148 INLINE LColor EggMaterial::
149 get_emit() const {
150  if (has_emit()) {
151  return _emit;
152  } else {
153  return LColor(0.0, 0.0, 0.0, 1.0);
154  }
155 }
156 
157 ////////////////////////////////////////////////////////////////////
158 // Function: EggMaterial::set_spec
159 // Access: Public
160 // Description:
161 ////////////////////////////////////////////////////////////////////
162 INLINE void EggMaterial::
163 set_spec(const LColor &spec) {
164  _spec = spec;
165  _flags |= F_spec;
166 }
167 
168 ////////////////////////////////////////////////////////////////////
169 // Function: EggMaterial::clear_spec
170 // Access: Public
171 // Description:
172 ////////////////////////////////////////////////////////////////////
173 INLINE void EggMaterial::
174 clear_spec() {
175  _flags &= ~F_spec;
176 }
177 
178 ////////////////////////////////////////////////////////////////////
179 // Function: EggMaterial::has_spec
180 // Access: Public
181 // Description:
182 ////////////////////////////////////////////////////////////////////
183 INLINE bool EggMaterial::
184 has_spec() const {
185  return (_flags & F_spec) != 0;
186 }
187 
188 ////////////////////////////////////////////////////////////////////
189 // Function: EggMaterial::get_spec
190 // Access: Public
191 // Description: It is legal to call this even if has_spec() returns
192 // false. If so, it simply returns the default spec
193 // color.
194 ////////////////////////////////////////////////////////////////////
195 INLINE LColor EggMaterial::
196 get_spec() const {
197  if (has_spec()) {
198  return _spec;
199  } else {
200  return LColor(0.0, 0.0, 0.0, 1.0);
201  }
202 }
203 
204 ////////////////////////////////////////////////////////////////////
205 // Function: EggMaterial::set_shininess
206 // Access: Public
207 // Description:
208 ////////////////////////////////////////////////////////////////////
209 INLINE void EggMaterial::
210 set_shininess(double shininess) {
211  _shininess = shininess;
212  _flags |= F_shininess;
213 }
214 
215 ////////////////////////////////////////////////////////////////////
216 // Function: EggMaterial::clear_shininess
217 // Access: Public
218 // Description:
219 ////////////////////////////////////////////////////////////////////
220 INLINE void EggMaterial::
221 clear_shininess() {
222  _flags &= ~F_shininess;
223 }
224 
225 ////////////////////////////////////////////////////////////////////
226 // Function: EggMaterial::has_shininess
227 // Access: Public
228 // Description:
229 ////////////////////////////////////////////////////////////////////
230 INLINE bool EggMaterial::
231 has_shininess() const {
232  return (_flags & F_shininess) != 0;
233 }
234 
235 ////////////////////////////////////////////////////////////////////
236 // Function: EggMaterial::get_shininess
237 // Access: Public
238 // Description:
239 ////////////////////////////////////////////////////////////////////
240 INLINE double EggMaterial::
241 get_shininess() const {
242  if (has_shininess()) {
243  return _shininess;
244  } else {
245  return 0.0;
246  }
247 }
248 
249 ////////////////////////////////////////////////////////////////////
250 // Function: EggMaterial::set_local
251 // Access: Public
252 // Description:
253 ////////////////////////////////////////////////////////////////////
254 INLINE void EggMaterial::
255 set_local(bool local) {
256  _local = local;
257  _flags |= F_local;
258 }
259 
260 ////////////////////////////////////////////////////////////////////
261 // Function: EggMaterial::clear_local
262 // Access: Public
263 // Description:
264 ////////////////////////////////////////////////////////////////////
265 INLINE void EggMaterial::
266 clear_local() {
267  _flags &= ~F_local;
268 }
269 
270 ////////////////////////////////////////////////////////////////////
271 // Function: EggMaterial::has_local
272 // Access: Public
273 // Description:
274 ////////////////////////////////////////////////////////////////////
275 INLINE bool EggMaterial::
276 has_local() const {
277  return (_flags & F_local) != 0;
278 }
279 
280 ////////////////////////////////////////////////////////////////////
281 // Function: EggMaterial::get_local
282 // Access: Public
283 // Description:
284 ////////////////////////////////////////////////////////////////////
285 INLINE bool EggMaterial::
286 get_local() const {
287  if (has_local()) {
288  return _local;
289  } else {
290  return 0.0;
291  }
292 }
293 
294 ////////////////////////////////////////////////////////////////////
295 // Function: UniqueEggMaterials::Constructor
296 // Access: Public
297 // Description:
298 ////////////////////////////////////////////////////////////////////
299 INLINE UniqueEggMaterials::
300 UniqueEggMaterials(int eq) : _eq(eq) {
301 }
302 
303 ////////////////////////////////////////////////////////////////////
304 // Function: UniqueEggMaterials::Function operator
305 // Access: Public
306 // Description:
307 ////////////////////////////////////////////////////////////////////
308 INLINE bool UniqueEggMaterials::
309 operator ()(const EggMaterial *t1, const EggMaterial *t2) const {
310  return t1->sorts_less_than(*t2, _eq);
311 }
312 
LColor get_amb() const
It is legal to call this even if has_amb() returns false.
Definition: eggMaterial.I:102
bool sorts_less_than(const EggMaterial &other, int eq) const
An ordering operator to compare two materials for sorting order.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
LColor get_spec() const
It is legal to call this even if has_spec() returns false.
Definition: eggMaterial.I:196
LColor get_emit() const
It is legal to call this even if has_emit() returns false.
Definition: eggMaterial.I:149
LColor get_diff() const
It is legal to call this even if has_diff() returns false.
Definition: eggMaterial.I:55