Panda3D
|
00001 // Filename: textureStage.I 00002 // Created by: masad (15Jul04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: TextureStage::Copy Constructor 00018 // Access: Published 00019 // Description: Initialize the texture stage from other 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE TextureStage:: 00022 TextureStage(TextureStage ©) { 00023 (*this) = copy; 00024 } 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Function: TextureStage::get_name 00028 // Access: Published 00029 // Description: Returns the name of this texture stage 00030 //////////////////////////////////////////////////////////////////// 00031 INLINE const string &TextureStage:: 00032 get_name() const { 00033 return _name; 00034 } 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Function: TextureStage::set_name 00038 // Access: Published 00039 // Description: Changes the name of this texture stage 00040 //////////////////////////////////////////////////////////////////// 00041 INLINE void TextureStage:: 00042 set_name(const string &name) { 00043 _name = name; 00044 } 00045 00046 //////////////////////////////////////////////////////////////////// 00047 // Function: TextureStage::set_sort 00048 // Access: Published 00049 // Description: Changes the order in which the texture associated 00050 // with this stage is rendered relative to the other 00051 // texture stages. When geometry is rendered with 00052 // multiple textures, the textures are rendered in order 00053 // from the lowest sort number to the highest sort 00054 // number. 00055 // 00056 // Also see set_priority(), which is used to select the 00057 // most important textures for rendering when some must 00058 // be omitted because of hardware limitations. 00059 //////////////////////////////////////////////////////////////////// 00060 INLINE void TextureStage:: 00061 set_sort(int sort) { 00062 _sort = sort; 00063 00064 // Update the global flag to indicate that all TextureAttribs in the 00065 // world must now re-sort their lists. 00066 _sort_seq++; 00067 } 00068 00069 //////////////////////////////////////////////////////////////////// 00070 // Function: TextureStage::get_sort 00071 // Access: Published 00072 // Description: Returns the sort order of this texture stage. 00073 //////////////////////////////////////////////////////////////////// 00074 INLINE int TextureStage:: 00075 get_sort() const { 00076 return _sort; 00077 } 00078 00079 //////////////////////////////////////////////////////////////////// 00080 // Function: TextureStage::set_priority 00081 // Access: Published 00082 // Description: Changes the relative importance of the texture 00083 // associated with this stage relative to the other 00084 // texture stages that are applied simultaneously. 00085 // 00086 // This is unrelated to set_sort(), which controls the 00087 // order in which multiple textures are applied. The 00088 // priority number is used to decide which of the 00089 // requested textures are to be selected for rendering 00090 // when more textures are requested than the hardware 00091 // will support. The highest-priority n textures are 00092 // selected for rendering, and then rendered in order by 00093 // their sort factor. 00094 //////////////////////////////////////////////////////////////////// 00095 INLINE void TextureStage:: 00096 set_priority(int priority) { 00097 _priority = priority; 00098 00099 // Update the global flag to indicate that all TextureAttribs in the 00100 // world must now re-sort their lists. 00101 _sort_seq++; 00102 } 00103 00104 //////////////////////////////////////////////////////////////////// 00105 // Function: TextureStage::get_priority 00106 // Access: Published 00107 // Description: Returns the priority associated with this stage. 00108 // 00109 // This is specially helpful for cards that do not 00110 // support more than n stages of multi-texturing. 00111 //////////////////////////////////////////////////////////////////// 00112 INLINE int TextureStage:: 00113 get_priority() const { 00114 return _priority; 00115 } 00116 00117 //////////////////////////////////////////////////////////////////// 00118 // Function: TextureStage::set_texcoord_name 00119 // Access: Published 00120 // Description: Indicate which set of UV's this texture stage will 00121 // use. Geometry may have any number of associated UV 00122 // sets, each of which must have a unique name. 00123 //////////////////////////////////////////////////////////////////// 00124 INLINE void TextureStage:: 00125 set_texcoord_name(InternalName *name) { 00126 _texcoord_name = name; 00127 } 00128 00129 //////////////////////////////////////////////////////////////////// 00130 // Function: TextureStage::set_texcoord_name 00131 // Access: Published 00132 // Description: Indicate which set of UV's this texture stage will 00133 // use. Geometry may have any number of associated UV 00134 // sets, each of which must have a unique name. 00135 //////////////////////////////////////////////////////////////////// 00136 INLINE void TextureStage:: 00137 set_texcoord_name(const string &name) { 00138 _texcoord_name = InternalName::get_texcoord_name(name); 00139 } 00140 00141 //////////////////////////////////////////////////////////////////// 00142 // Function: TextureStage::get_texcoord_name 00143 // Access: Published 00144 // Description: Returns the InternalName 00145 //////////////////////////////////////////////////////////////////// 00146 INLINE InternalName *TextureStage:: 00147 get_texcoord_name() const { 00148 return _texcoord_name; 00149 } 00150 00151 //////////////////////////////////////////////////////////////////// 00152 // Function: TextureStage::set_mode 00153 // Access: Published 00154 // Description: Set the mode of this texture stage 00155 //////////////////////////////////////////////////////////////////// 00156 INLINE void TextureStage:: 00157 set_mode(TextureStage::Mode mode) { 00158 _mode = mode; 00159 00160 if (_mode != M_combine) { 00161 _num_combine_rgb_operands = 0; 00162 _num_combine_alpha_operands = 0; 00163 } 00164 update_color_flags(); 00165 } 00166 00167 //////////////////////////////////////////////////////////////////// 00168 // Function: TextureStage::get_mode 00169 // Access: Published 00170 // Description: Return the mode of this stage 00171 //////////////////////////////////////////////////////////////////// 00172 INLINE TextureStage::Mode TextureStage:: 00173 get_mode() const { 00174 return _mode; 00175 } 00176 00177 //////////////////////////////////////////////////////////////////// 00178 // Function: TextureStage::is_fixed_function 00179 // Access: Published 00180 // Description: Returns true if the TextureStage is relevant to 00181 // the classic fixed function pipeline. This excludes 00182 // texture stages such as normal mapping and the like. 00183 //////////////////////////////////////////////////////////////////// 00184 INLINE bool TextureStage:: 00185 is_fixed_function() const { 00186 return (_mode < M_normal); 00187 } 00188 00189 //////////////////////////////////////////////////////////////////// 00190 // Function: TextureStage::set_color 00191 // Access: Published 00192 // Description: Set the color for this stage 00193 //////////////////////////////////////////////////////////////////// 00194 INLINE void TextureStage:: 00195 set_color(const Colorf &color) { 00196 _color = color; 00197 } 00198 00199 //////////////////////////////////////////////////////////////////// 00200 // Function: TextureStage::get_color 00201 // Access: Published 00202 // Description: return the color for this stage 00203 //////////////////////////////////////////////////////////////////// 00204 INLINE Colorf TextureStage:: 00205 get_color() const { 00206 return _color; 00207 } 00208 00209 //////////////////////////////////////////////////////////////////// 00210 // Function: TextureStage::set_rgb_scale 00211 // Access: Published 00212 // Description: Sets an additional factor that will scale all three 00213 // r, g, b components after the texture has been 00214 // applied. This is used only when the mode is 00215 // CM_combine. 00216 // 00217 // The only legal values are 1, 2, or 4. 00218 //////////////////////////////////////////////////////////////////// 00219 INLINE void TextureStage:: 00220 set_rgb_scale(int rgb_scale) { 00221 nassertv(rgb_scale == 1 || rgb_scale == 2 || rgb_scale == 4); 00222 _rgb_scale = rgb_scale; 00223 } 00224 00225 //////////////////////////////////////////////////////////////////// 00226 // Function: TextureStage::get_rgb_scale 00227 // Access: Published 00228 // Description: See set_rgb_scale(). 00229 //////////////////////////////////////////////////////////////////// 00230 INLINE int TextureStage:: 00231 get_rgb_scale() const { 00232 return _rgb_scale; 00233 } 00234 00235 //////////////////////////////////////////////////////////////////// 00236 // Function: TextureStage::set_alpha_scale 00237 // Access: Published 00238 // Description: Sets an additional factor that will scale the 00239 // alpha component after the texture has been applied. 00240 // This is used only when the mode is CM_combine. 00241 // 00242 // The only legal values are 1, 2, or 4. 00243 //////////////////////////////////////////////////////////////////// 00244 INLINE void TextureStage:: 00245 set_alpha_scale(int alpha_scale) { 00246 nassertv(alpha_scale == 1 || alpha_scale == 2 || alpha_scale == 4); 00247 _alpha_scale = alpha_scale; 00248 } 00249 00250 //////////////////////////////////////////////////////////////////// 00251 // Function: TextureStage::get_alpha_scale 00252 // Access: Published 00253 // Description: See set_alpha_scale(). 00254 //////////////////////////////////////////////////////////////////// 00255 INLINE int TextureStage:: 00256 get_alpha_scale() const { 00257 return _alpha_scale; 00258 } 00259 00260 //////////////////////////////////////////////////////////////////// 00261 // Function: TextureStage::set_saved_result 00262 // Access: Published 00263 // Description: Sets the saved_result flag. When this is true, the 00264 // output of this stage will be supplied as the 00265 // "last_saved_result" source for any future stages, 00266 // until the next TextureStage with a saved_result set 00267 // true is encountered. 00268 // 00269 // This can be used to reuse the results of this texture 00270 // stage as input to more than one stage later in the 00271 // pipeline. 00272 // 00273 // The last texture in the pipeline (the one with the 00274 // highest sort value) should not have this flag set. 00275 //////////////////////////////////////////////////////////////////// 00276 INLINE void TextureStage:: 00277 set_saved_result(bool saved_result) { 00278 _saved_result = saved_result; 00279 } 00280 00281 //////////////////////////////////////////////////////////////////// 00282 // Function: TextureStage::get_saved_result 00283 // Access: Published 00284 // Description: Returns the current setting of the saved_result flag. 00285 // See set_saved_result(). 00286 //////////////////////////////////////////////////////////////////// 00287 INLINE bool TextureStage:: 00288 get_saved_result() const { 00289 return _saved_result; 00290 } 00291 00292 //////////////////////////////////////////////////////////////////// 00293 // Function: TextureStage::set_combine_rgb 00294 // Access: Published 00295 // Description: Specifies any of the CombineMode values that 00296 // represent a one-parameter operation. Specifically, 00297 // this is CM_replace only. 00298 //////////////////////////////////////////////////////////////////// 00299 INLINE void TextureStage:: 00300 set_combine_rgb(CombineMode mode, 00301 CombineSource source0, CombineOperand operand0) { 00302 nassertv(get_expected_num_combine_operands(mode) == 1); 00303 nassertv(operand_valid_for_rgb(operand0)); 00304 _mode = M_combine; 00305 _num_combine_rgb_operands = 1; 00306 _combine_rgb_mode = mode; 00307 _combine_rgb_source0 = source0; 00308 _combine_rgb_operand0 = operand0; 00309 _combine_rgb_source1 = CS_undefined; 00310 _combine_rgb_operand1 = CO_undefined; 00311 _combine_rgb_source2 = CS_undefined; 00312 _combine_rgb_operand2 = CO_undefined; 00313 00314 update_color_flags(); 00315 } 00316 00317 //////////////////////////////////////////////////////////////////// 00318 // Function: TextureStage::set_combine_rgb 00319 // Access: Published 00320 // Description: Specifies any of the CombineMode values that 00321 // represent a two-parameter operation. Specifically, 00322 // this is everything except for CM_replace and 00323 // CM_interpolate. 00324 //////////////////////////////////////////////////////////////////// 00325 INLINE void TextureStage:: 00326 set_combine_rgb(CombineMode mode, 00327 CombineSource source0, CombineOperand operand0, 00328 CombineSource source1, CombineOperand operand1) { 00329 nassertv(get_expected_num_combine_operands(mode) == 2); 00330 nassertv(operand_valid_for_rgb(operand0)); 00331 nassertv(operand_valid_for_rgb(operand1)); 00332 _mode = M_combine; 00333 _num_combine_rgb_operands = 2; 00334 _combine_rgb_mode = mode; 00335 _combine_rgb_source0 = source0; 00336 _combine_rgb_operand0 = operand0; 00337 _combine_rgb_source1 = source1; 00338 _combine_rgb_operand1 = operand1; 00339 _combine_rgb_source2 = CS_undefined; 00340 _combine_rgb_operand2 = CO_undefined; 00341 00342 update_color_flags(); 00343 } 00344 00345 //////////////////////////////////////////////////////////////////// 00346 // Function: TextureStage::set_combine_rgb 00347 // Access: Published 00348 // Description: Specifies any of the CombineMode values that 00349 // represent a one-parameter operation. Specifically, 00350 // this is CM_interpolate only. 00351 //////////////////////////////////////////////////////////////////// 00352 INLINE void TextureStage:: 00353 set_combine_rgb(CombineMode mode, 00354 CombineSource source0, CombineOperand operand0, 00355 CombineSource source1, CombineOperand operand1, 00356 CombineSource source2, CombineOperand operand2) { 00357 nassertv(get_expected_num_combine_operands(mode) == 3); 00358 nassertv(operand_valid_for_rgb(operand0)); 00359 nassertv(operand_valid_for_rgb(operand1)); 00360 nassertv(operand_valid_for_rgb(operand2)); 00361 _mode = M_combine; 00362 _num_combine_rgb_operands = 3; 00363 _combine_rgb_mode = mode; 00364 _combine_rgb_source0 = source0; 00365 _combine_rgb_operand0 = operand0; 00366 _combine_rgb_source1 = source1; 00367 _combine_rgb_operand1 = operand1; 00368 _combine_rgb_source2 = source2; 00369 _combine_rgb_operand2 = operand2; 00370 00371 update_color_flags(); 00372 } 00373 00374 //////////////////////////////////////////////////////////////////// 00375 // Function: TextureStage::get_combine_rgb_mode 00376 // Access: Published 00377 // Description: Get the combine_rgb_mode 00378 //////////////////////////////////////////////////////////////////// 00379 INLINE TextureStage::CombineMode TextureStage:: 00380 get_combine_rgb_mode() const { 00381 return _combine_rgb_mode; 00382 } 00383 00384 //////////////////////////////////////////////////////////////////// 00385 // Function: TextureStage::get_num_combine_rgb_operands 00386 // Access: Published 00387 // Description: Returns the number of meaningful operands that may be 00388 // retrieved via get_combine_rgb_sourceN() and 00389 // get_combine_rgb_operandN(). 00390 //////////////////////////////////////////////////////////////////// 00391 INLINE int TextureStage:: 00392 get_num_combine_rgb_operands() const { 00393 return _num_combine_rgb_operands; 00394 } 00395 00396 //////////////////////////////////////////////////////////////////// 00397 // Function: TextureStage::get_combine_rgb_source0 00398 // Access: Published 00399 // Description: Get source0 of combine_rgb_mode 00400 //////////////////////////////////////////////////////////////////// 00401 INLINE TextureStage::CombineSource TextureStage:: 00402 get_combine_rgb_source0() const { 00403 return _combine_rgb_source0; 00404 } 00405 00406 //////////////////////////////////////////////////////////////////// 00407 // Function: TextureStage::get_combine_rgb_operand0 00408 // Access: Published 00409 // Description: Get operand0 of combine_rgb_mode 00410 //////////////////////////////////////////////////////////////////// 00411 INLINE TextureStage::CombineOperand TextureStage:: 00412 get_combine_rgb_operand0() const { 00413 return _combine_rgb_operand0; 00414 } 00415 00416 //////////////////////////////////////////////////////////////////// 00417 // Function: TextureStage::get_combine_rgb_source1 00418 // Access: Published 00419 // Description: Get source1 of combine_rgb_mode 00420 //////////////////////////////////////////////////////////////////// 00421 INLINE TextureStage::CombineSource TextureStage:: 00422 get_combine_rgb_source1() const { 00423 return _combine_rgb_source1; 00424 } 00425 00426 //////////////////////////////////////////////////////////////////// 00427 // Function: TextureStage::get_combine_rgb_operand1 00428 // Access: Published 00429 // Description: Get operand1 of combine_rgb_mode 00430 //////////////////////////////////////////////////////////////////// 00431 INLINE TextureStage::CombineOperand TextureStage:: 00432 get_combine_rgb_operand1() const { 00433 return _combine_rgb_operand1; 00434 } 00435 00436 //////////////////////////////////////////////////////////////////// 00437 // Function: TextureStage::get_combine_rgb_source2 00438 // Access: Published 00439 // Description: Get source2 of combine_rgb_mode 00440 //////////////////////////////////////////////////////////////////// 00441 INLINE TextureStage::CombineSource TextureStage:: 00442 get_combine_rgb_source2() const { 00443 return _combine_rgb_source2; 00444 } 00445 00446 //////////////////////////////////////////////////////////////////// 00447 // Function: TextureStage::get_combine_rgb_operand2 00448 // Access: Published 00449 // Description: Get operand2 of combine_rgb_mode 00450 //////////////////////////////////////////////////////////////////// 00451 INLINE TextureStage::CombineOperand TextureStage:: 00452 get_combine_rgb_operand2() const { 00453 return _combine_rgb_operand2; 00454 } 00455 00456 //////////////////////////////////////////////////////////////////// 00457 // Function: TextureStage::set_combine_alpha 00458 // Access: Published 00459 // Description: Specifies any of the CombineMode values that 00460 // represent a one-parameter operation. Specifically, 00461 // this is CM_replace only. 00462 //////////////////////////////////////////////////////////////////// 00463 INLINE void TextureStage:: 00464 set_combine_alpha(CombineMode mode, 00465 CombineSource source0, CombineOperand operand0) { 00466 nassertv(get_expected_num_combine_operands(mode) == 1); 00467 nassertv(operand_valid_for_alpha(operand0)); 00468 _mode = M_combine; 00469 _num_combine_alpha_operands = 1; 00470 _combine_alpha_mode = mode; 00471 _combine_alpha_source0 = source0; 00472 _combine_alpha_operand0 = operand0; 00473 _combine_alpha_source1 = CS_undefined; 00474 _combine_alpha_operand1 = CO_undefined; 00475 _combine_alpha_source2 = CS_undefined; 00476 _combine_alpha_operand2 = CO_undefined; 00477 00478 update_color_flags(); 00479 } 00480 00481 //////////////////////////////////////////////////////////////////// 00482 // Function: TextureStage::set_combine_alpha 00483 // Access: Published 00484 // Description: Specifies any of the CombineMode values that 00485 // represent a two-parameter operation. Specifically, 00486 // this is everything except for CM_replace and 00487 // CM_interpolate. 00488 //////////////////////////////////////////////////////////////////// 00489 INLINE void TextureStage:: 00490 set_combine_alpha(CombineMode mode, 00491 CombineSource source0, CombineOperand operand0, 00492 CombineSource source1, CombineOperand operand1) { 00493 nassertv(get_expected_num_combine_operands(mode) == 2); 00494 nassertv(operand_valid_for_alpha(operand0)); 00495 nassertv(operand_valid_for_alpha(operand1)); 00496 _mode = M_combine; 00497 _num_combine_alpha_operands = 2; 00498 _combine_alpha_mode = mode; 00499 _combine_alpha_source0 = source0; 00500 _combine_alpha_operand0 = operand0; 00501 _combine_alpha_source1 = source1; 00502 _combine_alpha_operand1 = operand1; 00503 _combine_alpha_source2 = CS_undefined; 00504 _combine_alpha_operand2 = CO_undefined; 00505 00506 update_color_flags(); 00507 } 00508 00509 //////////////////////////////////////////////////////////////////// 00510 // Function: TextureStage::set_combine_alpha 00511 // Access: Published 00512 // Description: Specifies any of the CombineMode values that 00513 // represent a one-parameter operation. Specifically, 00514 // this is CM_interpolate only. 00515 //////////////////////////////////////////////////////////////////// 00516 INLINE void TextureStage:: 00517 set_combine_alpha(CombineMode mode, 00518 CombineSource source0, CombineOperand operand0, 00519 CombineSource source1, CombineOperand operand1, 00520 CombineSource source2, CombineOperand operand2) { 00521 nassertv(get_expected_num_combine_operands(mode) == 3); 00522 nassertv(operand_valid_for_alpha(operand0)); 00523 nassertv(operand_valid_for_alpha(operand1)); 00524 nassertv(operand_valid_for_alpha(operand2)); 00525 _mode = M_combine; 00526 _num_combine_alpha_operands = 3; 00527 _combine_alpha_mode = mode; 00528 _combine_alpha_source0 = source0; 00529 _combine_alpha_operand0 = operand0; 00530 _combine_alpha_source1 = source1; 00531 _combine_alpha_operand1 = operand1; 00532 _combine_alpha_source2 = source2; 00533 _combine_alpha_operand2 = operand2; 00534 00535 update_color_flags(); 00536 } 00537 00538 //////////////////////////////////////////////////////////////////// 00539 // Function: TextureStage::get_combine_alpha 00540 // Access: Published 00541 // Description: Get combine_alpha_mode 00542 //////////////////////////////////////////////////////////////////// 00543 INLINE TextureStage::CombineMode TextureStage:: 00544 get_combine_alpha_mode() const { 00545 return _combine_alpha_mode; 00546 } 00547 00548 //////////////////////////////////////////////////////////////////// 00549 // Function: TextureStage::get_num_combine_alpha_operands 00550 // Access: Published 00551 // Description: Returns the number of meaningful operands that may be 00552 // retrieved via get_combine_alpha_sourceN() and 00553 // get_combine_alpha_operandN(). 00554 //////////////////////////////////////////////////////////////////// 00555 INLINE int TextureStage:: 00556 get_num_combine_alpha_operands() const { 00557 return _num_combine_alpha_operands; 00558 } 00559 00560 //////////////////////////////////////////////////////////////////// 00561 // Function: TextureStage::get_combine_alpha_source0 00562 // Access: Published 00563 // Description: Get source0 of combine_alpha_mode 00564 //////////////////////////////////////////////////////////////////// 00565 INLINE TextureStage::CombineSource TextureStage:: 00566 get_combine_alpha_source0() const { 00567 return _combine_alpha_source0; 00568 } 00569 00570 //////////////////////////////////////////////////////////////////// 00571 // Function: TextureStage::get_combine_alpha_operand0 00572 // Access: Published 00573 // Description: Get operand0 of combine_alpha_mode 00574 //////////////////////////////////////////////////////////////////// 00575 INLINE TextureStage::CombineOperand TextureStage:: 00576 get_combine_alpha_operand0() const { 00577 return _combine_alpha_operand0; 00578 } 00579 00580 //////////////////////////////////////////////////////////////////// 00581 // Function: TextureStage::get_combine_alpha_source1 00582 // Access: Published 00583 // Description: Get source1 of combine_alpha_mode 00584 //////////////////////////////////////////////////////////////////// 00585 INLINE TextureStage::CombineSource TextureStage:: 00586 get_combine_alpha_source1() const { 00587 return _combine_alpha_source1; 00588 } 00589 00590 //////////////////////////////////////////////////////////////////// 00591 // Function: TextureStage::get_combine_alpha_operand1 00592 // Access: Published 00593 // Description: Get operand1 of combine_alpha_mode 00594 //////////////////////////////////////////////////////////////////// 00595 INLINE TextureStage::CombineOperand TextureStage:: 00596 get_combine_alpha_operand1() const { 00597 return _combine_alpha_operand1; 00598 } 00599 00600 //////////////////////////////////////////////////////////////////// 00601 // Function: TextureStage::get_combine_alpha_source2 00602 // Access: Published 00603 // Description: Get source2 of combine_alpha_mode 00604 //////////////////////////////////////////////////////////////////// 00605 INLINE TextureStage::CombineSource TextureStage:: 00606 get_combine_alpha_source2() const { 00607 return _combine_alpha_source2; 00608 } 00609 00610 //////////////////////////////////////////////////////////////////// 00611 // Function: TextureStage::get_combine_alpha_operand2 00612 // Access: Published 00613 // Description: Get operand2 of combine_alpha_mode 00614 //////////////////////////////////////////////////////////////////// 00615 INLINE TextureStage::CombineOperand TextureStage:: 00616 get_combine_alpha_operand2() const { 00617 return _combine_alpha_operand2; 00618 } 00619 00620 //////////////////////////////////////////////////////////////////// 00621 // Function: TextureStage::involves_color_scale 00622 // Access: Published 00623 // Description: Returns true if the TextureStage is affected by the 00624 // setting of the current ColorScaleAttrib, false 00625 // otherwise. 00626 //////////////////////////////////////////////////////////////////// 00627 INLINE bool TextureStage:: 00628 involves_color_scale() const { 00629 return _involves_color_scale; 00630 } 00631 00632 //////////////////////////////////////////////////////////////////// 00633 // Function: TextureStage::uses_color 00634 // Access: Published 00635 // Description: Returns true if the TextureStage makes use of 00636 // whatever color is specified in set_color(), false 00637 // otherwise. 00638 //////////////////////////////////////////////////////////////////// 00639 INLINE bool TextureStage:: 00640 uses_color() const { 00641 return _uses_color; 00642 } 00643 00644 //////////////////////////////////////////////////////////////////// 00645 // Function: TextureStage::uses_primary_color 00646 // Access: Published 00647 // Description: Returns true if the TextureStage makes use of 00648 // the CS_primary_color combine source. 00649 //////////////////////////////////////////////////////////////////// 00650 INLINE bool TextureStage:: 00651 uses_primary_color() const { 00652 return _uses_primary_color; 00653 } 00654 00655 //////////////////////////////////////////////////////////////////// 00656 // Function: TextureStage::uses_last_saved_result 00657 // Access: Published 00658 // Description: Returns true if the TextureStage makes use of 00659 // the CS_primary_color combine source. 00660 //////////////////////////////////////////////////////////////////// 00661 INLINE bool TextureStage:: 00662 uses_last_saved_result() const { 00663 return _uses_last_saved_result; 00664 } 00665 00666 //////////////////////////////////////////////////////////////////// 00667 // Function: TextureStage::operator == 00668 // Access: Published 00669 // Description: 00670 //////////////////////////////////////////////////////////////////// 00671 INLINE bool TextureStage:: 00672 operator == (const TextureStage &other) const { 00673 return compare_to(other) == 0; 00674 } 00675 00676 //////////////////////////////////////////////////////////////////// 00677 // Function: TextureStage::operator != 00678 // Access: Published 00679 // Description: 00680 //////////////////////////////////////////////////////////////////// 00681 INLINE bool TextureStage:: 00682 operator != (const TextureStage &other) const { 00683 return compare_to(other) != 0; 00684 } 00685 00686 //////////////////////////////////////////////////////////////////// 00687 // Function: TextureStage::operator < 00688 // Access: Published 00689 // Description: 00690 //////////////////////////////////////////////////////////////////// 00691 INLINE bool TextureStage:: 00692 operator < (const TextureStage &other) const { 00693 return compare_to(other) < 0; 00694 } 00695 00696 //////////////////////////////////////////////////////////////////// 00697 // Function: TextureStage::get_default 00698 // Access: Published, Static 00699 // Description: Returns the default TextureStage that will be used 00700 // for all texturing that does not name a particular 00701 // stage. This generally handles the normal 00702 // single-texture case. 00703 //////////////////////////////////////////////////////////////////// 00704 INLINE TextureStage *TextureStage:: 00705 get_default() { 00706 if (_default_stage == (TextureStage *)NULL) { 00707 _default_stage = new TextureStage("default"); 00708 } 00709 return _default_stage; 00710 } 00711 00712 //////////////////////////////////////////////////////////////////// 00713 // Function: TextureStage::get_sort_seq 00714 // Access: Public, Static 00715 // Description: Returns a global sequence number that is incremented 00716 // any time any TextureStage in the world changes sort 00717 // or priority. This is used by TextureAttrib to 00718 // determine when it is necessary to re-sort its 00719 // internal array of stages. 00720 //////////////////////////////////////////////////////////////////// 00721 INLINE UpdateSeq TextureStage:: 00722 get_sort_seq() { 00723 return _sort_seq; 00724 } 00725 00726 //////////////////////////////////////////////////////////////////// 00727 // Function: TextureStage::update_color_flags 00728 // Access: Private 00729 // Description: Updates _uses_color, _involves_color_scale, 00730 // _uses_primary_color and _uses_last_saved_result 00731 // appropriately. 00732 //////////////////////////////////////////////////////////////////// 00733 INLINE void TextureStage:: 00734 update_color_flags() { 00735 _involves_color_scale = 00736 (_mode == M_blend_color_scale || 00737 (_mode == M_combine && 00738 (_combine_rgb_source0 == CS_constant_color_scale || 00739 _combine_rgb_source1 == CS_constant_color_scale || 00740 _combine_rgb_source2 == CS_constant_color_scale || 00741 _combine_alpha_source0 == CS_constant_color_scale || 00742 _combine_alpha_source1 == CS_constant_color_scale || 00743 _combine_alpha_source2 == CS_constant_color_scale))); 00744 00745 _uses_color = 00746 (_involves_color_scale || 00747 _mode == M_blend || 00748 (_mode == M_combine && 00749 (_combine_rgb_source0 == CS_constant || 00750 _combine_rgb_source1 == CS_constant || 00751 _combine_rgb_source2 == CS_constant || 00752 _combine_alpha_source0 == CS_constant || 00753 _combine_alpha_source1 == CS_constant || 00754 _combine_alpha_source2 == CS_constant))); 00755 00756 _uses_primary_color = 00757 (_mode == M_combine && 00758 (_combine_rgb_source0 == CS_primary_color || 00759 _combine_rgb_source1 == CS_primary_color || 00760 _combine_rgb_source2 == CS_primary_color || 00761 _combine_alpha_source0 == CS_primary_color || 00762 _combine_alpha_source1 == CS_primary_color || 00763 _combine_alpha_source2 == CS_primary_color)); 00764 00765 _uses_last_saved_result = 00766 (_mode == M_combine && 00767 (_combine_rgb_source0 == CS_last_saved_result || 00768 _combine_rgb_source1 == CS_last_saved_result || 00769 _combine_rgb_source2 == CS_last_saved_result || 00770 _combine_alpha_source0 == CS_last_saved_result || 00771 _combine_alpha_source1 == CS_last_saved_result || 00772 _combine_alpha_source2 == CS_last_saved_result)); 00773 } 00774 00775 INLINE ostream & 00776 operator << (ostream &out, const TextureStage &ts) { 00777 ts.output(out); 00778 return out; 00779 }