Panda3D
eggMaterial.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file eggMaterial.I
10  * @author drose
11  * @date 1999-01-29
12  */
13 
14 /**
15  *
16  */
17 INLINE void EggMaterial::
18 set_base(const LColor &base) {
19  _base = base;
20  _flags |= F_base;
21 }
22 
23 /**
24  *
25  */
26 INLINE void EggMaterial::
27 clear_base() {
28  _flags &= ~F_base;
29 }
30 
31 /**
32  *
33  */
34 INLINE bool EggMaterial::
35 has_base() const {
36  return (_flags & F_base) != 0;
37 }
38 
39 /**
40  * It is legal to call this even if has_base() returns false. If so, it
41  * simply returns the default base color.
42  */
43 INLINE LColor EggMaterial::
44 get_base() const {
45  if (has_base()) {
46  return _base;
47  } else {
48  return LColor(1.0, 1.0, 1.0, 1.0);
49  }
50 }
51 
52 /**
53  *
54  */
55 INLINE void EggMaterial::
56 set_diff(const LColor &diff) {
57  _diff = diff;
58  _flags |= F_diff;
59 }
60 
61 /**
62  *
63  */
64 INLINE void EggMaterial::
65 clear_diff() {
66  _flags &= ~F_diff;
67 }
68 
69 /**
70  *
71  */
72 INLINE bool EggMaterial::
73 has_diff() const {
74  return (_flags & F_diff) != 0;
75 }
76 
77 /**
78  * It is legal to call this even if has_diff() returns false. If so, it
79  * simply returns the default diff color.
80  */
81 INLINE LColor EggMaterial::
82 get_diff() const {
83  if (has_diff()) {
84  return _diff;
85  } else {
86  return LColor(1.0, 1.0, 1.0, 1.0);
87  }
88 }
89 
90 /**
91  *
92  */
93 INLINE void EggMaterial::
94 set_amb(const LColor &amb) {
95  _amb = amb;
96  _flags |= F_amb;
97 }
98 
99 /**
100  *
101  */
102 INLINE void EggMaterial::
103 clear_amb() {
104  _flags &= ~F_amb;
105 }
106 
107 /**
108  *
109  */
110 INLINE bool EggMaterial::
111 has_amb() const {
112  return (_flags & F_amb) != 0;
113 }
114 
115 /**
116  * It is legal to call this even if has_amb() returns false. If so, it simply
117  * returns the default amb color.
118  */
119 INLINE LColor EggMaterial::
120 get_amb() const {
121  if (has_amb()) {
122  return _amb;
123  } else {
124  return LColor(1.0, 1.0, 1.0, 1.0);
125  }
126 }
127 
128 /**
129  *
130  */
131 INLINE void EggMaterial::
132 set_emit(const LColor &emit) {
133  _emit = emit;
134  _flags |= F_emit;
135 }
136 
137 /**
138  *
139  */
140 INLINE void EggMaterial::
141 clear_emit() {
142  _flags &= ~F_emit;
143 }
144 
145 /**
146  *
147  */
148 INLINE bool EggMaterial::
149 has_emit() const {
150  return (_flags & F_emit) != 0;
151 }
152 
153 /**
154  * It is legal to call this even if has_emit() returns false. If so, it
155  * simply returns the default emit color.
156  */
157 INLINE LColor EggMaterial::
158 get_emit() const {
159  if (has_emit()) {
160  return _emit;
161  } else {
162  return LColor(0.0, 0.0, 0.0, 1.0);
163  }
164 }
165 
166 /**
167  *
168  */
169 INLINE void EggMaterial::
170 set_spec(const LColor &spec) {
171  _spec = spec;
172  _flags |= F_spec;
173 }
174 
175 /**
176  *
177  */
178 INLINE void EggMaterial::
179 clear_spec() {
180  _flags &= ~F_spec;
181 }
182 
183 /**
184  *
185  */
186 INLINE bool EggMaterial::
187 has_spec() const {
188  return (_flags & F_spec) != 0;
189 }
190 
191 /**
192  * It is legal to call this even if has_spec() returns false. If so, it
193  * simply returns the default spec 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  *
206  */
207 INLINE void EggMaterial::
208 set_shininess(double shininess) {
209  _shininess = shininess;
210  _flags |= F_shininess;
211 }
212 
213 /**
214  *
215  */
216 INLINE void EggMaterial::
217 clear_shininess() {
218  _flags &= ~F_shininess;
219 }
220 
221 /**
222  *
223  */
224 INLINE bool EggMaterial::
225 has_shininess() const {
226  return (_flags & F_shininess) != 0;
227 }
228 
229 /**
230  *
231  */
232 INLINE double EggMaterial::
233 get_shininess() const {
234  if (has_shininess()) {
235  return _shininess;
236  } else {
237  return 0.0;
238  }
239 }
240 
241 /**
242  *
243  */
244 INLINE void EggMaterial::
245 set_roughness(double roughness) {
246  _roughness = roughness;
247  _flags |= F_roughness;
248 }
249 
250 /**
251  *
252  */
253 INLINE void EggMaterial::
254 clear_roughness() {
255  _flags &= ~F_roughness;
256 }
257 
258 /**
259  *
260  */
261 INLINE bool EggMaterial::
262 has_roughness() const {
263  return (_flags & F_roughness) != 0;
264 }
265 
266 /**
267  *
268  */
269 INLINE double EggMaterial::
270 get_roughness() const {
271  if (has_roughness()) {
272  return _roughness;
273  } else {
274  return 1.0;
275  }
276 }
277 
278 /**
279  *
280  */
281 INLINE void EggMaterial::
282 set_metallic(double metallic) {
283  _metallic = metallic;
284  _flags |= F_metallic;
285 }
286 
287 /**
288  *
289  */
290 INLINE void EggMaterial::
291 clear_metallic() {
292  _flags &= ~F_metallic;
293 }
294 
295 /**
296  *
297  */
298 INLINE bool EggMaterial::
299 has_metallic() const {
300  return (_flags & F_metallic) != 0;
301 }
302 
303 /**
304  *
305  */
306 INLINE double EggMaterial::
307 get_metallic() const {
308  if (has_metallic()) {
309  return _metallic;
310  } else {
311  return 0.0;
312  }
313 }
314 
315 /**
316  *
317  */
318 INLINE void EggMaterial::
319 set_ior(double ior) {
320  _ior = ior;
321  _flags |= F_ior;
322 }
323 
324 /**
325  *
326  */
327 INLINE void EggMaterial::
328 clear_ior() {
329  _flags &= ~F_ior;
330 }
331 
332 /**
333  *
334  */
335 INLINE bool EggMaterial::
336 has_ior() const {
337  return (_flags & F_ior) != 0;
338 }
339 
340 /**
341  *
342  */
343 INLINE double EggMaterial::
344 get_ior() const {
345  if (has_ior()) {
346  return _ior;
347  } else {
348  return 1.0;
349  }
350 }
351 
352 /**
353  *
354  */
355 INLINE void EggMaterial::
356 set_local(bool local) {
357  _local = local;
358  _flags |= F_local;
359 }
360 
361 /**
362  *
363  */
364 INLINE void EggMaterial::
365 clear_local() {
366  _flags &= ~F_local;
367 }
368 
369 /**
370  *
371  */
372 INLINE bool EggMaterial::
373 has_local() const {
374  return (_flags & F_local) != 0;
375 }
376 
377 /**
378  *
379  */
380 INLINE bool EggMaterial::
381 get_local() const {
382  if (has_local()) {
383  return _local;
384  } else {
385  return 0.0;
386  }
387 }
388 
389 /**
390  *
391  */
392 INLINE UniqueEggMaterials::
393 UniqueEggMaterials(int eq) : _eq(eq) {
394 }
395 
396 /**
397  *
398  */
399 INLINE bool UniqueEggMaterials::
400 operator ()(const EggMaterial *t1, const EggMaterial *t2) const {
401  return t1->sorts_less_than(*t2, _eq);
402 }
bool sorts_less_than(const EggMaterial &other, int eq) const
An ordering operator to compare two materials for sorting order.