00001 // Filename: eggTexture.I 00002 // Created by: drose (18Jan99) 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: EggTexture::set_texture_type 00018 // Access: Published 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE void EggTexture:: 00022 set_texture_type(TextureType texture_type) { 00023 _texture_type = texture_type; 00024 00025 bool pattern_filename = 00026 (_texture_type == TT_3d_texture || _texture_type == TT_cube_map); 00027 00028 _filename.set_pattern(pattern_filename); 00029 _fullpath.set_pattern(pattern_filename); 00030 } 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: EggTexture::get_texture_type 00034 // Access: Published 00035 // Description: 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE EggTexture::TextureType EggTexture:: 00038 get_texture_type() const { 00039 return _texture_type; 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: EggTexture::set_format 00044 // Access: Published 00045 // Description: 00046 //////////////////////////////////////////////////////////////////// 00047 INLINE void EggTexture:: 00048 set_format(Format format) { 00049 _format = format; 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function: EggTexture::get_format 00054 // Access: Published 00055 // Description: 00056 //////////////////////////////////////////////////////////////////// 00057 INLINE EggTexture::Format EggTexture:: 00058 get_format() const { 00059 return _format; 00060 } 00061 00062 //////////////////////////////////////////////////////////////////// 00063 // Function: EggTexture::set_compression_mode 00064 // Access: Published 00065 // Description: 00066 //////////////////////////////////////////////////////////////////// 00067 INLINE void EggTexture:: 00068 set_compression_mode(CompressionMode mode) { 00069 _compression_mode = mode; 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: EggTexture::get_compression_mode 00074 // Access: Published 00075 // Description: 00076 //////////////////////////////////////////////////////////////////// 00077 INLINE EggTexture::CompressionMode EggTexture:: 00078 get_compression_mode() const { 00079 return _compression_mode; 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: EggTexture::set_wrap_mode 00084 // Access: Published 00085 // Description: 00086 //////////////////////////////////////////////////////////////////// 00087 INLINE void EggTexture:: 00088 set_wrap_mode(WrapMode mode) { 00089 _wrap_mode = mode; 00090 } 00091 00092 //////////////////////////////////////////////////////////////////// 00093 // Function: EggTexture::get_wrap_mode 00094 // Access: Published 00095 // Description: 00096 //////////////////////////////////////////////////////////////////// 00097 INLINE EggTexture::WrapMode EggTexture:: 00098 get_wrap_mode() const { 00099 return _wrap_mode; 00100 } 00101 00102 //////////////////////////////////////////////////////////////////// 00103 // Function: EggTexture::set_wrap_u 00104 // Access: Published 00105 // Description: 00106 //////////////////////////////////////////////////////////////////// 00107 INLINE void EggTexture:: 00108 set_wrap_u(WrapMode mode) { 00109 _wrap_u = mode; 00110 } 00111 00112 //////////////////////////////////////////////////////////////////// 00113 // Function: EggTexture::get_wrap_u 00114 // Access: Published 00115 // Description: Returns the amount specified for U wrap. This may be 00116 // unspecified, even if there is an overall wrap value. 00117 //////////////////////////////////////////////////////////////////// 00118 INLINE EggTexture::WrapMode EggTexture:: 00119 get_wrap_u() const { 00120 return _wrap_u; 00121 } 00122 00123 //////////////////////////////////////////////////////////////////// 00124 // Function: EggTexture::determine_wrap_u 00125 // Access: Published 00126 // Description: Determines the appropriate wrap in the U direction. 00127 // This is different from get_wrap_u() in that if the U 00128 // wrap is unspecified, it returns the overall wrap 00129 // value. 00130 //////////////////////////////////////////////////////////////////// 00131 INLINE EggTexture::WrapMode EggTexture:: 00132 determine_wrap_u() const { 00133 return (_wrap_u == WM_unspecified) ? get_wrap_mode() : get_wrap_u(); 00134 } 00135 00136 //////////////////////////////////////////////////////////////////// 00137 // Function: EggTexture::set_wrap_v 00138 // Access: Published 00139 // Description: 00140 //////////////////////////////////////////////////////////////////// 00141 INLINE void EggTexture:: 00142 set_wrap_v(WrapMode mode) { 00143 _wrap_v = mode; 00144 } 00145 00146 //////////////////////////////////////////////////////////////////// 00147 // Function: EggTexture::get_wrap_v 00148 // Access: Published 00149 // Description: Returns the amount specified for V wrap. This may be 00150 // unspecified, even if there is an overall wrap value. 00151 //////////////////////////////////////////////////////////////////// 00152 INLINE EggTexture::WrapMode EggTexture:: 00153 get_wrap_v() const { 00154 return _wrap_v; 00155 } 00156 00157 //////////////////////////////////////////////////////////////////// 00158 // Function: EggTexture::determine_wrap_v 00159 // Access: Published 00160 // Description: Determines the appropriate wrap in the V direction. 00161 // This is different from get_wrap_v() in that if the V 00162 // wrap is unspecified, it returns the overall wrap 00163 // value. 00164 //////////////////////////////////////////////////////////////////// 00165 INLINE EggTexture::WrapMode EggTexture:: 00166 determine_wrap_v() const { 00167 return (_wrap_v == WM_unspecified) ? get_wrap_mode() : get_wrap_v(); 00168 } 00169 00170 //////////////////////////////////////////////////////////////////// 00171 // Function: EggTexture::set_wrap_w 00172 // Access: Published 00173 // Description: 00174 //////////////////////////////////////////////////////////////////// 00175 INLINE void EggTexture:: 00176 set_wrap_w(WrapMode mode) { 00177 _wrap_w = mode; 00178 } 00179 00180 //////////////////////////////////////////////////////////////////// 00181 // Function: EggTexture::get_wrap_w 00182 // Access: Published 00183 // Description: Returns the amount specified for W wrap. This may be 00184 // unspecified, even if there is an overall wrap value. 00185 //////////////////////////////////////////////////////////////////// 00186 INLINE EggTexture::WrapMode EggTexture:: 00187 get_wrap_w() const { 00188 return _wrap_w; 00189 } 00190 00191 //////////////////////////////////////////////////////////////////// 00192 // Function: EggTexture::determine_wrap_w 00193 // Access: Published 00194 // Description: Determines the appropriate wrap in the W direction. 00195 // This is different from get_wrap_w() in that if the W 00196 // wrap is unspecified, it returns the overall wrap 00197 // value. 00198 //////////////////////////////////////////////////////////////////// 00199 INLINE EggTexture::WrapMode EggTexture:: 00200 determine_wrap_w() const { 00201 return (_wrap_w == WM_unspecified) ? get_wrap_mode() : get_wrap_w(); 00202 } 00203 00204 //////////////////////////////////////////////////////////////////// 00205 // Function: EggTexture::set_minfilter 00206 // Access: Published 00207 // Description: 00208 //////////////////////////////////////////////////////////////////// 00209 INLINE void EggTexture:: 00210 set_minfilter(FilterType type) { 00211 _minfilter = type; 00212 } 00213 00214 //////////////////////////////////////////////////////////////////// 00215 // Function: EggTexture::get_minfilter 00216 // Access: Published 00217 // Description: 00218 //////////////////////////////////////////////////////////////////// 00219 INLINE EggTexture::FilterType EggTexture:: 00220 get_minfilter() const { 00221 return _minfilter; 00222 } 00223 00224 //////////////////////////////////////////////////////////////////// 00225 // Function: EggTexture::set_magfilter 00226 // Access: Published 00227 // Description: 00228 //////////////////////////////////////////////////////////////////// 00229 INLINE void EggTexture:: 00230 set_magfilter(FilterType type) { 00231 _magfilter = type; 00232 } 00233 00234 //////////////////////////////////////////////////////////////////// 00235 // Function: EggTexture::get_magfilter 00236 // Access: Published 00237 // Description: 00238 //////////////////////////////////////////////////////////////////// 00239 INLINE EggTexture::FilterType EggTexture:: 00240 get_magfilter() const { 00241 return _magfilter; 00242 } 00243 00244 //////////////////////////////////////////////////////////////////// 00245 // Function: EggTexture::set_anisotropic_degree 00246 // Access: Published 00247 // Description: Sets the degree of anisotropic filtering for this 00248 // texture. 1 is off; higher levels indicate filtering 00249 // in effect. 00250 //////////////////////////////////////////////////////////////////// 00251 INLINE void EggTexture:: 00252 set_anisotropic_degree(int anisotropic_degree) { 00253 _anisotropic_degree = anisotropic_degree; 00254 _flags |= F_has_anisotropic_degree; 00255 } 00256 00257 //////////////////////////////////////////////////////////////////// 00258 // Function: EggTexture::clear_anisotropic_degree 00259 // Access: Published 00260 // Description: Removes the specification of anisotropic filtering 00261 // from the texture. 00262 //////////////////////////////////////////////////////////////////// 00263 INLINE void EggTexture:: 00264 clear_anisotropic_degree() { 00265 _anisotropic_degree = 0; 00266 _flags &= ~F_has_anisotropic_degree; 00267 } 00268 00269 //////////////////////////////////////////////////////////////////// 00270 // Function: EggTexture::has_anisotropic_degree 00271 // Access: Published 00272 // Description: Returns true if a value for the anisotropic filtering 00273 // degree has been specified for this texture, false 00274 // otherwise. 00275 //////////////////////////////////////////////////////////////////// 00276 INLINE bool EggTexture:: 00277 has_anisotropic_degree() const { 00278 return (_flags & F_has_anisotropic_degree) != 0; 00279 } 00280 00281 //////////////////////////////////////////////////////////////////// 00282 // Function: EggTexture::get_anisotropic_degree 00283 // Access: Published 00284 // Description: Returns the anisotropic filtering degree that has 00285 // been specified for this texture, or 0 if nothing has 00286 // been specified. 00287 //////////////////////////////////////////////////////////////////// 00288 INLINE int EggTexture:: 00289 get_anisotropic_degree() const { 00290 // note: _anisotropic_degree of 0 and 1 are equivalent (no 00291 // anisotropic filtering to be done by gsg) 00292 return _anisotropic_degree; 00293 } 00294 00295 //////////////////////////////////////////////////////////////////// 00296 // Function: EggTexture::set_env_type 00297 // Access: Published 00298 // Description: 00299 //////////////////////////////////////////////////////////////////// 00300 INLINE void EggTexture:: 00301 set_env_type(EnvType type) { 00302 _env_type = type; 00303 } 00304 00305 //////////////////////////////////////////////////////////////////// 00306 // Function: EggTexture::get_env_type 00307 // Access: Published 00308 // Description: 00309 //////////////////////////////////////////////////////////////////// 00310 INLINE EggTexture::EnvType EggTexture:: 00311 get_env_type() const { 00312 return _env_type; 00313 } 00314 00315 //////////////////////////////////////////////////////////////////// 00316 // Function: EggTexture::set_combine_mode 00317 // Access: Published 00318 // Description: 00319 //////////////////////////////////////////////////////////////////// 00320 INLINE void EggTexture:: 00321 set_combine_mode(CombineChannel channel, CombineMode cm) { 00322 nassertv((int)channel >= 0 && (int)channel < (int)CC_num_channels); 00323 _combiner[channel]._mode = cm; 00324 } 00325 00326 //////////////////////////////////////////////////////////////////// 00327 // Function: EggTexture::get_combine_mode 00328 // Access: Published 00329 // Description: 00330 //////////////////////////////////////////////////////////////////// 00331 INLINE EggTexture::CombineMode EggTexture:: 00332 get_combine_mode(CombineChannel channel) const { 00333 nassertr((int)channel >= 0 && (int)channel < (int)CC_num_channels, CM_unspecified); 00334 return _combiner[channel]._mode; 00335 } 00336 00337 //////////////////////////////////////////////////////////////////// 00338 // Function: EggTexture::set_combine_source 00339 // Access: Published 00340 // Description: 00341 //////////////////////////////////////////////////////////////////// 00342 INLINE void EggTexture:: 00343 set_combine_source(CombineChannel channel, int n, CombineSource cs) { 00344 nassertv((int)channel >= 0 && (int)channel < (int)CC_num_channels); 00345 nassertv(n >= 0 && n < (int)CI_num_indices); 00346 _combiner[channel]._ops[n]._source = cs; 00347 } 00348 00349 //////////////////////////////////////////////////////////////////// 00350 // Function: EggTexture::get_combine_source 00351 // Access: Published 00352 // Description: 00353 //////////////////////////////////////////////////////////////////// 00354 INLINE EggTexture::CombineSource EggTexture:: 00355 get_combine_source(CombineChannel channel, int n) const { 00356 nassertr((int)channel >= 0 && (int)channel < (int)CC_num_channels, CS_unspecified); 00357 nassertr(n >= 0 && n < (int)CI_num_indices, CS_unspecified); 00358 return _combiner[channel]._ops[n]._source; 00359 } 00360 00361 //////////////////////////////////////////////////////////////////// 00362 // Function: EggTexture::set_combine_operand 00363 // Access: Published 00364 // Description: 00365 //////////////////////////////////////////////////////////////////// 00366 INLINE void EggTexture:: 00367 set_combine_operand(CombineChannel channel, int n, CombineOperand co) { 00368 nassertv((int)channel >= 0 && (int)channel < (int)CC_num_channels); 00369 nassertv(n >= 0 && n < (int)CI_num_indices); 00370 _combiner[channel]._ops[n]._operand = co; 00371 } 00372 00373 //////////////////////////////////////////////////////////////////// 00374 // Function: EggTexture::get_combine_operand 00375 // Access: Published 00376 // Description: 00377 //////////////////////////////////////////////////////////////////// 00378 INLINE EggTexture::CombineOperand EggTexture:: 00379 get_combine_operand(CombineChannel channel, int n) const { 00380 nassertr((int)channel >= 0 && (int)channel < (int)CC_num_channels, CO_unspecified); 00381 nassertr(n >= 0 && n < (int)CI_num_indices, CO_unspecified); 00382 return _combiner[channel]._ops[n]._operand; 00383 } 00384 00385 //////////////////////////////////////////////////////////////////// 00386 // Function: EggTexture::set_saved_result 00387 // Access: Published 00388 // Description: Sets the saved_result flag. When this is true, the 00389 // output of this stage is not part of the normal 00390 // pipeline--that is, it will not be supplied as the 00391 // "previous" source for the next texture stage--but it 00392 // will instead be supplied as the "last_saved_result" 00393 // source for any future stages, until the next 00394 // TextureStage with a saved_result set true is 00395 // encountered. 00396 // 00397 // This can be used to reuse the results of this texture 00398 // stage as input to more than one stage later in the 00399 // pipeline. 00400 // 00401 // The last texture in the pipeline (the one with the 00402 // highest sort value) should not have this flag set. 00403 //////////////////////////////////////////////////////////////////// 00404 INLINE void EggTexture:: 00405 set_saved_result(bool saved_result) { 00406 _saved_result = saved_result; 00407 } 00408 00409 //////////////////////////////////////////////////////////////////// 00410 // Function: EggTexture::get_saved_result 00411 // Access: Published 00412 // Description: Returns the current setting of the saved_result flag. 00413 // See set_saved_result(). 00414 //////////////////////////////////////////////////////////////////// 00415 INLINE bool EggTexture:: 00416 get_saved_result() const { 00417 return _saved_result; 00418 } 00419 00420 //////////////////////////////////////////////////////////////////// 00421 // Function: EggTexture::set_tex_gen 00422 // Access: Published 00423 // Description: 00424 //////////////////////////////////////////////////////////////////// 00425 INLINE void EggTexture:: 00426 set_tex_gen(TexGen tex_gen) { 00427 _tex_gen = tex_gen; 00428 } 00429 00430 //////////////////////////////////////////////////////////////////// 00431 // Function: EggTexture::get_tex_gen 00432 // Access: Published 00433 // Description: 00434 //////////////////////////////////////////////////////////////////// 00435 INLINE EggTexture::TexGen EggTexture:: 00436 get_tex_gen() const { 00437 return _tex_gen; 00438 } 00439 00440 //////////////////////////////////////////////////////////////////// 00441 // Function: EggTexture::set_quality_level 00442 // Access: Published 00443 // Description: 00444 //////////////////////////////////////////////////////////////////// 00445 INLINE void EggTexture:: 00446 set_quality_level(QualityLevel quality_level) { 00447 _quality_level = quality_level; 00448 } 00449 00450 //////////////////////////////////////////////////////////////////// 00451 // Function: EggTexture::get_quality_level 00452 // Access: Published 00453 // Description: 00454 //////////////////////////////////////////////////////////////////// 00455 INLINE EggTexture::QualityLevel EggTexture:: 00456 get_quality_level() const { 00457 return _quality_level; 00458 } 00459 00460 //////////////////////////////////////////////////////////////////// 00461 // Function: EggTexture::set_stage_name 00462 // Access: Published 00463 // Description: Specifies the particular TextureStage this texture 00464 // will be rendered on by name. If this is omitted, the 00465 // texture will be rendered on the default TextureStage, 00466 // unless some other stage-specific property is 00467 // specificied, in which case the texture will be 00468 // rendered on a TextureStage with the same name as the 00469 // tref. This is in support of multitexturing. 00470 // 00471 // Each different TextureStage in the world must be 00472 // uniquely named. 00473 //////////////////////////////////////////////////////////////////// 00474 INLINE void EggTexture:: 00475 set_stage_name(const string &stage_name) { 00476 _stage_name = stage_name; 00477 _flags |= F_has_stage_name; 00478 } 00479 00480 //////////////////////////////////////////////////////////////////// 00481 // Function: EggTexture::clear_stage_name 00482 // Access: Published 00483 // Description: Removes the named TextureStage specification. 00484 //////////////////////////////////////////////////////////////////// 00485 INLINE void EggTexture:: 00486 clear_stage_name() { 00487 _stage_name = string(); 00488 _flags &= ~F_has_stage_name; 00489 } 00490 00491 //////////////////////////////////////////////////////////////////// 00492 // Function: EggTexture::has_stage_name 00493 // Access: Published 00494 // Description: Returns true if a stage name has been explicitly 00495 // specified for this texture, false otherwise. 00496 //////////////////////////////////////////////////////////////////// 00497 INLINE bool EggTexture:: 00498 has_stage_name() const { 00499 return (_flags & F_has_stage_name) != 0; 00500 } 00501 00502 //////////////////////////////////////////////////////////////////// 00503 // Function: EggTexture::get_stage_name 00504 // Access: Published 00505 // Description: Returns the stage name that has been specified for 00506 // this texture, or the tref name if no texture stage 00507 // has explicitly been specified. 00508 //////////////////////////////////////////////////////////////////// 00509 INLINE const string &EggTexture:: 00510 get_stage_name() const { 00511 return has_stage_name() ? _stage_name : get_name(); 00512 } 00513 00514 //////////////////////////////////////////////////////////////////// 00515 // Function: EggTexture::set_priority 00516 // Access: Published 00517 // Description: Sets the importance of this texture with respect to 00518 // other textures also applied on the same geometry. 00519 // This is only meaningful in the presence of 00520 // multitexturing. 00521 //////////////////////////////////////////////////////////////////// 00522 INLINE void EggTexture:: 00523 set_priority(int priority) { 00524 _priority = priority; 00525 _flags |= F_has_priority; 00526 } 00527 00528 //////////////////////////////////////////////////////////////////// 00529 // Function: EggTexture::clear_priority 00530 // Access: Published 00531 // Description: Removes the specification of multitexture priority 00532 // from the texture. The default priority value is 0. 00533 //////////////////////////////////////////////////////////////////// 00534 INLINE void EggTexture:: 00535 clear_priority() { 00536 _priority = 0; 00537 _flags &= ~F_has_priority; 00538 } 00539 00540 //////////////////////////////////////////////////////////////////// 00541 // Function: EggTexture::has_priority 00542 // Access: Published 00543 // Description: Returns true if a priority value for multitexture 00544 // importance has been specified for the texture, false 00545 // otherwise. 00546 //////////////////////////////////////////////////////////////////// 00547 INLINE bool EggTexture:: 00548 has_priority() const { 00549 return (_flags & F_has_priority) != 0; 00550 } 00551 00552 //////////////////////////////////////////////////////////////////// 00553 // Function: EggTexture::get_priority 00554 // Access: Published 00555 // Description: Returns the multitexture importance value that has been 00556 // specified for the texture, or 0 if no priority value has 00557 // been specified. 00558 //////////////////////////////////////////////////////////////////// 00559 INLINE int EggTexture:: 00560 get_priority() const { 00561 return _priority; 00562 } 00563 00564 //////////////////////////////////////////////////////////////////// 00565 // Function: EggTexture::set_color 00566 // Access: Published 00567 // Description: 00568 //////////////////////////////////////////////////////////////////// 00569 INLINE void EggTexture:: 00570 set_color(const LColor &color) { 00571 _color = color; 00572 _flags |= F_has_color; 00573 } 00574 00575 //////////////////////////////////////////////////////////////////// 00576 // Function: EggTexture::clear_color 00577 // Access: Published 00578 // Description: 00579 //////////////////////////////////////////////////////////////////// 00580 INLINE void EggTexture:: 00581 clear_color() { 00582 _color.set(0.0f, 0.0f, 0.0f, 1.0f); 00583 _flags &= ~F_has_color; 00584 } 00585 00586 //////////////////////////////////////////////////////////////////// 00587 // Function: EggTexture::has_color 00588 // Access: Published 00589 // Description: Returns true if a blend color has been 00590 // specified for the texture. 00591 //////////////////////////////////////////////////////////////////// 00592 INLINE bool EggTexture:: 00593 has_color() const { 00594 return (_flags & F_has_color) != 0; 00595 } 00596 00597 //////////////////////////////////////////////////////////////////// 00598 // Function: EggTexture::get_color 00599 // Access: Published 00600 // Description: Returns the blend color if one has been 00601 // specified, or (0, 0, 0, 1) otherwise. 00602 //////////////////////////////////////////////////////////////////// 00603 INLINE const LColor &EggTexture:: 00604 get_color() const { 00605 return _color; 00606 } 00607 00608 //////////////////////////////////////////////////////////////////// 00609 // Function: EggTexture::set_border_color 00610 // Access: Published 00611 // Description: 00612 //////////////////////////////////////////////////////////////////// 00613 INLINE void EggTexture:: 00614 set_border_color(const LColor &border_color) { 00615 _border_color = border_color; 00616 _flags |= F_has_border_color; 00617 } 00618 00619 //////////////////////////////////////////////////////////////////// 00620 // Function: EggTexture::clear_border_color 00621 // Access: Published 00622 // Description: 00623 //////////////////////////////////////////////////////////////////// 00624 INLINE void EggTexture:: 00625 clear_border_color() { 00626 _border_color.set(0.0f, 0.0f, 0.0f, 1.0f); 00627 _flags &= ~F_has_border_color; 00628 } 00629 00630 //////////////////////////////////////////////////////////////////// 00631 // Function: EggTexture::has_border_color 00632 // Access: Published 00633 // Description: Returns true if a border color has been 00634 // specified for the texture. 00635 //////////////////////////////////////////////////////////////////// 00636 INLINE bool EggTexture:: 00637 has_border_color() const { 00638 return (_flags & F_has_border_color) != 0; 00639 } 00640 00641 //////////////////////////////////////////////////////////////////// 00642 // Function: EggTexture::get_border_color 00643 // Access: Published 00644 // Description: Returns the border color if one has been 00645 // specified, or (0, 0, 0, 1) otherwise. 00646 //////////////////////////////////////////////////////////////////// 00647 INLINE const LColor &EggTexture:: 00648 get_border_color() const { 00649 return _border_color; 00650 } 00651 00652 //////////////////////////////////////////////////////////////////// 00653 // Function: EggTexture::set_uv_name 00654 // Access: Published 00655 // Description: Specifies the named set of texture coordinates that 00656 // this texture will use when it is applied to geometry. 00657 // Geometry may have multiple sets of texture 00658 // coordinates defined, by name. 00659 // 00660 // If this is not specified for a particular texture, 00661 // the default set of texture coordinates will be used. 00662 //////////////////////////////////////////////////////////////////// 00663 INLINE void EggTexture:: 00664 set_uv_name(const string &uv_name) { 00665 if (uv_name == "default" || uv_name.empty()) { 00666 clear_uv_name(); 00667 } else { 00668 _uv_name = uv_name; 00669 _flags |= F_has_uv_name; 00670 } 00671 } 00672 00673 //////////////////////////////////////////////////////////////////// 00674 // Function: EggTexture::clear_uv_name 00675 // Access: Published 00676 // Description: Removes the restriction to a particular named set of 00677 // texture coordinates and restores the texture to using 00678 // the default texture coordinates. 00679 //////////////////////////////////////////////////////////////////// 00680 INLINE void EggTexture:: 00681 clear_uv_name() { 00682 _uv_name = string(); 00683 _flags &= ~F_has_uv_name; 00684 } 00685 00686 //////////////////////////////////////////////////////////////////// 00687 // Function: EggTexture::has_uv_name 00688 // Access: Published 00689 // Description: Returns true if a texcoord name has been explicitly 00690 // specified for this texture, false otherwise. 00691 //////////////////////////////////////////////////////////////////// 00692 INLINE bool EggTexture:: 00693 has_uv_name() const { 00694 return (_flags & F_has_uv_name) != 0; 00695 } 00696 00697 //////////////////////////////////////////////////////////////////// 00698 // Function: EggTexture::get_uv_name 00699 // Access: Published 00700 // Description: Returns the texcoord name that has been specified for 00701 // this texture, or the empty string if no texcoord name 00702 // has explicitly been specified. 00703 //////////////////////////////////////////////////////////////////// 00704 INLINE const string &EggTexture:: 00705 get_uv_name() const { 00706 return _uv_name; 00707 } 00708 00709 //////////////////////////////////////////////////////////////////// 00710 // Function: EggTexture::set_rgb_scale 00711 // Access: Published 00712 // Description: Sets an additional factor that will scale all three 00713 // r, g, b components after the texture has been 00714 // applied. This is used only when a combine mode is in 00715 // effect. 00716 // 00717 // The only legal values are 1, 2, or 4. 00718 //////////////////////////////////////////////////////////////////// 00719 INLINE void EggTexture:: 00720 set_rgb_scale(int rgb_scale) { 00721 _rgb_scale = rgb_scale; 00722 _flags |= F_has_rgb_scale; 00723 } 00724 00725 //////////////////////////////////////////////////////////////////// 00726 // Function: EggTexture::clear_rgb_scale 00727 // Access: Published 00728 // Description: Removes the rgb_scale from the texture and restores 00729 // it to the default value of 1. 00730 //////////////////////////////////////////////////////////////////// 00731 INLINE void EggTexture:: 00732 clear_rgb_scale() { 00733 _rgb_scale = 1; 00734 _flags &= ~F_has_rgb_scale; 00735 } 00736 00737 //////////////////////////////////////////////////////////////////// 00738 // Function: EggTexture::has_rgb_scale 00739 // Access: Published 00740 // Description: Returns true if an rgb_scale has been specified for 00741 // the texture, false otherwise. 00742 //////////////////////////////////////////////////////////////////// 00743 INLINE bool EggTexture:: 00744 has_rgb_scale() const { 00745 return (_flags & F_has_rgb_scale) != 0; 00746 } 00747 00748 //////////////////////////////////////////////////////////////////// 00749 // Function: EggTexture::get_rgb_scale 00750 // Access: Published 00751 // Description: Returns the rgb_scale value that has been 00752 // specified for the texture, or 1 if no rgb_scale value 00753 // has been specified. 00754 //////////////////////////////////////////////////////////////////// 00755 INLINE int EggTexture:: 00756 get_rgb_scale() const { 00757 return _rgb_scale; 00758 } 00759 00760 //////////////////////////////////////////////////////////////////// 00761 // Function: EggTexture::set_alpha_scale 00762 // Access: Published 00763 // Description: Sets an additional factor that will scale the 00764 // alpha component after the texture has been applied. 00765 // This is used only when a combine mode is in effect. 00766 // 00767 // The only legal values are 1, 2, or 4. 00768 //////////////////////////////////////////////////////////////////// 00769 INLINE void EggTexture:: 00770 set_alpha_scale(int alpha_scale) { 00771 _alpha_scale = alpha_scale; 00772 _flags |= F_has_alpha_scale; 00773 } 00774 00775 //////////////////////////////////////////////////////////////////// 00776 // Function: EggTexture::clear_alpha_scale 00777 // Access: Published 00778 // Description: Removes the alpha_scale from the texture and restores 00779 // it to the default value of 1. 00780 //////////////////////////////////////////////////////////////////// 00781 INLINE void EggTexture:: 00782 clear_alpha_scale() { 00783 _alpha_scale = 1; 00784 _flags &= ~F_has_alpha_scale; 00785 } 00786 00787 //////////////////////////////////////////////////////////////////// 00788 // Function: EggTexture::has_alpha_scale 00789 // Access: Published 00790 // Description: Returns true if an alpha_scale has been specified for 00791 // the texture, false otherwise. 00792 //////////////////////////////////////////////////////////////////// 00793 INLINE bool EggTexture:: 00794 has_alpha_scale() const { 00795 return (_flags & F_has_alpha_scale) != 0; 00796 } 00797 00798 //////////////////////////////////////////////////////////////////// 00799 // Function: EggTexture::get_alpha_scale 00800 // Access: Published 00801 // Description: Returns the alpha_scale value that has been 00802 // specified for the texture, or 1 if no alpha_scale 00803 // value has been specified. 00804 //////////////////////////////////////////////////////////////////// 00805 INLINE int EggTexture:: 00806 get_alpha_scale() const { 00807 return _alpha_scale; 00808 } 00809 00810 //////////////////////////////////////////////////////////////////// 00811 // Function: EggTexture::set_alpha_filename 00812 // Access: Published 00813 // Description: Specifies a separate file that will be loaded in with 00814 // the 1- or 3-component texture and applied as the 00815 // alpha channel. This is useful when loading textures 00816 // from file formats that do not support alpha, for 00817 // instance jpg. 00818 //////////////////////////////////////////////////////////////////// 00819 INLINE void EggTexture:: 00820 set_alpha_filename(const Filename &alpha_filename) { 00821 _alpha_filename = alpha_filename; 00822 _alpha_fullpath = alpha_filename; 00823 _flags |= F_has_alpha_filename; 00824 } 00825 00826 //////////////////////////////////////////////////////////////////// 00827 // Function: EggTexture::clear_alpha_filename 00828 // Access: Published 00829 // Description: 00830 //////////////////////////////////////////////////////////////////// 00831 INLINE void EggTexture:: 00832 clear_alpha_filename() { 00833 _alpha_filename = Filename(); 00834 _alpha_fullpath = Filename(); 00835 _flags &= ~F_has_alpha_filename; 00836 } 00837 00838 //////////////////////////////////////////////////////////////////// 00839 // Function: EggTexture::has_alpha_filename 00840 // Access: Published 00841 // Description: Returns true if a separate file for the alpha 00842 // component has been applied, false otherwise. See 00843 // set_alpha_filename(). 00844 //////////////////////////////////////////////////////////////////// 00845 INLINE bool EggTexture:: 00846 has_alpha_filename() const { 00847 return (_flags & F_has_alpha_filename) != 0; 00848 } 00849 00850 //////////////////////////////////////////////////////////////////// 00851 // Function: EggTexture::get_alpha_filename 00852 // Access: Published 00853 // Description: Returns the separate file assigned for the alpha 00854 // channel. It is an error to call this unless 00855 // has_alpha_filename() returns true. See set_alpha_filename(). 00856 //////////////////////////////////////////////////////////////////// 00857 INLINE const Filename &EggTexture:: 00858 get_alpha_filename() const { 00859 nassertr(has_alpha_filename(), _alpha_filename); 00860 return _alpha_filename; 00861 } 00862 00863 //////////////////////////////////////////////////////////////////// 00864 // Function: EggTexture::get_alpha_fullpath 00865 // Access: Published 00866 // Description: Returns the full pathname to the alpha file, if it is 00867 // known; otherwise, returns the same thing as 00868 // get_alpha_filename(). 00869 // 00870 // This function simply returns whatever was set by the 00871 // last call to set_alpha_fullpath(). This string is 00872 // not written to the egg file; its main purpose is to 00873 // record the full path to the alpha filename if it is 00874 // known, for egg structures that are generated 00875 // in-memory and then immediately converted to a scene 00876 // graph. 00877 //////////////////////////////////////////////////////////////////// 00878 INLINE const Filename &EggTexture:: 00879 get_alpha_fullpath() const { 00880 return _alpha_fullpath; 00881 } 00882 00883 //////////////////////////////////////////////////////////////////// 00884 // Function: EggTexture::set_alpha_fullpath 00885 // Access: Published 00886 // Description: Records the full pathname to the file, for the 00887 // benefit of get_alpha_fullpath(). 00888 //////////////////////////////////////////////////////////////////// 00889 INLINE void EggTexture:: 00890 set_alpha_fullpath(const Filename &alpha_fullpath) { 00891 _alpha_fullpath = alpha_fullpath; 00892 } 00893 00894 //////////////////////////////////////////////////////////////////// 00895 // Function: EggTexture::set_alpha_file_channel 00896 // Access: Published 00897 // Description: If a separate alpha-file is specified, this indicates 00898 // which channel number should be extracted from this 00899 // file to derive the alpha channel for the final image. 00900 // The default is 0, which means the grayscale 00901 // combination of r, g, b. Otherwise, this should be 00902 // the 1-based channel number, for instance 1, 2, or 3 00903 // for r, g, or b, respectively, or 4 for the alpha 00904 // channel of a four-component image. 00905 //////////////////////////////////////////////////////////////////// 00906 INLINE void EggTexture:: 00907 set_alpha_file_channel(int alpha_file_channel) { 00908 _alpha_file_channel = alpha_file_channel; 00909 _flags |= F_has_alpha_file_channel; 00910 } 00911 00912 //////////////////////////////////////////////////////////////////// 00913 // Function: EggTexture::clear_alpha_file_channel 00914 // Access: Published 00915 // Description: Removes the specification of a particular channel to 00916 // use from the alpha-file image. 00917 //////////////////////////////////////////////////////////////////// 00918 INLINE void EggTexture:: 00919 clear_alpha_file_channel() { 00920 _alpha_file_channel = 0; 00921 _flags &= ~F_has_alpha_file_channel; 00922 } 00923 00924 //////////////////////////////////////////////////////////////////// 00925 // Function: EggTexture::has_alpha_file_channel 00926 // Access: Published 00927 // Description: Returns true if a particular channel has been 00928 // specified for the alpha-file image, false otherwise. 00929 //////////////////////////////////////////////////////////////////// 00930 INLINE bool EggTexture:: 00931 has_alpha_file_channel() const { 00932 return (_flags & F_has_alpha_file_channel) != 0; 00933 } 00934 00935 //////////////////////////////////////////////////////////////////// 00936 // Function: EggTexture::get_alpha_file_channel 00937 // Access: Published 00938 // Description: Returns the particular channel that has been 00939 // specified for the alpha-file image, or 0 if no 00940 // channel has been specified. See 00941 // set_alpha_file_channel(). 00942 //////////////////////////////////////////////////////////////////// 00943 INLINE int EggTexture:: 00944 get_alpha_file_channel() const { 00945 return _alpha_file_channel; 00946 } 00947 00948 //////////////////////////////////////////////////////////////////// 00949 // Function: EggTexture::set_multiview 00950 // Access: Published 00951 // Description: Sets the multiview flag. 00952 // 00953 // If multiview is true, the filename should contain a 00954 // hash mark ('#'), which will be filled in with the 00955 // view number; and a multiview texture will be defined 00956 // with a series of images, one for each view. 00957 // 00958 // A multiview texture is most often used for stereo 00959 // textures, but other uses are also possible, such as 00960 // for texture animation. 00961 //////////////////////////////////////////////////////////////////// 00962 INLINE void EggTexture:: 00963 set_multiview(bool multiview) { 00964 _multiview = multiview; 00965 } 00966 00967 //////////////////////////////////////////////////////////////////// 00968 // Function: EggTexture::get_multiview 00969 // Access: Published 00970 // Description: Returns the current setting of the multiview flag. 00971 // See set_multiview(). 00972 //////////////////////////////////////////////////////////////////// 00973 INLINE bool EggTexture:: 00974 get_multiview() const { 00975 return _multiview; 00976 } 00977 00978 //////////////////////////////////////////////////////////////////// 00979 // Function: EggTexture::set_num_views 00980 // Access: Published 00981 // Description: When loading a 3-D multiview texture, this parameter 00982 // is necessary to specify how many views will be 00983 // expected. The z size is determined implicitly from 00984 // the number of images loaded. 00985 //////////////////////////////////////////////////////////////////// 00986 INLINE void EggTexture:: 00987 set_num_views(int num_views) { 00988 _num_views = num_views; 00989 _flags |= F_has_num_views; 00990 } 00991 00992 //////////////////////////////////////////////////////////////////// 00993 // Function: EggTexture::clear_num_views 00994 // Access: Published 00995 // Description: Removes the specification of the number of views 00996 // for a 3-D multiview texture. 00997 //////////////////////////////////////////////////////////////////// 00998 INLINE void EggTexture:: 00999 clear_num_views() { 01000 _num_views = 0; 01001 _flags &= ~F_has_num_views; 01002 } 01003 01004 //////////////////////////////////////////////////////////////////// 01005 // Function: EggTexture::has_num_views 01006 // Access: Published 01007 // Description: Returns true if the number of views has been 01008 // specified for the 3-D multiview texture, false 01009 // otherwise. 01010 //////////////////////////////////////////////////////////////////// 01011 INLINE bool EggTexture:: 01012 has_num_views() const { 01013 return (_flags & F_has_num_views) != 0; 01014 } 01015 01016 //////////////////////////////////////////////////////////////////// 01017 // Function: EggTexture::get_num_views 01018 // Access: Published 01019 // Description: Returns the specified number of views specified for 01020 // the 3-D multiview texture. See set_num_views(). 01021 //////////////////////////////////////////////////////////////////// 01022 INLINE int EggTexture:: 01023 get_num_views() const { 01024 return _num_views; 01025 } 01026 01027 //////////////////////////////////////////////////////////////////// 01028 // Function: EggTexture::set_read_mipmaps 01029 // Access: Published 01030 // Description: Sets the read_mipmaps flag. 01031 // 01032 // If read_mipmaps is true, the filename should contain 01033 // a hash mark ('#'), which will be filled in with the 01034 // mipmap level number; and the texture will be defined 01035 // with a series of images, one for each mipmap level. 01036 // 01037 // If the filename is of a type that already requires a 01038 // hash mark, such as a cube map or a 3-d texture, then 01039 // the filename should now require two hash marks, and 01040 // the first one indicates the mipmap level number, 01041 // while the second indicates the face number or 3-d 01042 // level number. 01043 //////////////////////////////////////////////////////////////////// 01044 INLINE void EggTexture:: 01045 set_read_mipmaps(bool read_mipmaps) { 01046 _read_mipmaps = read_mipmaps; 01047 } 01048 01049 //////////////////////////////////////////////////////////////////// 01050 // Function: EggTexture::get_read_mipmaps 01051 // Access: Published 01052 // Description: Returns the current setting of the read_mipmaps flag. 01053 // See set_read_mipmaps(). 01054 //////////////////////////////////////////////////////////////////// 01055 INLINE bool EggTexture:: 01056 get_read_mipmaps() const { 01057 return _read_mipmaps; 01058 } 01059 01060 //////////////////////////////////////////////////////////////////// 01061 // Function: EggTexture::get_multitexture_sort 01062 // Access: Published 01063 // Description: Returns an integer that represents the depth to which 01064 // this texture is layered on all other textures in the 01065 // egg file. In general, if texture A is layered over 01066 // texture B, then sort(A) > sort(B). If texture A is 01067 // never layered over any other texture, then sort(A) == 01068 // 0. More than that is difficult to guarantee. 01069 //////////////////////////////////////////////////////////////////// 01070 INLINE int EggTexture:: 01071 get_multitexture_sort() const { 01072 return _multitexture_sort; 01073 } 01074 01075 //////////////////////////////////////////////////////////////////// 01076 // Function: EggTexture::SourceAndOperand::Constructor 01077 // Access: Public 01078 // Description: 01079 //////////////////////////////////////////////////////////////////// 01080 INLINE EggTexture::SourceAndOperand:: 01081 SourceAndOperand() : 01082 _source(CS_unspecified), 01083 _operand(CO_unspecified) 01084 { 01085 } 01086 01087 //////////////////////////////////////////////////////////////////// 01088 // Function: EggTexture::Combiner::Constructor 01089 // Access: Public 01090 // Description: 01091 //////////////////////////////////////////////////////////////////// 01092 INLINE EggTexture::Combiner:: 01093 Combiner() : 01094 _mode(CM_unspecified) 01095 { 01096 } 01097 01098 //////////////////////////////////////////////////////////////////// 01099 // Function: UniqueEggTextures::Constructor 01100 // Access: Published 01101 // Description: 01102 //////////////////////////////////////////////////////////////////// 01103 INLINE UniqueEggTextures:: 01104 UniqueEggTextures(int eq) : _eq(eq) { 01105 } 01106 01107 //////////////////////////////////////////////////////////////////// 01108 // Function: UniqueEggTextures::Function operator 01109 // Access: Published 01110 // Description: 01111 //////////////////////////////////////////////////////////////////// 01112 INLINE bool UniqueEggTextures:: 01113 operator ()(const EggTexture *t1, const EggTexture *t2) const { 01114 return t1->sorts_less_than(*t2, _eq); 01115 } 01116