Panda3D
textureStage.I
1 // Filename: textureStage.I
2 // Created by: masad (15Jul04)
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: TextureStage::Copy Constructor
18 // Access: Published
19 // Description: Initialize the texture stage from other
20 ////////////////////////////////////////////////////////////////////
21 INLINE TextureStage::
23  (*this) = copy;
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: TextureStage::get_name
28 // Access: Published
29 // Description: Returns the name of this texture stage
30 ////////////////////////////////////////////////////////////////////
31 INLINE const string &TextureStage::
32 get_name() const {
33  return _name;
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: TextureStage::set_name
38 // Access: Published
39 // Description: Changes the name of this texture stage
40 ////////////////////////////////////////////////////////////////////
41 INLINE void TextureStage::
42 set_name(const string &name) {
43  _name = name;
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: TextureStage::set_sort
48 // Access: Published
49 // Description: Changes the order in which the texture associated
50 // with this stage is rendered relative to the other
51 // texture stages. When geometry is rendered with
52 // multiple textures, the textures are rendered in order
53 // from the lowest sort number to the highest sort
54 // number.
55 //
56 // Also see set_priority(), which is used to select the
57 // most important textures for rendering when some must
58 // be omitted because of hardware limitations.
59 ////////////////////////////////////////////////////////////////////
60 INLINE void TextureStage::
61 set_sort(int sort) {
62  _sort = sort;
63 
64  // Update the global flag to indicate that all TextureAttribs in the
65  // world must now re-sort their lists.
66  _sort_seq++;
67 }
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: TextureStage::get_sort
71 // Access: Published
72 // Description: Returns the sort order of this texture stage.
73 ////////////////////////////////////////////////////////////////////
74 INLINE int TextureStage::
75 get_sort() const {
76  return _sort;
77 }
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: TextureStage::set_priority
81 // Access: Published
82 // Description: Changes the relative importance of the texture
83 // associated with this stage relative to the other
84 // texture stages that are applied simultaneously.
85 //
86 // This is unrelated to set_sort(), which controls the
87 // order in which multiple textures are applied. The
88 // priority number is used to decide which of the
89 // requested textures are to be selected for rendering
90 // when more textures are requested than the hardware
91 // will support. The highest-priority n textures are
92 // selected for rendering, and then rendered in order by
93 // their sort factor.
94 ////////////////////////////////////////////////////////////////////
95 INLINE void TextureStage::
96 set_priority(int priority) {
97  _priority = priority;
98 
99  // Update the global flag to indicate that all TextureAttribs in the
100  // world must now re-sort their lists.
101  _sort_seq++;
102 }
103 
104 ////////////////////////////////////////////////////////////////////
105 // Function: TextureStage::get_priority
106 // Access: Published
107 // Description: Returns the priority associated with this stage.
108 //
109 // This is specially helpful for cards that do not
110 // support more than n stages of multi-texturing.
111 ////////////////////////////////////////////////////////////////////
112 INLINE int TextureStage::
113 get_priority() const {
114  return _priority;
115 }
116 
117 ////////////////////////////////////////////////////////////////////
118 // Function: TextureStage::set_texcoord_name
119 // Access: Published
120 // Description: Indicate which set of UV's this texture stage will
121 // use. Geometry may have any number of associated UV
122 // sets, each of which must have a unique name.
123 ////////////////////////////////////////////////////////////////////
124 INLINE void TextureStage::
125 set_texcoord_name(InternalName *name) {
126  _texcoord_name = name;
127 }
128 
129 ////////////////////////////////////////////////////////////////////
130 // Function: TextureStage::set_texcoord_name
131 // Access: Published
132 // Description: Indicate which set of UV's this texture stage will
133 // use. Geometry may have any number of associated UV
134 // sets, each of which must have a unique name.
135 ////////////////////////////////////////////////////////////////////
136 INLINE void TextureStage::
137 set_texcoord_name(const string &name) {
138  _texcoord_name = InternalName::get_texcoord_name(name);
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: TextureStage::get_texcoord_name
143 // Access: Published
144 // Description: See set_texcoord_name. The default is
145 // InternalName::get_texcoord().
146 ////////////////////////////////////////////////////////////////////
147 INLINE InternalName *TextureStage::
149  return _texcoord_name;
150 }
151 
152 ////////////////////////////////////////////////////////////////////
153 // Function: TextureStage::get_tangent_name
154 // Access: Published
155 // Description: Returns the set of tangents this texture stage will
156 // use. This is the same as get_texcoord_name(),
157 // except that the first part is "tangent".
158 ////////////////////////////////////////////////////////////////////
159 INLINE InternalName *TextureStage::
161  if (_texcoord_name->get_parent() == NULL) {
162  return InternalName::get_tangent();
163  } else {
164  return InternalName::get_tangent_name(_texcoord_name->get_basename());
165  }
166 }
167 
168 ////////////////////////////////////////////////////////////////////
169 // Function: TextureStage::get_binormal_name
170 // Access: Published
171 // Description: Returns the set of binormals this texture stage will
172 // use. This is the same as get_binormal_name(),
173 // except that the first part is "binormal".
174 ////////////////////////////////////////////////////////////////////
175 INLINE InternalName *TextureStage::
177  if (_texcoord_name->get_parent() == NULL) {
178  return InternalName::get_binormal();
179  } else {
180  return InternalName::get_binormal_name(_texcoord_name->get_basename());
181  }
182 }
183 
184 ////////////////////////////////////////////////////////////////////
185 // Function: TextureStage::set_mode
186 // Access: Published
187 // Description: Set the mode of this texture stage
188 ////////////////////////////////////////////////////////////////////
189 INLINE void TextureStage::
190 set_mode(TextureStage::Mode mode) {
191  _mode = mode;
192 
193  if (_mode != M_combine) {
194  _num_combine_rgb_operands = 0;
195  _num_combine_alpha_operands = 0;
196  }
197  update_color_flags();
198 }
199 
200 ////////////////////////////////////////////////////////////////////
201 // Function: TextureStage::get_mode
202 // Access: Published
203 // Description: Return the mode of this stage
204 ////////////////////////////////////////////////////////////////////
205 INLINE TextureStage::Mode TextureStage::
206 get_mode() const {
207  return _mode;
208 }
209 
210 ////////////////////////////////////////////////////////////////////
211 // Function: TextureStage::is_fixed_function
212 // Access: Published
213 // Description: Returns true if the TextureStage is relevant to
214 // the classic fixed function pipeline. This excludes
215 // texture stages such as normal mapping and the like.
216 ////////////////////////////////////////////////////////////////////
217 INLINE bool TextureStage::
219  return (_mode < M_normal);
220 }
221 
222 ////////////////////////////////////////////////////////////////////
223 // Function: TextureStage::set_color
224 // Access: Published
225 // Description: Set the color for this stage
226 ////////////////////////////////////////////////////////////////////
227 INLINE void TextureStage::
229  _color = color;
230 }
231 
232 ////////////////////////////////////////////////////////////////////
233 // Function: TextureStage::get_color
234 // Access: Published
235 // Description: return the color for this stage
236 ////////////////////////////////////////////////////////////////////
237 INLINE LColor TextureStage::
238 get_color() const {
239  return _color;
240 }
241 
242 ////////////////////////////////////////////////////////////////////
243 // Function: TextureStage::set_rgb_scale
244 // Access: Published
245 // Description: Sets an additional factor that will scale all three
246 // r, g, b components after the texture has been
247 // applied. This is used only when the mode is
248 // CM_combine.
249 //
250 // The only legal values are 1, 2, or 4.
251 ////////////////////////////////////////////////////////////////////
252 INLINE void TextureStage::
253 set_rgb_scale(int rgb_scale) {
254  nassertv(rgb_scale == 1 || rgb_scale == 2 || rgb_scale == 4);
255  _rgb_scale = rgb_scale;
256 }
257 
258 ////////////////////////////////////////////////////////////////////
259 // Function: TextureStage::get_rgb_scale
260 // Access: Published
261 // Description: See set_rgb_scale().
262 ////////////////////////////////////////////////////////////////////
263 INLINE int TextureStage::
264 get_rgb_scale() const {
265  return _rgb_scale;
266 }
267 
268 ////////////////////////////////////////////////////////////////////
269 // Function: TextureStage::set_alpha_scale
270 // Access: Published
271 // Description: Sets an additional factor that will scale the
272 // alpha component after the texture has been applied.
273 // This is used only when the mode is CM_combine.
274 //
275 // The only legal values are 1, 2, or 4.
276 ////////////////////////////////////////////////////////////////////
277 INLINE void TextureStage::
278 set_alpha_scale(int alpha_scale) {
279  nassertv(alpha_scale == 1 || alpha_scale == 2 || alpha_scale == 4);
280  _alpha_scale = alpha_scale;
281 }
282 
283 ////////////////////////////////////////////////////////////////////
284 // Function: TextureStage::get_alpha_scale
285 // Access: Published
286 // Description: See set_alpha_scale().
287 ////////////////////////////////////////////////////////////////////
288 INLINE int TextureStage::
290  return _alpha_scale;
291 }
292 
293 ////////////////////////////////////////////////////////////////////
294 // Function: TextureStage::set_saved_result
295 // Access: Published
296 // Description: Sets the saved_result flag. When this is true, the
297 // output of this stage will be supplied as the
298 // "last_saved_result" source for any future stages,
299 // until the next TextureStage with a saved_result set
300 // true is encountered.
301 //
302 // This can be used to reuse the results of this texture
303 // stage as input to more than one stage later in the
304 // pipeline.
305 //
306 // The last texture in the pipeline (the one with the
307 // highest sort value) should not have this flag set.
308 ////////////////////////////////////////////////////////////////////
309 INLINE void TextureStage::
310 set_saved_result(bool saved_result) {
311  _saved_result = saved_result;
312 }
313 
314 ////////////////////////////////////////////////////////////////////
315 // Function: TextureStage::get_saved_result
316 // Access: Published
317 // Description: Returns the current setting of the saved_result flag.
318 // See set_saved_result().
319 ////////////////////////////////////////////////////////////////////
320 INLINE bool TextureStage::
322  return _saved_result;
323 }
324 
325 ////////////////////////////////////////////////////////////////////
326 // Function: TextureStage::set_tex_view_offset
327 // Access: Published
328 // Description: Sets the tex_view_offset value. This is used only
329 // when a special multiview texture is bound to the
330 // TextureStage, and it selects the particular view of
331 // the texture that is to be used.
332 //
333 // This value is added to the similar parameter on
334 // DisplayRegion to derive the final texture view index
335 // that is selected for rendering.
336 ////////////////////////////////////////////////////////////////////
337 INLINE void TextureStage::
338 set_tex_view_offset(int tex_view_offset) {
339  _tex_view_offset = tex_view_offset;
340 }
341 
342 ////////////////////////////////////////////////////////////////////
343 // Function: TextureStage::get_tex_view_offset
344 // Access: Published
345 // Description: Returns the current setting of the tex_view_offset.
346 // See set_tex_view_offset().
347 ////////////////////////////////////////////////////////////////////
348 INLINE int TextureStage::
350  return _tex_view_offset;
351 }
352 
353 ////////////////////////////////////////////////////////////////////
354 // Function: TextureStage::set_combine_rgb
355 // Access: Published
356 // Description: Specifies any of the CombineMode values that
357 // represent a one-parameter operation. Specifically,
358 // this is CM_replace only.
359 ////////////////////////////////////////////////////////////////////
360 INLINE void TextureStage::
361 set_combine_rgb(CombineMode mode,
362  CombineSource source0, CombineOperand operand0) {
363  nassertv(get_expected_num_combine_operands(mode) == 1);
364  nassertv(operand_valid_for_rgb(operand0));
365  _mode = M_combine;
366  _num_combine_rgb_operands = 1;
367  _combine_rgb_mode = mode;
368  _combine_rgb_source0 = source0;
369  _combine_rgb_operand0 = operand0;
370  _combine_rgb_source1 = CS_undefined;
371  _combine_rgb_operand1 = CO_undefined;
372  _combine_rgb_source2 = CS_undefined;
373  _combine_rgb_operand2 = CO_undefined;
374 
375  update_color_flags();
376 }
377 
378 ////////////////////////////////////////////////////////////////////
379 // Function: TextureStage::set_combine_rgb
380 // Access: Published
381 // Description: Specifies any of the CombineMode values that
382 // represent a two-parameter operation. Specifically,
383 // this is everything except for CM_replace and
384 // CM_interpolate.
385 ////////////////////////////////////////////////////////////////////
386 INLINE void TextureStage::
387 set_combine_rgb(CombineMode mode,
388  CombineSource source0, CombineOperand operand0,
389  CombineSource source1, CombineOperand operand1) {
390  nassertv(get_expected_num_combine_operands(mode) == 2);
391  nassertv(operand_valid_for_rgb(operand0));
392  nassertv(operand_valid_for_rgb(operand1));
393  _mode = M_combine;
394  _num_combine_rgb_operands = 2;
395  _combine_rgb_mode = mode;
396  _combine_rgb_source0 = source0;
397  _combine_rgb_operand0 = operand0;
398  _combine_rgb_source1 = source1;
399  _combine_rgb_operand1 = operand1;
400  _combine_rgb_source2 = CS_undefined;
401  _combine_rgb_operand2 = CO_undefined;
402 
403  update_color_flags();
404 }
405 
406 ////////////////////////////////////////////////////////////////////
407 // Function: TextureStage::set_combine_rgb
408 // Access: Published
409 // Description: Specifies any of the CombineMode values that
410 // represent a one-parameter operation. Specifically,
411 // this is CM_interpolate only.
412 ////////////////////////////////////////////////////////////////////
413 INLINE void TextureStage::
414 set_combine_rgb(CombineMode mode,
415  CombineSource source0, CombineOperand operand0,
416  CombineSource source1, CombineOperand operand1,
417  CombineSource source2, CombineOperand operand2) {
418  nassertv(get_expected_num_combine_operands(mode) == 3);
419  nassertv(operand_valid_for_rgb(operand0));
420  nassertv(operand_valid_for_rgb(operand1));
421  nassertv(operand_valid_for_rgb(operand2));
422  _mode = M_combine;
423  _num_combine_rgb_operands = 3;
424  _combine_rgb_mode = mode;
425  _combine_rgb_source0 = source0;
426  _combine_rgb_operand0 = operand0;
427  _combine_rgb_source1 = source1;
428  _combine_rgb_operand1 = operand1;
429  _combine_rgb_source2 = source2;
430  _combine_rgb_operand2 = operand2;
431 
432  update_color_flags();
433 }
434 
435 ////////////////////////////////////////////////////////////////////
436 // Function: TextureStage::get_combine_rgb_mode
437 // Access: Published
438 // Description: Get the combine_rgb_mode
439 ////////////////////////////////////////////////////////////////////
440 INLINE TextureStage::CombineMode TextureStage::
442  return _combine_rgb_mode;
443 }
444 
445 ////////////////////////////////////////////////////////////////////
446 // Function: TextureStage::get_num_combine_rgb_operands
447 // Access: Published
448 // Description: Returns the number of meaningful operands that may be
449 // retrieved via get_combine_rgb_sourceN() and
450 // get_combine_rgb_operandN().
451 ////////////////////////////////////////////////////////////////////
452 INLINE int TextureStage::
454  return _num_combine_rgb_operands;
455 }
456 
457 ////////////////////////////////////////////////////////////////////
458 // Function: TextureStage::get_combine_rgb_source0
459 // Access: Published
460 // Description: Get source0 of combine_rgb_mode
461 ////////////////////////////////////////////////////////////////////
462 INLINE TextureStage::CombineSource TextureStage::
464  return _combine_rgb_source0;
465 }
466 
467 ////////////////////////////////////////////////////////////////////
468 // Function: TextureStage::get_combine_rgb_operand0
469 // Access: Published
470 // Description: Get operand0 of combine_rgb_mode
471 ////////////////////////////////////////////////////////////////////
472 INLINE TextureStage::CombineOperand TextureStage::
474  return _combine_rgb_operand0;
475 }
476 
477 ////////////////////////////////////////////////////////////////////
478 // Function: TextureStage::get_combine_rgb_source1
479 // Access: Published
480 // Description: Get source1 of combine_rgb_mode
481 ////////////////////////////////////////////////////////////////////
482 INLINE TextureStage::CombineSource TextureStage::
484  return _combine_rgb_source1;
485 }
486 
487 ////////////////////////////////////////////////////////////////////
488 // Function: TextureStage::get_combine_rgb_operand1
489 // Access: Published
490 // Description: Get operand1 of combine_rgb_mode
491 ////////////////////////////////////////////////////////////////////
492 INLINE TextureStage::CombineOperand TextureStage::
494  return _combine_rgb_operand1;
495 }
496 
497 ////////////////////////////////////////////////////////////////////
498 // Function: TextureStage::get_combine_rgb_source2
499 // Access: Published
500 // Description: Get source2 of combine_rgb_mode
501 ////////////////////////////////////////////////////////////////////
502 INLINE TextureStage::CombineSource TextureStage::
504  return _combine_rgb_source2;
505 }
506 
507 ////////////////////////////////////////////////////////////////////
508 // Function: TextureStage::get_combine_rgb_operand2
509 // Access: Published
510 // Description: Get operand2 of combine_rgb_mode
511 ////////////////////////////////////////////////////////////////////
512 INLINE TextureStage::CombineOperand TextureStage::
514  return _combine_rgb_operand2;
515 }
516 
517 ////////////////////////////////////////////////////////////////////
518 // Function: TextureStage::set_combine_alpha
519 // Access: Published
520 // Description: Specifies any of the CombineMode values that
521 // represent a one-parameter operation. Specifically,
522 // this is CM_replace only.
523 ////////////////////////////////////////////////////////////////////
524 INLINE void TextureStage::
525 set_combine_alpha(CombineMode mode,
526  CombineSource source0, CombineOperand operand0) {
527  nassertv(get_expected_num_combine_operands(mode) == 1);
528  nassertv(operand_valid_for_alpha(operand0));
529  _mode = M_combine;
530  _num_combine_alpha_operands = 1;
531  _combine_alpha_mode = mode;
532  _combine_alpha_source0 = source0;
533  _combine_alpha_operand0 = operand0;
534  _combine_alpha_source1 = CS_undefined;
535  _combine_alpha_operand1 = CO_undefined;
536  _combine_alpha_source2 = CS_undefined;
537  _combine_alpha_operand2 = CO_undefined;
538 
539  update_color_flags();
540 }
541 
542 ////////////////////////////////////////////////////////////////////
543 // Function: TextureStage::set_combine_alpha
544 // Access: Published
545 // Description: Specifies any of the CombineMode values that
546 // represent a two-parameter operation. Specifically,
547 // this is everything except for CM_replace and
548 // CM_interpolate.
549 ////////////////////////////////////////////////////////////////////
550 INLINE void TextureStage::
551 set_combine_alpha(CombineMode mode,
552  CombineSource source0, CombineOperand operand0,
553  CombineSource source1, CombineOperand operand1) {
554  nassertv(get_expected_num_combine_operands(mode) == 2);
555  nassertv(operand_valid_for_alpha(operand0));
556  nassertv(operand_valid_for_alpha(operand1));
557  _mode = M_combine;
558  _num_combine_alpha_operands = 2;
559  _combine_alpha_mode = mode;
560  _combine_alpha_source0 = source0;
561  _combine_alpha_operand0 = operand0;
562  _combine_alpha_source1 = source1;
563  _combine_alpha_operand1 = operand1;
564  _combine_alpha_source2 = CS_undefined;
565  _combine_alpha_operand2 = CO_undefined;
566 
567  update_color_flags();
568 }
569 
570 ////////////////////////////////////////////////////////////////////
571 // Function: TextureStage::set_combine_alpha
572 // Access: Published
573 // Description: Specifies any of the CombineMode values that
574 // represent a one-parameter operation. Specifically,
575 // this is CM_interpolate only.
576 ////////////////////////////////////////////////////////////////////
577 INLINE void TextureStage::
578 set_combine_alpha(CombineMode mode,
579  CombineSource source0, CombineOperand operand0,
580  CombineSource source1, CombineOperand operand1,
581  CombineSource source2, CombineOperand operand2) {
582  nassertv(get_expected_num_combine_operands(mode) == 3);
583  nassertv(operand_valid_for_alpha(operand0));
584  nassertv(operand_valid_for_alpha(operand1));
585  nassertv(operand_valid_for_alpha(operand2));
586  _mode = M_combine;
587  _num_combine_alpha_operands = 3;
588  _combine_alpha_mode = mode;
589  _combine_alpha_source0 = source0;
590  _combine_alpha_operand0 = operand0;
591  _combine_alpha_source1 = source1;
592  _combine_alpha_operand1 = operand1;
593  _combine_alpha_source2 = source2;
594  _combine_alpha_operand2 = operand2;
595 
596  update_color_flags();
597 }
598 
599 ////////////////////////////////////////////////////////////////////
600 // Function: TextureStage::get_combine_alpha
601 // Access: Published
602 // Description: Get combine_alpha_mode
603 ////////////////////////////////////////////////////////////////////
604 INLINE TextureStage::CombineMode TextureStage::
606  return _combine_alpha_mode;
607 }
608 
609 ////////////////////////////////////////////////////////////////////
610 // Function: TextureStage::get_num_combine_alpha_operands
611 // Access: Published
612 // Description: Returns the number of meaningful operands that may be
613 // retrieved via get_combine_alpha_sourceN() and
614 // get_combine_alpha_operandN().
615 ////////////////////////////////////////////////////////////////////
616 INLINE int TextureStage::
618  return _num_combine_alpha_operands;
619 }
620 
621 ////////////////////////////////////////////////////////////////////
622 // Function: TextureStage::get_combine_alpha_source0
623 // Access: Published
624 // Description: Get source0 of combine_alpha_mode
625 ////////////////////////////////////////////////////////////////////
626 INLINE TextureStage::CombineSource TextureStage::
628  return _combine_alpha_source0;
629 }
630 
631 ////////////////////////////////////////////////////////////////////
632 // Function: TextureStage::get_combine_alpha_operand0
633 // Access: Published
634 // Description: Get operand0 of combine_alpha_mode
635 ////////////////////////////////////////////////////////////////////
636 INLINE TextureStage::CombineOperand TextureStage::
638  return _combine_alpha_operand0;
639 }
640 
641 ////////////////////////////////////////////////////////////////////
642 // Function: TextureStage::get_combine_alpha_source1
643 // Access: Published
644 // Description: Get source1 of combine_alpha_mode
645 ////////////////////////////////////////////////////////////////////
646 INLINE TextureStage::CombineSource TextureStage::
648  return _combine_alpha_source1;
649 }
650 
651 ////////////////////////////////////////////////////////////////////
652 // Function: TextureStage::get_combine_alpha_operand1
653 // Access: Published
654 // Description: Get operand1 of combine_alpha_mode
655 ////////////////////////////////////////////////////////////////////
656 INLINE TextureStage::CombineOperand TextureStage::
658  return _combine_alpha_operand1;
659 }
660 
661 ////////////////////////////////////////////////////////////////////
662 // Function: TextureStage::get_combine_alpha_source2
663 // Access: Published
664 // Description: Get source2 of combine_alpha_mode
665 ////////////////////////////////////////////////////////////////////
666 INLINE TextureStage::CombineSource TextureStage::
668  return _combine_alpha_source2;
669 }
670 
671 ////////////////////////////////////////////////////////////////////
672 // Function: TextureStage::get_combine_alpha_operand2
673 // Access: Published
674 // Description: Get operand2 of combine_alpha_mode
675 ////////////////////////////////////////////////////////////////////
676 INLINE TextureStage::CombineOperand TextureStage::
678  return _combine_alpha_operand2;
679 }
680 
681 ////////////////////////////////////////////////////////////////////
682 // Function: TextureStage::involves_color_scale
683 // Access: Published
684 // Description: Returns true if the TextureStage is affected by the
685 // setting of the current ColorScaleAttrib, false
686 // otherwise.
687 ////////////////////////////////////////////////////////////////////
688 INLINE bool TextureStage::
690  return _involves_color_scale;
691 }
692 
693 ////////////////////////////////////////////////////////////////////
694 // Function: TextureStage::uses_color
695 // Access: Published
696 // Description: Returns true if the TextureStage makes use of
697 // whatever color is specified in set_color(), false
698 // otherwise.
699 ////////////////////////////////////////////////////////////////////
700 INLINE bool TextureStage::
701 uses_color() const {
702  return _uses_color;
703 }
704 
705 ////////////////////////////////////////////////////////////////////
706 // Function: TextureStage::uses_primary_color
707 // Access: Published
708 // Description: Returns true if the TextureStage makes use of
709 // the CS_primary_color combine source.
710 ////////////////////////////////////////////////////////////////////
711 INLINE bool TextureStage::
713  return _uses_primary_color;
714 }
715 
716 ////////////////////////////////////////////////////////////////////
717 // Function: TextureStage::uses_last_saved_result
718 // Access: Published
719 // Description: Returns true if the TextureStage makes use of
720 // the CS_primary_color combine source.
721 ////////////////////////////////////////////////////////////////////
722 INLINE bool TextureStage::
724  return _uses_last_saved_result;
725 }
726 
727 ////////////////////////////////////////////////////////////////////
728 // Function: TextureStage::operator ==
729 // Access: Published
730 // Description:
731 ////////////////////////////////////////////////////////////////////
732 INLINE bool TextureStage::
733 operator == (const TextureStage &other) const {
734  return compare_to(other) == 0;
735 }
736 
737 ////////////////////////////////////////////////////////////////////
738 // Function: TextureStage::operator !=
739 // Access: Published
740 // Description:
741 ////////////////////////////////////////////////////////////////////
742 INLINE bool TextureStage::
743 operator != (const TextureStage &other) const {
744  return compare_to(other) != 0;
745 }
746 
747 ////////////////////////////////////////////////////////////////////
748 // Function: TextureStage::operator <
749 // Access: Published
750 // Description:
751 ////////////////////////////////////////////////////////////////////
752 INLINE bool TextureStage::
753 operator < (const TextureStage &other) const {
754  return compare_to(other) < 0;
755 }
756 
757 ////////////////////////////////////////////////////////////////////
758 // Function: TextureStage::get_default
759 // Access: Published, Static
760 // Description: Returns the default TextureStage that will be used
761 // for all texturing that does not name a particular
762 // stage. This generally handles the normal
763 // single-texture case.
764 ////////////////////////////////////////////////////////////////////
767  if (_default_stage == (TextureStage *)NULL) {
768  _default_stage = new TextureStage("default");
769  }
770  return _default_stage;
771 }
772 
773 ////////////////////////////////////////////////////////////////////
774 // Function: TextureStage::get_sort_seq
775 // Access: Public, Static
776 // Description: Returns a global sequence number that is incremented
777 // any time any TextureStage in the world changes sort
778 // or priority. This is used by TextureAttrib to
779 // determine when it is necessary to re-sort its
780 // internal array of stages.
781 ////////////////////////////////////////////////////////////////////
784  return _sort_seq;
785 }
786 
787 ////////////////////////////////////////////////////////////////////
788 // Function: TextureStage::update_color_flags
789 // Access: Private
790 // Description: Updates _uses_color, _involves_color_scale,
791 // _uses_primary_color and _uses_last_saved_result
792 // appropriately.
793 ////////////////////////////////////////////////////////////////////
794 INLINE void TextureStage::
795 update_color_flags() {
796  _involves_color_scale =
797  (_mode == M_blend_color_scale ||
798  (_mode == M_combine &&
799  (_combine_rgb_source0 == CS_constant_color_scale ||
800  _combine_rgb_source1 == CS_constant_color_scale ||
801  _combine_rgb_source2 == CS_constant_color_scale ||
802  _combine_alpha_source0 == CS_constant_color_scale ||
803  _combine_alpha_source1 == CS_constant_color_scale ||
804  _combine_alpha_source2 == CS_constant_color_scale)));
805 
806  _uses_color =
807  (_involves_color_scale ||
808  _mode == M_blend ||
809  (_mode == M_combine &&
810  (_combine_rgb_source0 == CS_constant ||
811  _combine_rgb_source1 == CS_constant ||
812  _combine_rgb_source2 == CS_constant ||
813  _combine_alpha_source0 == CS_constant ||
814  _combine_alpha_source1 == CS_constant ||
815  _combine_alpha_source2 == CS_constant)));
816 
817  _uses_primary_color =
818  (_mode == M_combine &&
819  (_combine_rgb_source0 == CS_primary_color ||
820  _combine_rgb_source1 == CS_primary_color ||
821  _combine_rgb_source2 == CS_primary_color ||
822  _combine_alpha_source0 == CS_primary_color ||
823  _combine_alpha_source1 == CS_primary_color ||
824  _combine_alpha_source2 == CS_primary_color));
825 
826  _uses_last_saved_result =
827  (_mode == M_combine &&
828  (_combine_rgb_source0 == CS_last_saved_result ||
829  _combine_rgb_source1 == CS_last_saved_result ||
830  _combine_rgb_source2 == CS_last_saved_result ||
831  _combine_alpha_source0 == CS_last_saved_result ||
832  _combine_alpha_source1 == CS_last_saved_result ||
833  _combine_alpha_source2 == CS_last_saved_result));
834 }
835 
836 INLINE ostream &
837 operator << (ostream &out, const TextureStage &ts) {
838  ts.output(out);
839  return out;
840 }
CombineSource get_combine_alpha_source2() const
Get source2 of combine_alpha_mode.
Definition: textureStage.I:667
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: textureStage.I:253
LColor get_color() const
return the color for this stage
Definition: textureStage.I:238
CombineOperand get_combine_alpha_operand0() const
Get operand0 of combine_alpha_mode.
Definition: textureStage.I:637
int get_rgb_scale() const
See set_rgb_scale().
Definition: textureStage.I:264
static UpdateSeq get_sort_seq()
Returns a global sequence number that is incremented any time any TextureStage in the world changes s...
Definition: textureStage.I:783
void set_saved_result(bool saved_result)
Sets the saved_result flag.
Definition: textureStage.I:310
int get_alpha_scale() const
See set_alpha_scale().
Definition: textureStage.I:289
TextureStage(const string &name)
Initialize the texture stage at construction.
Mode get_mode() const
Return the mode of this stage.
Definition: textureStage.I:206
int get_num_combine_alpha_operands() const
Returns the number of meaningful operands that may be retrieved via get_combine_alpha_sourceN() and g...
Definition: textureStage.I:617
CombineOperand get_combine_rgb_operand1() const
Get operand1 of combine_rgb_mode.
Definition: textureStage.I:493
void set_mode(Mode mode)
Set the mode of this texture stage.
Definition: textureStage.I:190
void output(ostream &out) const
Just a single line output.
CombineSource get_combine_rgb_source1() const
Get source1 of combine_rgb_mode.
Definition: textureStage.I:483
void set_sort(int sort)
Changes the order in which the texture associated with this stage is rendered relative to the other t...
Definition: textureStage.I:61
InternalName * get_binormal_name() const
Returns the set of binormals this texture stage will use.
Definition: textureStage.I:176
void set_name(const string &name)
Changes the name of this texture stage.
Definition: textureStage.I:42
int compare_to(const TextureStage &other) const
Returns a number less than zero if this TextureStage sorts before the other one, greater than zero if...
bool uses_last_saved_result() const
Returns true if the TextureStage makes use of the CS_primary_color combine source.
Definition: textureStage.I:723
CombineSource get_combine_alpha_source0() const
Get source0 of combine_alpha_mode.
Definition: textureStage.I:627
bool uses_primary_color() const
Returns true if the TextureStage makes use of the CS_primary_color combine source.
Definition: textureStage.I:712
void set_combine_alpha(CombineMode mode, CombineSource source0, CombineOperand operand0)
Specifies any of the CombineMode values that represent a one-parameter operation. ...
Definition: textureStage.I:525
void set_priority(int priority)
Changes the relative importance of the texture associated with this stage relative to the other textu...
Definition: textureStage.I:96
void set_alpha_scale(int alpha_scale)
Sets an additional factor that will scale the alpha component after the texture has been applied...
Definition: textureStage.I:278
CombineSource get_combine_rgb_source2() const
Get source2 of combine_rgb_mode.
Definition: textureStage.I:503
bool is_fixed_function() const
Returns true if the TextureStage is relevant to the classic fixed function pipeline.
Definition: textureStage.I:218
CombineOperand get_combine_rgb_operand0() const
Get operand0 of combine_rgb_mode.
Definition: textureStage.I:473
int get_num_combine_rgb_operands() const
Returns the number of meaningful operands that may be retrieved via get_combine_rgb_sourceN() and get...
Definition: textureStage.I:453
InternalName * get_texcoord_name() const
See set_texcoord_name.
Definition: textureStage.I:148
CombineMode get_combine_alpha_mode() const
Get combine_alpha_mode.
Definition: textureStage.I:605
int get_tex_view_offset() const
Returns the current setting of the tex_view_offset.
Definition: textureStage.I:349
CombineOperand get_combine_alpha_operand1() const
Get operand1 of combine_alpha_mode.
Definition: textureStage.I:657
int get_priority() const
Returns the priority associated with this stage.
Definition: textureStage.I:113
const string & get_name() const
Returns the name of this texture stage.
Definition: textureStage.I:32
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
CombineMode get_combine_rgb_mode() const
Get the combine_rgb_mode.
Definition: textureStage.I:441
void set_combine_rgb(CombineMode mode, CombineSource source0, CombineOperand operand0)
Specifies any of the CombineMode values that represent a one-parameter operation. ...
Definition: textureStage.I:361
CombineSource get_combine_rgb_source0() const
Get source0 of combine_rgb_mode.
Definition: textureStage.I:463
void set_color(const LColor &color)
Set the color for this stage.
Definition: textureStage.I:228
void set_tex_view_offset(int tex_view_offset)
Sets the tex_view_offset value.
Definition: textureStage.I:338
bool involves_color_scale() const
Returns true if the TextureStage is affected by the setting of the current ColorScaleAttrib, false otherwise.
Definition: textureStage.I:689
void set_texcoord_name(InternalName *name)
Indicate which set of UV&#39;s this texture stage will use.
Definition: textureStage.I:125
CombineOperand get_combine_rgb_operand2() const
Get operand2 of combine_rgb_mode.
Definition: textureStage.I:513
CombineSource get_combine_alpha_source1() const
Get source1 of combine_alpha_mode.
Definition: textureStage.I:647
CombineOperand get_combine_alpha_operand2() const
Get operand2 of combine_alpha_mode.
Definition: textureStage.I:677
InternalName * get_tangent_name() const
Returns the set of tangents this texture stage will use.
Definition: textureStage.I:160
bool uses_color() const
Returns true if the TextureStage makes use of whatever color is specified in set_color(), false otherwise.
Definition: textureStage.I:701
This is a sequence number that increments monotonically.
Definition: updateSeq.h:43
static TextureStage * get_default()
Returns the default TextureStage that will be used for all texturing that does not name a particular ...
Definition: textureStage.I:766
Defines the properties of a named stage of the multitexture pipeline.
Definition: textureStage.h:38
int get_sort() const
Returns the sort order of this texture stage.
Definition: textureStage.I:75
bool get_saved_result() const
Returns the current setting of the saved_result flag.
Definition: textureStage.I:321