00001 // Filename: eggGroup.I 00002 // Created by: drose (16Jan99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: EggGroup::get_group_type 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE EggGroup::GroupType EggGroup:: 00026 get_group_type() const { 00027 return (GroupType)(_flags & F_group_type); 00028 } 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Function: EggGroup::is_instance_type 00032 // Access: Public 00033 // Description: Returns true if this group is an instance type node; 00034 // i.e. it begins the root of a local coordinate space. 00035 // This is not related to instancing (multiple copies of 00036 // a node in a scene graph). 00037 // 00038 // This also includes the case of the node including a 00039 // billboard flag without an explicit center, which 00040 // implicitly makes the node behave like an instance. 00041 //////////////////////////////////////////////////////////////////// 00042 INLINE bool EggGroup:: 00043 is_instance_type() const { 00044 return 00045 (get_group_type() == GT_instance) || 00046 (get_billboard_type() != BT_none && !has_billboard_center()); 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: EggGroup::set_billboard_type 00051 // Access: Public 00052 // Description: 00053 //////////////////////////////////////////////////////////////////// 00054 INLINE void EggGroup:: 00055 set_billboard_type(BillboardType type) { 00056 // Make sure the user didn't give us any stray bits. 00057 nassertv((type & ~F_billboard_type)==0); 00058 _flags = (_flags & ~F_billboard_type) | type; 00059 // This may change the transform space of this node. 00060 update_under(0); 00061 } 00062 00063 //////////////////////////////////////////////////////////////////// 00064 // Function: EggGroup::get_billboard_type 00065 // Access: Public 00066 // Description: 00067 //////////////////////////////////////////////////////////////////// 00068 INLINE EggGroup::BillboardType EggGroup:: 00069 get_billboard_type() const { 00070 return (BillboardType)(_flags & F_billboard_type); 00071 } 00072 00073 //////////////////////////////////////////////////////////////////// 00074 // Function: EggGroup::set_billboard_center 00075 // Access: Public 00076 // Description: Sets the point around which the billboard will 00077 // rotate, if this node contains a billboard 00078 // specification. 00079 // 00080 // If a billboard type is given but no billboard_center 00081 // is specified, then the group node is treated as an 00082 // <Instance>, and the billboard rotates around the 00083 // origin. If, however, a billboard_center is 00084 // specified, then the group node is *not* treated as an 00085 // <Instance>, and the billboard rotates around the 00086 // specified point. 00087 // 00088 // The point is in the same coordinate system as the 00089 // vertices of this node: usually global, but possibly 00090 // local if there is an <Instance> somewhere above. 00091 // Specifically, this is the coordinate system defined 00092 // by get_vertex_frame(). 00093 //////////////////////////////////////////////////////////////////// 00094 INLINE void EggGroup:: 00095 set_billboard_center(const LPoint3d &billboard_center) { 00096 _billboard_center = billboard_center; 00097 _flags2 |= F2_billboard_center; 00098 // This may change the transform space of this node. 00099 update_under(0); 00100 } 00101 00102 //////////////////////////////////////////////////////////////////// 00103 // Function: EggGroup::clear_billboard_center 00104 // Access: Public 00105 // Description: 00106 //////////////////////////////////////////////////////////////////// 00107 INLINE void EggGroup:: 00108 clear_billboard_center() { 00109 _flags2 &= ~F2_billboard_center; 00110 // This may change the transform space of this node. 00111 update_under(0); 00112 } 00113 00114 //////////////////////////////////////////////////////////////////// 00115 // Function: EggGroup::has_billboard_center 00116 // Access: Public 00117 // Description: 00118 //////////////////////////////////////////////////////////////////// 00119 INLINE bool EggGroup:: 00120 has_billboard_center() const { 00121 return (_flags2 & F2_billboard_center) != 0; 00122 } 00123 00124 //////////////////////////////////////////////////////////////////// 00125 // Function: EggGroup::get_billboard_center 00126 // Access: Public 00127 // Description: 00128 //////////////////////////////////////////////////////////////////// 00129 INLINE const LPoint3d &EggGroup:: 00130 get_billboard_center() const { 00131 nassertr(has_billboard_center(), _billboard_center); 00132 return _billboard_center; 00133 } 00134 00135 //////////////////////////////////////////////////////////////////// 00136 // Function: EggGroup::set_cs_type 00137 // Access: Public 00138 // Description: 00139 //////////////////////////////////////////////////////////////////// 00140 INLINE void EggGroup:: 00141 set_cs_type(CollisionSolidType type) { 00142 // Make sure the user didn't give us any stray bits. 00143 nassertv((type & ~F_cs_type)==0); 00144 _flags = (_flags & ~F_cs_type) | type; 00145 } 00146 00147 //////////////////////////////////////////////////////////////////// 00148 // Function: EggGroup::get_cs_type 00149 // Access: Public 00150 // Description: 00151 //////////////////////////////////////////////////////////////////// 00152 INLINE EggGroup::CollisionSolidType EggGroup:: 00153 get_cs_type() const { 00154 return (CollisionSolidType)(_flags & F_cs_type); 00155 } 00156 00157 //////////////////////////////////////////////////////////////////// 00158 // Function: EggGroup::set_collision_name 00159 // Access: Public 00160 // Description: 00161 //////////////////////////////////////////////////////////////////// 00162 INLINE void EggGroup:: 00163 set_collision_name(const string &collision_name) { 00164 _collision_name = collision_name; 00165 } 00166 00167 //////////////////////////////////////////////////////////////////// 00168 // Function: EggGroup::clear_collision_name 00169 // Access: Public 00170 // Description: 00171 //////////////////////////////////////////////////////////////////// 00172 INLINE void EggGroup:: 00173 clear_collision_name() { 00174 _collision_name = ""; 00175 } 00176 00177 //////////////////////////////////////////////////////////////////// 00178 // Function: EggGroup::has_collision_name 00179 // Access: Public 00180 // Description: 00181 //////////////////////////////////////////////////////////////////// 00182 INLINE bool EggGroup:: 00183 has_collision_name() const { 00184 return !_collision_name.empty(); 00185 } 00186 00187 //////////////////////////////////////////////////////////////////// 00188 // Function: EggGroup::get_collision_name 00189 // Access: Public 00190 // Description: 00191 //////////////////////////////////////////////////////////////////// 00192 INLINE const string &EggGroup:: 00193 get_collision_name() const { 00194 return _collision_name; 00195 } 00196 00197 //////////////////////////////////////////////////////////////////// 00198 // Function: EggGroup::set_collide_flags 00199 // Access: Public 00200 // Description: 00201 //////////////////////////////////////////////////////////////////// 00202 INLINE void EggGroup:: 00203 set_collide_flags(int flags) { 00204 // Make sure the user didn't give us any stray bits. 00205 nassertv((flags & ~F_collide_flags)==0); 00206 _flags = (_flags & ~F_collide_flags) | flags; 00207 } 00208 00209 //////////////////////////////////////////////////////////////////// 00210 // Function: EggGroup::get_collide_flags 00211 // Access: Public 00212 // Description: 00213 //////////////////////////////////////////////////////////////////// 00214 INLINE EggGroup::CollideFlags EggGroup:: 00215 get_collide_flags() const { 00216 return (EggGroup::CollideFlags)(_flags & F_collide_flags); 00217 } 00218 00219 //////////////////////////////////////////////////////////////////// 00220 // Function: EggGroup::set_dcs_type 00221 // Access: Public 00222 // Description: 00223 //////////////////////////////////////////////////////////////////// 00224 INLINE void EggGroup:: 00225 set_dcs_type(EggGroup::DCSType type) { 00226 // Make sure the user didn't give us any stray bits. 00227 nassertv((type & ~F2_dcs_type)==0); 00228 _flags2 = (_flags2 & ~F2_dcs_type) | type; 00229 } 00230 00231 //////////////////////////////////////////////////////////////////// 00232 // Function: EggGroup::get_dcs_type 00233 // Access: Public 00234 // Description: 00235 //////////////////////////////////////////////////////////////////// 00236 INLINE EggGroup::DCSType EggGroup:: 00237 get_dcs_type() const { 00238 return (DCSType)(_flags2 & F2_dcs_type); 00239 } 00240 00241 //////////////////////////////////////////////////////////////////// 00242 // Function: EggGroup::set_dart_type 00243 // Access: Public 00244 // Description: 00245 //////////////////////////////////////////////////////////////////// 00246 INLINE void EggGroup:: 00247 set_dart_type(EggGroup::DartType type) { 00248 // Make sure the user didn't give us any stray bits. 00249 nassertv((type & ~F_dart_type)==0); 00250 _flags = (_flags & ~F_dart_type) | type; 00251 } 00252 00253 //////////////////////////////////////////////////////////////////// 00254 // Function: EggGroup::get_dart_type 00255 // Access: Public 00256 // Description: 00257 //////////////////////////////////////////////////////////////////// 00258 INLINE EggGroup::DartType EggGroup:: 00259 get_dart_type() const { 00260 return (DartType)(_flags & F_dart_type); 00261 } 00262 00263 //////////////////////////////////////////////////////////////////// 00264 // Function: EggGroup::set_switch_flag 00265 // Access: Public 00266 // Description: 00267 //////////////////////////////////////////////////////////////////// 00268 INLINE void EggGroup:: 00269 set_switch_flag(bool flag) { 00270 if (flag) { 00271 _flags |= F_switch_flag; 00272 } else { 00273 _flags &= ~F_switch_flag; 00274 } 00275 } 00276 00277 //////////////////////////////////////////////////////////////////// 00278 // Function: EggGroup::get_switch_flag 00279 // Access: Public 00280 // Description: 00281 //////////////////////////////////////////////////////////////////// 00282 INLINE bool EggGroup:: 00283 get_switch_flag() const { 00284 return ((_flags & F_switch_flag) != 0); 00285 } 00286 00287 //////////////////////////////////////////////////////////////////// 00288 // Function: EggGroup::set_switch_fps 00289 // Access: Public 00290 // Description: 00291 //////////////////////////////////////////////////////////////////// 00292 INLINE void EggGroup:: 00293 set_switch_fps(double fps) { 00294 _fps = fps; 00295 } 00296 00297 //////////////////////////////////////////////////////////////////// 00298 // Function: EggGroup::get_switch_fps 00299 // Access: Public 00300 // Description: 00301 //////////////////////////////////////////////////////////////////// 00302 INLINE double EggGroup:: 00303 get_switch_fps() const { 00304 return _fps; 00305 } 00306 00307 //////////////////////////////////////////////////////////////////// 00308 // Function: EggGroup::add_object_type 00309 // Access: Public 00310 // Description: 00311 //////////////////////////////////////////////////////////////////// 00312 INLINE void EggGroup:: 00313 add_object_type(const string &object_type) { 00314 _object_types.push_back(object_type); 00315 } 00316 00317 //////////////////////////////////////////////////////////////////// 00318 // Function: EggGroup::clear_object_types 00319 // Access: Public 00320 // Description: 00321 //////////////////////////////////////////////////////////////////// 00322 INLINE void EggGroup:: 00323 clear_object_types() { 00324 _object_types.clear(); 00325 } 00326 00327 //////////////////////////////////////////////////////////////////// 00328 // Function: EggGroup::get_num_object_types 00329 // Access: Public 00330 // Description: 00331 //////////////////////////////////////////////////////////////////// 00332 INLINE int EggGroup:: 00333 get_num_object_types() const { 00334 return _object_types.size(); 00335 } 00336 00337 //////////////////////////////////////////////////////////////////// 00338 // Function: EggGroup::get_object_type 00339 // Access: Public 00340 // Description: 00341 //////////////////////////////////////////////////////////////////// 00342 INLINE string EggGroup:: 00343 get_object_type(int index) const { 00344 nassertr(index >= 0 && index < (int)_object_types.size(), string()); 00345 return _object_types[index]; 00346 } 00347 00348 //////////////////////////////////////////////////////////////////// 00349 // Function: EggGroup::set_model_flag 00350 // Access: Public 00351 // Description: 00352 //////////////////////////////////////////////////////////////////// 00353 INLINE void EggGroup:: 00354 set_model_flag(bool flag) { 00355 if (flag) { 00356 _flags |= F_model_flag; 00357 } else { 00358 _flags &= ~F_model_flag; 00359 } 00360 } 00361 00362 //////////////////////////////////////////////////////////////////// 00363 // Function: EggGroup::get_model_flag 00364 // Access: Public 00365 // Description: 00366 //////////////////////////////////////////////////////////////////// 00367 INLINE bool EggGroup:: 00368 get_model_flag() const { 00369 return ((_flags & F_model_flag) != 0); 00370 } 00371 00372 //////////////////////////////////////////////////////////////////// 00373 // Function: EggGroup::set_texlist_flag 00374 // Access: Public 00375 // Description: 00376 //////////////////////////////////////////////////////////////////// 00377 INLINE void EggGroup:: 00378 set_texlist_flag(bool flag) { 00379 if (flag) { 00380 _flags |= F_texlist_flag; 00381 } else { 00382 _flags &= ~F_texlist_flag; 00383 } 00384 } 00385 00386 //////////////////////////////////////////////////////////////////// 00387 // Function: EggGroup::get_texlist_flag 00388 // Access: Public 00389 // Description: 00390 //////////////////////////////////////////////////////////////////// 00391 INLINE bool EggGroup:: 00392 get_texlist_flag() const { 00393 return ((_flags & F_texlist_flag) != 0); 00394 } 00395 00396 //////////////////////////////////////////////////////////////////// 00397 // Function: EggGroup::set_nofog_flag 00398 // Access: Public 00399 // Description: 00400 //////////////////////////////////////////////////////////////////// 00401 INLINE void EggGroup:: 00402 set_nofog_flag(bool flag) { 00403 if (flag) { 00404 _flags |= F_nofog_flag; 00405 } else { 00406 _flags &= ~F_nofog_flag; 00407 } 00408 } 00409 00410 //////////////////////////////////////////////////////////////////// 00411 // Function: EggGroup::get_nofog_flag 00412 // Access: Public 00413 // Description: 00414 //////////////////////////////////////////////////////////////////// 00415 INLINE bool EggGroup:: 00416 get_nofog_flag() const { 00417 return ((_flags & F_nofog_flag) != 0); 00418 } 00419 00420 //////////////////////////////////////////////////////////////////// 00421 // Function: EggGroup::set_decal_flag 00422 // Access: Public 00423 // Description: 00424 //////////////////////////////////////////////////////////////////// 00425 INLINE void EggGroup:: 00426 set_decal_flag(bool flag) { 00427 if (flag) { 00428 _flags |= F_decal_flag; 00429 } else { 00430 _flags &= ~F_decal_flag; 00431 } 00432 } 00433 00434 //////////////////////////////////////////////////////////////////// 00435 // Function: EggGroup::get_decal_flag 00436 // Access: Public 00437 // Description: 00438 //////////////////////////////////////////////////////////////////// 00439 INLINE bool EggGroup:: 00440 get_decal_flag() const { 00441 return ((_flags & F_decal_flag) != 0); 00442 } 00443 00444 //////////////////////////////////////////////////////////////////// 00445 // Function: EggGroup::set_direct_flag 00446 // Access: Public 00447 // Description: 00448 //////////////////////////////////////////////////////////////////// 00449 INLINE void EggGroup:: 00450 set_direct_flag(bool flag) { 00451 if (flag) { 00452 _flags |= F_direct_flag; 00453 } else { 00454 _flags &= ~F_direct_flag; 00455 } 00456 } 00457 00458 //////////////////////////////////////////////////////////////////// 00459 // Function: EggGroup::get_direct_flag 00460 // Access: Public 00461 // Description: 00462 //////////////////////////////////////////////////////////////////// 00463 INLINE bool EggGroup:: 00464 get_direct_flag() const { 00465 return ((_flags & F_direct_flag) != 0); 00466 } 00467 00468 00469 //////////////////////////////////////////////////////////////////// 00470 // Function: EggGroup::set_collide_mask 00471 // Access: Public 00472 // Description: 00473 //////////////////////////////////////////////////////////////////// 00474 INLINE void EggGroup:: 00475 set_collide_mask(CollideMask mask) { 00476 _collide_mask = mask; 00477 _flags2 |= F2_collide_mask; 00478 } 00479 00480 //////////////////////////////////////////////////////////////////// 00481 // Function: EggGroup::clear_collide_mask 00482 // Access: Public 00483 // Description: 00484 //////////////////////////////////////////////////////////////////// 00485 INLINE void EggGroup:: 00486 clear_collide_mask() { 00487 _flags2 &= ~F2_collide_mask; 00488 } 00489 00490 //////////////////////////////////////////////////////////////////// 00491 // Function: EggGroup::has_collide_mask 00492 // Access: Public 00493 // Description: 00494 //////////////////////////////////////////////////////////////////// 00495 INLINE bool EggGroup:: 00496 has_collide_mask() const { 00497 return (_flags2 & F2_collide_mask) != 0; 00498 } 00499 00500 //////////////////////////////////////////////////////////////////// 00501 // Function: EggGroup::get_collide_mask 00502 // Access: Public 00503 // Description: 00504 //////////////////////////////////////////////////////////////////// 00505 INLINE CollideMask EggGroup:: 00506 get_collide_mask() const { 00507 nassertr(has_collide_mask(), CollideMask()); 00508 return _collide_mask; 00509 } 00510 00511 //////////////////////////////////////////////////////////////////// 00512 // Function: EggGroup::set_from_collide_mask 00513 // Access: Public 00514 // Description: 00515 //////////////////////////////////////////////////////////////////// 00516 INLINE void EggGroup:: 00517 set_from_collide_mask(CollideMask mask) { 00518 _from_collide_mask = mask; 00519 _flags2 |= F2_from_collide_mask; 00520 } 00521 00522 //////////////////////////////////////////////////////////////////// 00523 // Function: EggGroup::clear_from_collide_mask 00524 // Access: Public 00525 // Description: 00526 //////////////////////////////////////////////////////////////////// 00527 INLINE void EggGroup:: 00528 clear_from_collide_mask() { 00529 _flags2 &= ~F2_from_collide_mask; 00530 } 00531 00532 //////////////////////////////////////////////////////////////////// 00533 // Function: EggGroup::has_from_collide_mask 00534 // Access: Public 00535 // Description: 00536 //////////////////////////////////////////////////////////////////// 00537 INLINE bool EggGroup:: 00538 has_from_collide_mask() const { 00539 return (_flags2 & F2_from_collide_mask) != 0; 00540 } 00541 00542 //////////////////////////////////////////////////////////////////// 00543 // Function: EggGroup::get_from_collide_mask 00544 // Access: Public 00545 // Description: 00546 //////////////////////////////////////////////////////////////////// 00547 INLINE CollideMask EggGroup:: 00548 get_from_collide_mask() const { 00549 nassertr(has_from_collide_mask(), CollideMask()); 00550 return _from_collide_mask; 00551 } 00552 00553 //////////////////////////////////////////////////////////////////// 00554 // Function: EggGroup::set_into_collide_mask 00555 // Access: Public 00556 // Description: 00557 //////////////////////////////////////////////////////////////////// 00558 INLINE void EggGroup:: 00559 set_into_collide_mask(CollideMask mask) { 00560 _into_collide_mask = mask; 00561 _flags2 |= F2_into_collide_mask; 00562 } 00563 00564 //////////////////////////////////////////////////////////////////// 00565 // Function: EggGroup::clear_into_collide_mask 00566 // Access: Public 00567 // Description: 00568 //////////////////////////////////////////////////////////////////// 00569 INLINE void EggGroup:: 00570 clear_into_collide_mask() { 00571 _flags2 &= ~F2_into_collide_mask; 00572 } 00573 00574 //////////////////////////////////////////////////////////////////// 00575 // Function: EggGroup::has_into_collide_mask 00576 // Access: Public 00577 // Description: 00578 //////////////////////////////////////////////////////////////////// 00579 INLINE bool EggGroup:: 00580 has_into_collide_mask() const { 00581 return (_flags2 & F2_into_collide_mask) != 0; 00582 } 00583 00584 //////////////////////////////////////////////////////////////////// 00585 // Function: EggGroup::get_into_collide_mask 00586 // Access: Public 00587 // Description: 00588 //////////////////////////////////////////////////////////////////// 00589 INLINE CollideMask EggGroup:: 00590 get_into_collide_mask() const { 00591 nassertr(has_into_collide_mask(), CollideMask()); 00592 return _into_collide_mask; 00593 } 00594 00595 //////////////////////////////////////////////////////////////////// 00596 // Function: EggGroup::set_lod 00597 // Access: Public 00598 // Description: 00599 //////////////////////////////////////////////////////////////////// 00600 INLINE void EggGroup:: 00601 set_lod(const EggSwitchCondition &lod) { 00602 _lod = lod.make_copy(); 00603 } 00604 00605 //////////////////////////////////////////////////////////////////// 00606 // Function: EggGroup::clear_lod 00607 // Access: Public 00608 // Description: 00609 //////////////////////////////////////////////////////////////////// 00610 INLINE void EggGroup:: 00611 clear_lod() { 00612 _lod = NULL; 00613 } 00614 00615 //////////////////////////////////////////////////////////////////// 00616 // Function: EggGroup::has_lod 00617 // Access: Public 00618 // Description: 00619 //////////////////////////////////////////////////////////////////// 00620 INLINE bool EggGroup:: 00621 has_lod() const { 00622 return (_lod != (EggSwitchCondition *)NULL); 00623 } 00624 00625 //////////////////////////////////////////////////////////////////// 00626 // Function: EggGroup::get_lod 00627 // Access: Public 00628 // Description: 00629 //////////////////////////////////////////////////////////////////// 00630 INLINE const EggSwitchCondition &EggGroup:: 00631 get_lod() const { 00632 return *_lod; 00633 } 00634 00635 00636 //////////////////////////////////////////////////////////////////// 00637 // Function: EggGroup::vref_begin 00638 // Access: Public 00639 // Description: Returns an iterator that can, in conjunction with 00640 // vref_end(), be used to traverse the entire set of 00641 // referenced vertices. Each iterator returns a 00642 // pair<PT(EggVertex), double>. 00643 // 00644 // This interface is not safe to use outside of 00645 // PANDAEGG.DLL. 00646 //////////////////////////////////////////////////////////////////// 00647 INLINE EggGroup::VertexRef::const_iterator EggGroup:: 00648 vref_begin() const { 00649 return _vref.begin(); 00650 } 00651 00652 //////////////////////////////////////////////////////////////////// 00653 // Function: EggGroup::vref_end 00654 // Access: Public 00655 // Description: Returns an iterator that can, in conjunction with 00656 // vref_begin(), be used to traverse the entire set of 00657 // referenced vertices. Each iterator returns a 00658 // pair<PT(EggVertex), double>. 00659 // 00660 // This interface is not safe to use outside of 00661 // PANDAEGG.DLL. 00662 //////////////////////////////////////////////////////////////////// 00663 INLINE EggGroup::VertexRef::const_iterator EggGroup:: 00664 vref_end() const { 00665 return _vref.end(); 00666 } 00667 00668 //////////////////////////////////////////////////////////////////// 00669 // Function: EggGrop::vref_size 00670 // Access: Public 00671 // Description: Returns the number of elements between vref_begin() 00672 // and vref_end(). 00673 // 00674 // This interface is not safe to use outside of 00675 // PANDAEGG.DLL. 00676 //////////////////////////////////////////////////////////////////// 00677 INLINE EggGroup::VertexRef::size_type EggGroup:: 00678 vref_size() const { 00679 return _vref.size(); 00680 }