Panda3D
eggTexture.I
1 // Filename: eggTexture.I
2 // Created by: drose (18Jan99)
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: EggTexture::set_texture_type
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE void EggTexture::
22 set_texture_type(TextureType texture_type) {
23  _texture_type = texture_type;
24 
25  bool pattern_filename =
26  (_texture_type == TT_3d_texture || _texture_type == TT_cube_map);
27 
28  _filename.set_pattern(pattern_filename);
29  _fullpath.set_pattern(pattern_filename);
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function: EggTexture::get_texture_type
34 // Access: Published
35 // Description:
36 ////////////////////////////////////////////////////////////////////
37 INLINE EggTexture::TextureType EggTexture::
38 get_texture_type() const {
39  return _texture_type;
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: EggTexture::set_format
44 // Access: Published
45 // Description:
46 ////////////////////////////////////////////////////////////////////
47 INLINE void EggTexture::
48 set_format(Format format) {
49  _format = format;
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function: EggTexture::get_format
54 // Access: Published
55 // Description:
56 ////////////////////////////////////////////////////////////////////
57 INLINE EggTexture::Format EggTexture::
58 get_format() const {
59  return _format;
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: EggTexture::set_compression_mode
64 // Access: Published
65 // Description:
66 ////////////////////////////////////////////////////////////////////
67 INLINE void EggTexture::
68 set_compression_mode(CompressionMode mode) {
69  _compression_mode = mode;
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: EggTexture::get_compression_mode
74 // Access: Published
75 // Description:
76 ////////////////////////////////////////////////////////////////////
77 INLINE EggTexture::CompressionMode EggTexture::
78 get_compression_mode() const {
79  return _compression_mode;
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: EggTexture::set_wrap_mode
84 // Access: Published
85 // Description:
86 ////////////////////////////////////////////////////////////////////
87 INLINE void EggTexture::
88 set_wrap_mode(WrapMode mode) {
89  _wrap_mode = mode;
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function: EggTexture::get_wrap_mode
94 // Access: Published
95 // Description:
96 ////////////////////////////////////////////////////////////////////
97 INLINE EggTexture::WrapMode EggTexture::
98 get_wrap_mode() const {
99  return _wrap_mode;
100 }
101 
102 ////////////////////////////////////////////////////////////////////
103 // Function: EggTexture::set_wrap_u
104 // Access: Published
105 // Description:
106 ////////////////////////////////////////////////////////////////////
107 INLINE void EggTexture::
108 set_wrap_u(WrapMode mode) {
109  _wrap_u = mode;
110 }
111 
112 ////////////////////////////////////////////////////////////////////
113 // Function: EggTexture::get_wrap_u
114 // Access: Published
115 // Description: Returns the amount specified for U wrap. This may be
116 // unspecified, even if there is an overall wrap value.
117 ////////////////////////////////////////////////////////////////////
118 INLINE EggTexture::WrapMode EggTexture::
119 get_wrap_u() const {
120  return _wrap_u;
121 }
122 
123 ////////////////////////////////////////////////////////////////////
124 // Function: EggTexture::determine_wrap_u
125 // Access: Published
126 // Description: Determines the appropriate wrap in the U direction.
127 // This is different from get_wrap_u() in that if the U
128 // wrap is unspecified, it returns the overall wrap
129 // value.
130 ////////////////////////////////////////////////////////////////////
131 INLINE EggTexture::WrapMode EggTexture::
133  return (_wrap_u == WM_unspecified) ? get_wrap_mode() : get_wrap_u();
134 }
135 
136 ////////////////////////////////////////////////////////////////////
137 // Function: EggTexture::set_wrap_v
138 // Access: Published
139 // Description:
140 ////////////////////////////////////////////////////////////////////
141 INLINE void EggTexture::
142 set_wrap_v(WrapMode mode) {
143  _wrap_v = mode;
144 }
145 
146 ////////////////////////////////////////////////////////////////////
147 // Function: EggTexture::get_wrap_v
148 // Access: Published
149 // Description: Returns the amount specified for V wrap. This may be
150 // unspecified, even if there is an overall wrap value.
151 ////////////////////////////////////////////////////////////////////
152 INLINE EggTexture::WrapMode EggTexture::
153 get_wrap_v() const {
154  return _wrap_v;
155 }
156 
157 ////////////////////////////////////////////////////////////////////
158 // Function: EggTexture::determine_wrap_v
159 // Access: Published
160 // Description: Determines the appropriate wrap in the V direction.
161 // This is different from get_wrap_v() in that if the V
162 // wrap is unspecified, it returns the overall wrap
163 // value.
164 ////////////////////////////////////////////////////////////////////
165 INLINE EggTexture::WrapMode EggTexture::
167  return (_wrap_v == WM_unspecified) ? get_wrap_mode() : get_wrap_v();
168 }
169 
170 ////////////////////////////////////////////////////////////////////
171 // Function: EggTexture::set_wrap_w
172 // Access: Published
173 // Description:
174 ////////////////////////////////////////////////////////////////////
175 INLINE void EggTexture::
176 set_wrap_w(WrapMode mode) {
177  _wrap_w = mode;
178 }
179 
180 ////////////////////////////////////////////////////////////////////
181 // Function: EggTexture::get_wrap_w
182 // Access: Published
183 // Description: Returns the amount specified for W wrap. This may be
184 // unspecified, even if there is an overall wrap value.
185 ////////////////////////////////////////////////////////////////////
186 INLINE EggTexture::WrapMode EggTexture::
187 get_wrap_w() const {
188  return _wrap_w;
189 }
190 
191 ////////////////////////////////////////////////////////////////////
192 // Function: EggTexture::determine_wrap_w
193 // Access: Published
194 // Description: Determines the appropriate wrap in the W direction.
195 // This is different from get_wrap_w() in that if the W
196 // wrap is unspecified, it returns the overall wrap
197 // value.
198 ////////////////////////////////////////////////////////////////////
199 INLINE EggTexture::WrapMode EggTexture::
201  return (_wrap_w == WM_unspecified) ? get_wrap_mode() : get_wrap_w();
202 }
203 
204 ////////////////////////////////////////////////////////////////////
205 // Function: EggTexture::set_minfilter
206 // Access: Published
207 // Description:
208 ////////////////////////////////////////////////////////////////////
209 INLINE void EggTexture::
210 set_minfilter(FilterType type) {
211  _minfilter = type;
212 }
213 
214 ////////////////////////////////////////////////////////////////////
215 // Function: EggTexture::get_minfilter
216 // Access: Published
217 // Description:
218 ////////////////////////////////////////////////////////////////////
219 INLINE EggTexture::FilterType EggTexture::
220 get_minfilter() const {
221  return _minfilter;
222 }
223 
224 ////////////////////////////////////////////////////////////////////
225 // Function: EggTexture::set_magfilter
226 // Access: Published
227 // Description:
228 ////////////////////////////////////////////////////////////////////
229 INLINE void EggTexture::
230 set_magfilter(FilterType type) {
231  _magfilter = type;
232 }
233 
234 ////////////////////////////////////////////////////////////////////
235 // Function: EggTexture::get_magfilter
236 // Access: Published
237 // Description:
238 ////////////////////////////////////////////////////////////////////
239 INLINE EggTexture::FilterType EggTexture::
240 get_magfilter() const {
241  return _magfilter;
242 }
243 
244 ////////////////////////////////////////////////////////////////////
245 // Function: EggTexture::set_anisotropic_degree
246 // Access: Published
247 // Description: Sets the degree of anisotropic filtering for this
248 // texture. 1 is off; higher levels indicate filtering
249 // in effect.
250 ////////////////////////////////////////////////////////////////////
251 INLINE void EggTexture::
252 set_anisotropic_degree(int anisotropic_degree) {
253  _anisotropic_degree = anisotropic_degree;
254  _flags |= F_has_anisotropic_degree;
255 }
256 
257 ////////////////////////////////////////////////////////////////////
258 // Function: EggTexture::clear_anisotropic_degree
259 // Access: Published
260 // Description: Removes the specification of anisotropic filtering
261 // from the texture.
262 ////////////////////////////////////////////////////////////////////
263 INLINE void EggTexture::
265  _anisotropic_degree = 0;
266  _flags &= ~F_has_anisotropic_degree;
267 }
268 
269 ////////////////////////////////////////////////////////////////////
270 // Function: EggTexture::has_anisotropic_degree
271 // Access: Published
272 // Description: Returns true if a value for the anisotropic filtering
273 // degree has been specified for this texture, false
274 // otherwise.
275 ////////////////////////////////////////////////////////////////////
276 INLINE bool EggTexture::
278  return (_flags & F_has_anisotropic_degree) != 0;
279 }
280 
281 ////////////////////////////////////////////////////////////////////
282 // Function: EggTexture::get_anisotropic_degree
283 // Access: Published
284 // Description: Returns the anisotropic filtering degree that has
285 // been specified for this texture, or 0 if nothing has
286 // been specified.
287 ////////////////////////////////////////////////////////////////////
288 INLINE int EggTexture::
290  // note: _anisotropic_degree of 0 and 1 are equivalent (no
291  // anisotropic filtering to be done by gsg)
292  return _anisotropic_degree;
293 }
294 
295 ////////////////////////////////////////////////////////////////////
296 // Function: EggTexture::set_env_type
297 // Access: Published
298 // Description:
299 ////////////////////////////////////////////////////////////////////
300 INLINE void EggTexture::
301 set_env_type(EnvType type) {
302  _env_type = type;
303 }
304 
305 ////////////////////////////////////////////////////////////////////
306 // Function: EggTexture::get_env_type
307 // Access: Published
308 // Description:
309 ////////////////////////////////////////////////////////////////////
310 INLINE EggTexture::EnvType EggTexture::
311 get_env_type() const {
312  return _env_type;
313 }
314 
315 ////////////////////////////////////////////////////////////////////
316 // Function: EggTexture::set_combine_mode
317 // Access: Published
318 // Description:
319 ////////////////////////////////////////////////////////////////////
320 INLINE void EggTexture::
321 set_combine_mode(CombineChannel channel, CombineMode cm) {
322  nassertv((int)channel >= 0 && (int)channel < (int)CC_num_channels);
323  _combiner[channel]._mode = cm;
324 }
325 
326 ////////////////////////////////////////////////////////////////////
327 // Function: EggTexture::get_combine_mode
328 // Access: Published
329 // Description:
330 ////////////////////////////////////////////////////////////////////
331 INLINE EggTexture::CombineMode EggTexture::
332 get_combine_mode(CombineChannel channel) const {
333  nassertr((int)channel >= 0 && (int)channel < (int)CC_num_channels, CM_unspecified);
334  return _combiner[channel]._mode;
335 }
336 
337 ////////////////////////////////////////////////////////////////////
338 // Function: EggTexture::set_combine_source
339 // Access: Published
340 // Description:
341 ////////////////////////////////////////////////////////////////////
342 INLINE void EggTexture::
343 set_combine_source(CombineChannel channel, int n, CombineSource cs) {
344  nassertv((int)channel >= 0 && (int)channel < (int)CC_num_channels);
345  nassertv(n >= 0 && n < (int)CI_num_indices);
346  _combiner[channel]._ops[n]._source = cs;
347 }
348 
349 ////////////////////////////////////////////////////////////////////
350 // Function: EggTexture::get_combine_source
351 // Access: Published
352 // Description:
353 ////////////////////////////////////////////////////////////////////
354 INLINE EggTexture::CombineSource EggTexture::
355 get_combine_source(CombineChannel channel, int n) const {
356  nassertr((int)channel >= 0 && (int)channel < (int)CC_num_channels, CS_unspecified);
357  nassertr(n >= 0 && n < (int)CI_num_indices, CS_unspecified);
358  return _combiner[channel]._ops[n]._source;
359 }
360 
361 ////////////////////////////////////////////////////////////////////
362 // Function: EggTexture::set_combine_operand
363 // Access: Published
364 // Description:
365 ////////////////////////////////////////////////////////////////////
366 INLINE void EggTexture::
367 set_combine_operand(CombineChannel channel, int n, CombineOperand co) {
368  nassertv((int)channel >= 0 && (int)channel < (int)CC_num_channels);
369  nassertv(n >= 0 && n < (int)CI_num_indices);
370  _combiner[channel]._ops[n]._operand = co;
371 }
372 
373 ////////////////////////////////////////////////////////////////////
374 // Function: EggTexture::get_combine_operand
375 // Access: Published
376 // Description:
377 ////////////////////////////////////////////////////////////////////
378 INLINE EggTexture::CombineOperand EggTexture::
379 get_combine_operand(CombineChannel channel, int n) const {
380  nassertr((int)channel >= 0 && (int)channel < (int)CC_num_channels, CO_unspecified);
381  nassertr(n >= 0 && n < (int)CI_num_indices, CO_unspecified);
382  return _combiner[channel]._ops[n]._operand;
383 }
384 
385 ////////////////////////////////////////////////////////////////////
386 // Function: EggTexture::set_saved_result
387 // Access: Published
388 // Description: Sets the saved_result flag. When this is true, the
389 // output of this stage is not part of the normal
390 // pipeline--that is, it will not be supplied as the
391 // "previous" source for the next texture stage--but it
392 // will instead be supplied as the "last_saved_result"
393 // source for any future stages, until the next
394 // TextureStage with a saved_result set true is
395 // encountered.
396 //
397 // This can be used to reuse the results of this texture
398 // stage as input to more than one stage later in the
399 // pipeline.
400 //
401 // The last texture in the pipeline (the one with the
402 // highest sort value) should not have this flag set.
403 ////////////////////////////////////////////////////////////////////
404 INLINE void EggTexture::
405 set_saved_result(bool saved_result) {
406  _saved_result = saved_result;
407 }
408 
409 ////////////////////////////////////////////////////////////////////
410 // Function: EggTexture::get_saved_result
411 // Access: Published
412 // Description: Returns the current setting of the saved_result flag.
413 // See set_saved_result().
414 ////////////////////////////////////////////////////////////////////
415 INLINE bool EggTexture::
417  return _saved_result;
418 }
419 
420 ////////////////////////////////////////////////////////////////////
421 // Function: EggTexture::set_tex_gen
422 // Access: Published
423 // Description:
424 ////////////////////////////////////////////////////////////////////
425 INLINE void EggTexture::
426 set_tex_gen(TexGen tex_gen) {
427  _tex_gen = tex_gen;
428 }
429 
430 ////////////////////////////////////////////////////////////////////
431 // Function: EggTexture::get_tex_gen
432 // Access: Published
433 // Description:
434 ////////////////////////////////////////////////////////////////////
435 INLINE EggTexture::TexGen EggTexture::
436 get_tex_gen() const {
437  return _tex_gen;
438 }
439 
440 ////////////////////////////////////////////////////////////////////
441 // Function: EggTexture::set_quality_level
442 // Access: Published
443 // Description:
444 ////////////////////////////////////////////////////////////////////
445 INLINE void EggTexture::
446 set_quality_level(QualityLevel quality_level) {
447  _quality_level = quality_level;
448 }
449 
450 ////////////////////////////////////////////////////////////////////
451 // Function: EggTexture::get_quality_level
452 // Access: Published
453 // Description:
454 ////////////////////////////////////////////////////////////////////
455 INLINE EggTexture::QualityLevel EggTexture::
456 get_quality_level() const {
457  return _quality_level;
458 }
459 
460 ////////////////////////////////////////////////////////////////////
461 // Function: EggTexture::set_stage_name
462 // Access: Published
463 // Description: Specifies the particular TextureStage this texture
464 // will be rendered on by name. If this is omitted, the
465 // texture will be rendered on the default TextureStage,
466 // unless some other stage-specific property is
467 // specificied, in which case the texture will be
468 // rendered on a TextureStage with the same name as the
469 // tref. This is in support of multitexturing.
470 //
471 // Each different TextureStage in the world must be
472 // uniquely named.
473 ////////////////////////////////////////////////////////////////////
474 INLINE void EggTexture::
475 set_stage_name(const string &stage_name) {
476  _stage_name = stage_name;
477  _flags |= F_has_stage_name;
478 }
479 
480 ////////////////////////////////////////////////////////////////////
481 // Function: EggTexture::clear_stage_name
482 // Access: Published
483 // Description: Removes the named TextureStage specification.
484 ////////////////////////////////////////////////////////////////////
485 INLINE void EggTexture::
487  _stage_name = string();
488  _flags &= ~F_has_stage_name;
489 }
490 
491 ////////////////////////////////////////////////////////////////////
492 // Function: EggTexture::has_stage_name
493 // Access: Published
494 // Description: Returns true if a stage name has been explicitly
495 // specified for this texture, false otherwise.
496 ////////////////////////////////////////////////////////////////////
497 INLINE bool EggTexture::
498 has_stage_name() const {
499  return (_flags & F_has_stage_name) != 0;
500 }
501 
502 ////////////////////////////////////////////////////////////////////
503 // Function: EggTexture::get_stage_name
504 // Access: Published
505 // Description: Returns the stage name that has been specified for
506 // this texture, or the tref name if no texture stage
507 // has explicitly been specified.
508 ////////////////////////////////////////////////////////////////////
509 INLINE const string &EggTexture::
510 get_stage_name() const {
511  return has_stage_name() ? _stage_name : get_name();
512 }
513 
514 ////////////////////////////////////////////////////////////////////
515 // Function: EggTexture::set_priority
516 // Access: Published
517 // Description: Sets the importance of this texture with respect to
518 // other textures also applied on the same geometry.
519 // This is only meaningful in the presence of
520 // multitexturing.
521 ////////////////////////////////////////////////////////////////////
522 INLINE void EggTexture::
523 set_priority(int priority) {
524  _priority = priority;
525  _flags |= F_has_priority;
526 }
527 
528 ////////////////////////////////////////////////////////////////////
529 // Function: EggTexture::clear_priority
530 // Access: Published
531 // Description: Removes the specification of multitexture priority
532 // from the texture. The default priority value is 0.
533 ////////////////////////////////////////////////////////////////////
534 INLINE void EggTexture::
536  _priority = 0;
537  _flags &= ~F_has_priority;
538 }
539 
540 ////////////////////////////////////////////////////////////////////
541 // Function: EggTexture::has_priority
542 // Access: Published
543 // Description: Returns true if a priority value for multitexture
544 // importance has been specified for the texture, false
545 // otherwise.
546 ////////////////////////////////////////////////////////////////////
547 INLINE bool EggTexture::
548 has_priority() const {
549  return (_flags & F_has_priority) != 0;
550 }
551 
552 ////////////////////////////////////////////////////////////////////
553 // Function: EggTexture::get_priority
554 // Access: Published
555 // Description: Returns the multitexture importance value that has been
556 // specified for the texture, or 0 if no priority value has
557 // been specified.
558 ////////////////////////////////////////////////////////////////////
559 INLINE int EggTexture::
560 get_priority() const {
561  return _priority;
562 }
563 
564 ////////////////////////////////////////////////////////////////////
565 // Function: EggTexture::set_color
566 // Access: Published
567 // Description:
568 ////////////////////////////////////////////////////////////////////
569 INLINE void EggTexture::
570 set_color(const LColor &color) {
571  _color = color;
572  _flags |= F_has_color;
573 }
574 
575 ////////////////////////////////////////////////////////////////////
576 // Function: EggTexture::clear_color
577 // Access: Published
578 // Description:
579 ////////////////////////////////////////////////////////////////////
580 INLINE void EggTexture::
581 clear_color() {
582  _color.set(0.0f, 0.0f, 0.0f, 1.0f);
583  _flags &= ~F_has_color;
584 }
585 
586 ////////////////////////////////////////////////////////////////////
587 // Function: EggTexture::has_color
588 // Access: Published
589 // Description: Returns true if a blend color has been
590 // specified for the texture.
591 ////////////////////////////////////////////////////////////////////
592 INLINE bool EggTexture::
593 has_color() const {
594  return (_flags & F_has_color) != 0;
595 }
596 
597 ////////////////////////////////////////////////////////////////////
598 // Function: EggTexture::get_color
599 // Access: Published
600 // Description: Returns the blend color if one has been
601 // specified, or (0, 0, 0, 1) otherwise.
602 ////////////////////////////////////////////////////////////////////
603 INLINE const LColor &EggTexture::
604 get_color() const {
605  return _color;
606 }
607 
608 ////////////////////////////////////////////////////////////////////
609 // Function: EggTexture::set_border_color
610 // Access: Published
611 // Description:
612 ////////////////////////////////////////////////////////////////////
613 INLINE void EggTexture::
614 set_border_color(const LColor &border_color) {
615  _border_color = border_color;
616  _flags |= F_has_border_color;
617 }
618 
619 ////////////////////////////////////////////////////////////////////
620 // Function: EggTexture::clear_border_color
621 // Access: Published
622 // Description:
623 ////////////////////////////////////////////////////////////////////
624 INLINE void EggTexture::
625 clear_border_color() {
626  _border_color.set(0.0f, 0.0f, 0.0f, 1.0f);
627  _flags &= ~F_has_border_color;
628 }
629 
630 ////////////////////////////////////////////////////////////////////
631 // Function: EggTexture::has_border_color
632 // Access: Published
633 // Description: Returns true if a border color has been
634 // specified for the texture.
635 ////////////////////////////////////////////////////////////////////
636 INLINE bool EggTexture::
638  return (_flags & F_has_border_color) != 0;
639 }
640 
641 ////////////////////////////////////////////////////////////////////
642 // Function: EggTexture::get_border_color
643 // Access: Published
644 // Description: Returns the border color if one has been
645 // specified, or (0, 0, 0, 1) otherwise.
646 ////////////////////////////////////////////////////////////////////
647 INLINE const LColor &EggTexture::
649  return _border_color;
650 }
651 
652 ////////////////////////////////////////////////////////////////////
653 // Function: EggTexture::set_uv_name
654 // Access: Published
655 // Description: Specifies the named set of texture coordinates that
656 // this texture will use when it is applied to geometry.
657 // Geometry may have multiple sets of texture
658 // coordinates defined, by name.
659 //
660 // If this is not specified for a particular texture,
661 // the default set of texture coordinates will be used.
662 ////////////////////////////////////////////////////////////////////
663 INLINE void EggTexture::
664 set_uv_name(const string &uv_name) {
665  if (uv_name == "default" || uv_name.empty()) {
666  clear_uv_name();
667  } else {
668  _uv_name = uv_name;
669  _flags |= F_has_uv_name;
670  }
671 }
672 
673 ////////////////////////////////////////////////////////////////////
674 // Function: EggTexture::clear_uv_name
675 // Access: Published
676 // Description: Removes the restriction to a particular named set of
677 // texture coordinates and restores the texture to using
678 // the default texture coordinates.
679 ////////////////////////////////////////////////////////////////////
680 INLINE void EggTexture::
682  _uv_name = string();
683  _flags &= ~F_has_uv_name;
684 }
685 
686 ////////////////////////////////////////////////////////////////////
687 // Function: EggTexture::has_uv_name
688 // Access: Published
689 // Description: Returns true if a texcoord name has been explicitly
690 // specified for this texture, false otherwise.
691 ////////////////////////////////////////////////////////////////////
692 INLINE bool EggTexture::
693 has_uv_name() const {
694  return (_flags & F_has_uv_name) != 0;
695 }
696 
697 ////////////////////////////////////////////////////////////////////
698 // Function: EggTexture::get_uv_name
699 // Access: Published
700 // Description: Returns the texcoord name that has been specified for
701 // this texture, or the empty string if no texcoord name
702 // has explicitly been specified.
703 ////////////////////////////////////////////////////////////////////
704 INLINE const string &EggTexture::
705 get_uv_name() const {
706  return _uv_name;
707 }
708 
709 ////////////////////////////////////////////////////////////////////
710 // Function: EggTexture::set_rgb_scale
711 // Access: Published
712 // Description: Sets an additional factor that will scale all three
713 // r, g, b components after the texture has been
714 // applied. This is used only when a combine mode is in
715 // effect.
716 //
717 // The only legal values are 1, 2, or 4.
718 ////////////////////////////////////////////////////////////////////
719 INLINE void EggTexture::
720 set_rgb_scale(int rgb_scale) {
721  _rgb_scale = rgb_scale;
722  _flags |= F_has_rgb_scale;
723 }
724 
725 ////////////////////////////////////////////////////////////////////
726 // Function: EggTexture::clear_rgb_scale
727 // Access: Published
728 // Description: Removes the rgb_scale from the texture and restores
729 // it to the default value of 1.
730 ////////////////////////////////////////////////////////////////////
731 INLINE void EggTexture::
733  _rgb_scale = 1;
734  _flags &= ~F_has_rgb_scale;
735 }
736 
737 ////////////////////////////////////////////////////////////////////
738 // Function: EggTexture::has_rgb_scale
739 // Access: Published
740 // Description: Returns true if an rgb_scale has been specified for
741 // the texture, false otherwise.
742 ////////////////////////////////////////////////////////////////////
743 INLINE bool EggTexture::
744 has_rgb_scale() const {
745  return (_flags & F_has_rgb_scale) != 0;
746 }
747 
748 ////////////////////////////////////////////////////////////////////
749 // Function: EggTexture::get_rgb_scale
750 // Access: Published
751 // Description: Returns the rgb_scale value that has been
752 // specified for the texture, or 1 if no rgb_scale value
753 // has been specified.
754 ////////////////////////////////////////////////////////////////////
755 INLINE int EggTexture::
756 get_rgb_scale() const {
757  return _rgb_scale;
758 }
759 
760 ////////////////////////////////////////////////////////////////////
761 // Function: EggTexture::set_alpha_scale
762 // Access: Published
763 // Description: Sets an additional factor that will scale the
764 // alpha component after the texture has been applied.
765 // This is used only when a combine mode is in effect.
766 //
767 // The only legal values are 1, 2, or 4.
768 ////////////////////////////////////////////////////////////////////
769 INLINE void EggTexture::
770 set_alpha_scale(int alpha_scale) {
771  _alpha_scale = alpha_scale;
772  _flags |= F_has_alpha_scale;
773 }
774 
775 ////////////////////////////////////////////////////////////////////
776 // Function: EggTexture::clear_alpha_scale
777 // Access: Published
778 // Description: Removes the alpha_scale from the texture and restores
779 // it to the default value of 1.
780 ////////////////////////////////////////////////////////////////////
781 INLINE void EggTexture::
783  _alpha_scale = 1;
784  _flags &= ~F_has_alpha_scale;
785 }
786 
787 ////////////////////////////////////////////////////////////////////
788 // Function: EggTexture::has_alpha_scale
789 // Access: Published
790 // Description: Returns true if an alpha_scale has been specified for
791 // the texture, false otherwise.
792 ////////////////////////////////////////////////////////////////////
793 INLINE bool EggTexture::
795  return (_flags & F_has_alpha_scale) != 0;
796 }
797 
798 ////////////////////////////////////////////////////////////////////
799 // Function: EggTexture::get_alpha_scale
800 // Access: Published
801 // Description: Returns the alpha_scale value that has been
802 // specified for the texture, or 1 if no alpha_scale
803 // value has been specified.
804 ////////////////////////////////////////////////////////////////////
805 INLINE int EggTexture::
807  return _alpha_scale;
808 }
809 
810 ////////////////////////////////////////////////////////////////////
811 // Function: EggTexture::set_alpha_filename
812 // Access: Published
813 // Description: Specifies a separate file that will be loaded in with
814 // the 1- or 3-component texture and applied as the
815 // alpha channel. This is useful when loading textures
816 // from file formats that do not support alpha, for
817 // instance jpg.
818 ////////////////////////////////////////////////////////////////////
819 INLINE void EggTexture::
820 set_alpha_filename(const Filename &alpha_filename) {
821  _alpha_filename = alpha_filename;
822  _alpha_fullpath = alpha_filename;
823  _flags |= F_has_alpha_filename;
824 }
825 
826 ////////////////////////////////////////////////////////////////////
827 // Function: EggTexture::clear_alpha_filename
828 // Access: Published
829 // Description:
830 ////////////////////////////////////////////////////////////////////
831 INLINE void EggTexture::
832 clear_alpha_filename() {
833  _alpha_filename = Filename();
834  _alpha_fullpath = Filename();
835  _flags &= ~F_has_alpha_filename;
836 }
837 
838 ////////////////////////////////////////////////////////////////////
839 // Function: EggTexture::has_alpha_filename
840 // Access: Published
841 // Description: Returns true if a separate file for the alpha
842 // component has been applied, false otherwise. See
843 // set_alpha_filename().
844 ////////////////////////////////////////////////////////////////////
845 INLINE bool EggTexture::
847  return (_flags & F_has_alpha_filename) != 0;
848 }
849 
850 ////////////////////////////////////////////////////////////////////
851 // Function: EggTexture::get_alpha_filename
852 // Access: Published
853 // Description: Returns the separate file assigned for the alpha
854 // channel. It is an error to call this unless
855 // has_alpha_filename() returns true. See set_alpha_filename().
856 ////////////////////////////////////////////////////////////////////
857 INLINE const Filename &EggTexture::
859  nassertr(has_alpha_filename(), _alpha_filename);
860  return _alpha_filename;
861 }
862 
863 ////////////////////////////////////////////////////////////////////
864 // Function: EggTexture::get_alpha_fullpath
865 // Access: Published
866 // Description: Returns the full pathname to the alpha file, if it is
867 // known; otherwise, returns the same thing as
868 // get_alpha_filename().
869 //
870 // This function simply returns whatever was set by the
871 // last call to set_alpha_fullpath(). This string is
872 // not written to the egg file; its main purpose is to
873 // record the full path to the alpha filename if it is
874 // known, for egg structures that are generated
875 // in-memory and then immediately converted to a scene
876 // graph.
877 ////////////////////////////////////////////////////////////////////
878 INLINE const Filename &EggTexture::
880  return _alpha_fullpath;
881 }
882 
883 ////////////////////////////////////////////////////////////////////
884 // Function: EggTexture::set_alpha_fullpath
885 // Access: Published
886 // Description: Records the full pathname to the file, for the
887 // benefit of get_alpha_fullpath().
888 ////////////////////////////////////////////////////////////////////
889 INLINE void EggTexture::
890 set_alpha_fullpath(const Filename &alpha_fullpath) {
891  _alpha_fullpath = alpha_fullpath;
892 }
893 
894 ////////////////////////////////////////////////////////////////////
895 // Function: EggTexture::set_alpha_file_channel
896 // Access: Published
897 // Description: If a separate alpha-file is specified, this indicates
898 // which channel number should be extracted from this
899 // file to derive the alpha channel for the final image.
900 // The default is 0, which means the grayscale
901 // combination of r, g, b. Otherwise, this should be
902 // the 1-based channel number, for instance 1, 2, or 3
903 // for r, g, or b, respectively, or 4 for the alpha
904 // channel of a four-component image.
905 ////////////////////////////////////////////////////////////////////
906 INLINE void EggTexture::
907 set_alpha_file_channel(int alpha_file_channel) {
908  _alpha_file_channel = alpha_file_channel;
909  _flags |= F_has_alpha_file_channel;
910 }
911 
912 ////////////////////////////////////////////////////////////////////
913 // Function: EggTexture::clear_alpha_file_channel
914 // Access: Published
915 // Description: Removes the specification of a particular channel to
916 // use from the alpha-file image.
917 ////////////////////////////////////////////////////////////////////
918 INLINE void EggTexture::
920  _alpha_file_channel = 0;
921  _flags &= ~F_has_alpha_file_channel;
922 }
923 
924 ////////////////////////////////////////////////////////////////////
925 // Function: EggTexture::has_alpha_file_channel
926 // Access: Published
927 // Description: Returns true if a particular channel has been
928 // specified for the alpha-file image, false otherwise.
929 ////////////////////////////////////////////////////////////////////
930 INLINE bool EggTexture::
932  return (_flags & F_has_alpha_file_channel) != 0;
933 }
934 
935 ////////////////////////////////////////////////////////////////////
936 // Function: EggTexture::get_alpha_file_channel
937 // Access: Published
938 // Description: Returns the particular channel that has been
939 // specified for the alpha-file image, or 0 if no
940 // channel has been specified. See
941 // set_alpha_file_channel().
942 ////////////////////////////////////////////////////////////////////
943 INLINE int EggTexture::
945  return _alpha_file_channel;
946 }
947 
948 ////////////////////////////////////////////////////////////////////
949 // Function: EggTexture::set_multiview
950 // Access: Published
951 // Description: Sets the multiview flag.
952 //
953 // If multiview is true, the filename should contain a
954 // hash mark ('#'), which will be filled in with the
955 // view number; and a multiview texture will be defined
956 // with a series of images, one for each view.
957 //
958 // A multiview texture is most often used for stereo
959 // textures, but other uses are also possible, such as
960 // for texture animation.
961 ////////////////////////////////////////////////////////////////////
962 INLINE void EggTexture::
963 set_multiview(bool multiview) {
964  _multiview = multiview;
965 }
966 
967 ////////////////////////////////////////////////////////////////////
968 // Function: EggTexture::get_multiview
969 // Access: Published
970 // Description: Returns the current setting of the multiview flag.
971 // See set_multiview().
972 ////////////////////////////////////////////////////////////////////
973 INLINE bool EggTexture::
974 get_multiview() const {
975  return _multiview;
976 }
977 
978 ////////////////////////////////////////////////////////////////////
979 // Function: EggTexture::set_num_views
980 // Access: Published
981 // Description: When loading a 3-D multiview texture, this parameter
982 // is necessary to specify how many views will be
983 // expected. The z size is determined implicitly from
984 // the number of images loaded.
985 ////////////////////////////////////////////////////////////////////
986 INLINE void EggTexture::
987 set_num_views(int num_views) {
988  _num_views = num_views;
989  _flags |= F_has_num_views;
990 }
991 
992 ////////////////////////////////////////////////////////////////////
993 // Function: EggTexture::clear_num_views
994 // Access: Published
995 // Description: Removes the specification of the number of views
996 // for a 3-D multiview texture.
997 ////////////////////////////////////////////////////////////////////
998 INLINE void EggTexture::
1000  _num_views = 0;
1001  _flags &= ~F_has_num_views;
1002 }
1003 
1004 ////////////////////////////////////////////////////////////////////
1005 // Function: EggTexture::has_num_views
1006 // Access: Published
1007 // Description: Returns true if the number of views has been
1008 // specified for the 3-D multiview texture, false
1009 // otherwise.
1010 ////////////////////////////////////////////////////////////////////
1011 INLINE bool EggTexture::
1012 has_num_views() const {
1013  return (_flags & F_has_num_views) != 0;
1014 }
1015 
1016 ////////////////////////////////////////////////////////////////////
1017 // Function: EggTexture::get_num_views
1018 // Access: Published
1019 // Description: Returns the specified number of views specified for
1020 // the 3-D multiview texture. See set_num_views().
1021 ////////////////////////////////////////////////////////////////////
1022 INLINE int EggTexture::
1023 get_num_views() const {
1024  return _num_views;
1025 }
1026 
1027 ////////////////////////////////////////////////////////////////////
1028 // Function: EggTexture::set_read_mipmaps
1029 // Access: Published
1030 // Description: Sets the read_mipmaps flag.
1031 //
1032 // If read_mipmaps is true, the filename should contain
1033 // a hash mark ('#'), which will be filled in with the
1034 // mipmap level number; and the texture will be defined
1035 // with a series of images, one for each mipmap level.
1036 //
1037 // If the filename is of a type that already requires a
1038 // hash mark, such as a cube map or a 3-d texture, then
1039 // the filename should now require two hash marks, and
1040 // the first one indicates the mipmap level number,
1041 // while the second indicates the face number or 3-d
1042 // level number.
1043 ////////////////////////////////////////////////////////////////////
1044 INLINE void EggTexture::
1045 set_read_mipmaps(bool read_mipmaps) {
1046  _read_mipmaps = read_mipmaps;
1047 }
1048 
1049 ////////////////////////////////////////////////////////////////////
1050 // Function: EggTexture::get_read_mipmaps
1051 // Access: Published
1052 // Description: Returns the current setting of the read_mipmaps flag.
1053 // See set_read_mipmaps().
1054 ////////////////////////////////////////////////////////////////////
1055 INLINE bool EggTexture::
1057  return _read_mipmaps;
1058 }
1059 
1060 ////////////////////////////////////////////////////////////////////
1061 // Function: EggTexture::get_multitexture_sort
1062 // Access: Published
1063 // Description: Returns an integer that represents the depth to which
1064 // this texture is layered on all other textures in the
1065 // egg file. In general, if texture A is layered over
1066 // texture B, then sort(A) > sort(B). If texture A is
1067 // never layered over any other texture, then sort(A) ==
1068 // 0. More than that is difficult to guarantee.
1069 ////////////////////////////////////////////////////////////////////
1070 INLINE int EggTexture::
1072  return _multitexture_sort;
1073 }
1074 
1075 ////////////////////////////////////////////////////////////////////
1076 // Function: EggTexture::SourceAndOperand::Constructor
1077 // Access: Public
1078 // Description:
1079 ////////////////////////////////////////////////////////////////////
1080 INLINE EggTexture::SourceAndOperand::
1081 SourceAndOperand() :
1082  _source(CS_unspecified),
1083  _operand(CO_unspecified)
1084 {
1085 }
1086 
1087 ////////////////////////////////////////////////////////////////////
1088 // Function: EggTexture::Combiner::Constructor
1089 // Access: Public
1090 // Description:
1091 ////////////////////////////////////////////////////////////////////
1092 INLINE EggTexture::Combiner::
1093 Combiner() :
1094  _mode(CM_unspecified)
1095 {
1096 }
1097 
1098 ////////////////////////////////////////////////////////////////////
1099 // Function: UniqueEggTextures::Constructor
1100 // Access: Published
1101 // Description:
1102 ////////////////////////////////////////////////////////////////////
1103 INLINE UniqueEggTextures::
1104 UniqueEggTextures(int eq) : _eq(eq) {
1105 }
1106 
1107 ////////////////////////////////////////////////////////////////////
1108 // Function: UniqueEggTextures::Function operator
1109 // Access: Published
1110 // Description:
1111 ////////////////////////////////////////////////////////////////////
1112 INLINE bool UniqueEggTextures::
1113 operator ()(const EggTexture *t1, const EggTexture *t2) const {
1114  return t1->sorts_less_than(*t2, _eq);
1115 }
1116 
bool has_color() const
Returns true if a blend color has been specified for the texture.
Definition: eggTexture.I:593
const LColor & get_border_color() const
Returns the border color if one has been specified, or (0, 0, 0, 1) otherwise.
Definition: eggTexture.I:648
void set_stage_name(const string &stage_name)
Specifies the particular TextureStage this texture will be rendered on by name.
Definition: eggTexture.I:475
bool has_alpha_scale() const
Returns true if an alpha_scale has been specified for the texture, false otherwise.
Definition: eggTexture.I:794
bool has_num_views() const
Returns true if the number of views has been specified for the 3-D multiview texture, false otherwise.
Definition: eggTexture.I:1012
void set_alpha_file_channel(int alpha_file_channel)
If a separate alpha-file is specified, this indicates which channel number should be extracted from t...
Definition: eggTexture.I:907
int get_rgb_scale() const
Returns the rgb_scale value that has been specified for the texture, or 1 if no rgb_scale value has b...
Definition: eggTexture.I:756
bool get_read_mipmaps() const
Returns the current setting of the read_mipmaps flag.
Definition: eggTexture.I:1056
void set_multiview(bool multiview)
Sets the multiview flag.
Definition: eggTexture.I:963
int get_alpha_file_channel() const
Returns the particular channel that has been specified for the alpha-file image, or 0 if no channel h...
Definition: eggTexture.I:944
Defines a texture map that may be applied to geometry.
Definition: eggTexture.h:33
void clear_priority()
Removes the specification of multitexture priority from the texture.
Definition: eggTexture.I:535
void set_alpha_fullpath(const Filename &fullpath)
Records the full pathname to the file, for the benefit of get_alpha_fullpath().
Definition: eggTexture.I:890
bool has_stage_name() const
Returns true if a stage name has been explicitly specified for this texture, false otherwise...
Definition: eggTexture.I:498
void set_alpha_filename(const Filename &filename)
Specifies a separate file that will be loaded in with the 1- or 3-component texture and applied as th...
Definition: eggTexture.I:820
int get_priority() const
Returns the multitexture importance value that has been specified for the texture, or 0 if no priority value has been specified.
Definition: eggTexture.I:560
WrapMode determine_wrap_w() const
Determines the appropriate wrap in the W direction.
Definition: eggTexture.I:200
const string & get_uv_name() const
Returns the texcoord name that has been specified for this texture, or the empty string if no texcoor...
Definition: eggTexture.I:705
void set_read_mipmaps(bool read_mipmaps)
Sets the read_mipmaps flag.
Definition: eggTexture.I:1045
WrapMode determine_wrap_v() const
Determines the appropriate wrap in the V direction.
Definition: eggTexture.I:166
void set_anisotropic_degree(int anisotropic_degree)
Sets the degree of anisotropic filtering for this texture.
Definition: eggTexture.I:252
bool has_rgb_scale() const
Returns true if an rgb_scale has been specified for the texture, false otherwise. ...
Definition: eggTexture.I:744
int get_num_views() const
Returns the specified number of views specified for the 3-D multiview texture.
Definition: eggTexture.I:1023
const string & get_stage_name() const
Returns the stage name that has been specified for this texture, or the tref name if no texture stage...
Definition: eggTexture.I:510
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
void clear_num_views()
Removes the specification of the number of views for a 3-D multiview texture.
Definition: eggTexture.I:999
const Filename & get_alpha_filename() const
Returns the separate file assigned for the alpha channel.
Definition: eggTexture.I:858
WrapMode get_wrap_v() const
Returns the amount specified for V wrap.
Definition: eggTexture.I:153
WrapMode get_wrap_w() const
Returns the amount specified for W wrap.
Definition: eggTexture.I:187
void set_uv_name(const string &uv_name)
Specifies the named set of texture coordinates that this texture will use when it is applied to geome...
Definition: eggTexture.I:664
bool sorts_less_than(const EggTexture &other, int eq) const
An ordering operator to compare two textures for sorting order.
Definition: eggTexture.cxx:429
void clear_alpha_scale()
Removes the alpha_scale from the texture and restores it to the default value of 1.
Definition: eggTexture.I:782
int get_alpha_scale() const
Returns the alpha_scale value that has been specified for the texture, or 1 if no alpha_scale value h...
Definition: eggTexture.I:806
void clear_alpha_file_channel()
Removes the specification of a particular channel to use from the alpha-file image.
Definition: eggTexture.I:919
bool get_saved_result() const
Returns the current setting of the saved_result flag.
Definition: eggTexture.I:416
const LColor & get_color() const
Returns the blend color if one has been specified, or (0, 0, 0, 1) otherwise.
Definition: eggTexture.I:604
void clear_rgb_scale()
Removes the rgb_scale from the texture and restores it to the default value of 1. ...
Definition: eggTexture.I:732
bool has_alpha_file_channel() const
Returns true if a particular channel has been specified for the alpha-file image, false otherwise...
Definition: eggTexture.I:931
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
void clear_anisotropic_degree()
Removes the specification of anisotropic filtering from the texture.
Definition: eggTexture.I:264
bool has_priority() const
Returns true if a priority value for multitexture importance has been specified for the texture...
Definition: eggTexture.I:548
int get_anisotropic_degree() const
Returns the anisotropic filtering degree that has been specified for this texture, or 0 if nothing has been specified.
Definition: eggTexture.I:289
const Filename & get_alpha_fullpath() const
Returns the full pathname to the alpha file, if it is known; otherwise, returns the same thing as get...
Definition: eggTexture.I:879
void set_priority(int priority)
Sets the importance of this texture with respect to other textures also applied on the same geometry...
Definition: eggTexture.I:523
void set_rgb_scale(int rgb_scale)
Sets an additional factor that will scale all three r, g, b components after the texture has been app...
Definition: eggTexture.I:720
WrapMode determine_wrap_u() const
Determines the appropriate wrap in the U direction.
Definition: eggTexture.I:132
bool get_multiview() const
Returns the current setting of the multiview flag.
Definition: eggTexture.I:974
WrapMode get_wrap_u() const
Returns the amount specified for U wrap.
Definition: eggTexture.I:119
void clear_uv_name()
Removes the restriction to a particular named set of texture coordinates and restores the texture to ...
Definition: eggTexture.I:681
bool has_border_color() const
Returns true if a border color has been specified for the texture.
Definition: eggTexture.I:637
void set_alpha_scale(int alpha_scale)
Sets an additional factor that will scale the alpha component after the texture has been applied...
Definition: eggTexture.I:770
bool has_anisotropic_degree() const
Returns true if a value for the anisotropic filtering degree has been specified for this texture...
Definition: eggTexture.I:277
void set_saved_result(bool saved_result)
Sets the saved_result flag.
Definition: eggTexture.I:405
void set_num_views(int num_views)
When loading a 3-D multiview texture, this parameter is necessary to specify how many views will be e...
Definition: eggTexture.I:987
int get_multitexture_sort() const
Returns an integer that represents the depth to which this texture is layered on all other textures i...
Definition: eggTexture.I:1071
bool has_uv_name() const
Returns true if a texcoord name has been explicitly specified for this texture, false otherwise...
Definition: eggTexture.I:693
void clear_stage_name()
Removes the named TextureStage specification.
Definition: eggTexture.I:486
bool has_alpha_filename() const
Returns true if a separate file for the alpha component has been applied, false otherwise.
Definition: eggTexture.I:846