Panda3D
|
00001 // Filename: nodePath.I 00002 // Created by: drose (25Feb02) 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: NodePath::Default Constructor 00018 // Access: Published 00019 // Description: This constructs an empty NodePath with no nodes. 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE NodePath:: 00022 NodePath() : 00023 _error_type(ET_ok) 00024 { 00025 _backup_key = 0; 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: NodePath::Constructor 00030 // Access: Published 00031 // Description: This constructs a new NodePath with a single 00032 // node. An ordinary, unattached PandaNode is created 00033 // with the indicated name. 00034 //////////////////////////////////////////////////////////////////// 00035 INLINE NodePath:: 00036 NodePath(const string &top_node_name, Thread *current_thread) : 00037 _error_type(ET_ok) 00038 { 00039 PandaNode *top_node = new PandaNode(top_node_name); 00040 int pipeline_stage = current_thread->get_pipeline_stage(); 00041 _head = top_node->get_generic_component(false, pipeline_stage, current_thread); 00042 _backup_key = 0; 00043 } 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function: NodePath::Constructor 00047 // Access: Published 00048 // Description: This constructs a NodePath for the indicated node. 00049 // If the node does not have any parents, this creates a 00050 // singleton NodePath; otherwise, it automatically finds 00051 // the path from the node to the root. If the node has 00052 // multiple paths to the root, one path is chosen 00053 // arbitrarily and a warning message is printed (but see 00054 // also NodePath::any_path(), below). 00055 //////////////////////////////////////////////////////////////////// 00056 INLINE NodePath:: 00057 NodePath(PandaNode *node, Thread *current_thread) : 00058 _error_type(ET_ok) 00059 { 00060 if (node != (PandaNode *)NULL) { 00061 int pipeline_stage = current_thread->get_pipeline_stage(); 00062 _head = node->get_generic_component(false, pipeline_stage, current_thread); 00063 } 00064 _backup_key = 0; 00065 } 00066 00067 //////////////////////////////////////////////////////////////////// 00068 // Function: NodePath::any_path named constructor 00069 // Access: Published, Static 00070 // Description: Returns a new NodePath that represents any arbitrary 00071 // path from the root to the indicated node. This is 00072 // the same thing that would be returned by 00073 // NodePath(node), except that no warning is issued if 00074 // the path is ambiguous. 00075 //////////////////////////////////////////////////////////////////// 00076 INLINE NodePath NodePath:: 00077 any_path(PandaNode *node, Thread *current_thread) { 00078 NodePath result; 00079 if (node != (PandaNode *)NULL) { 00080 int pipeline_stage = current_thread->get_pipeline_stage(); 00081 result._head = node->get_generic_component(true, pipeline_stage, 00082 current_thread); 00083 } 00084 return result; 00085 } 00086 00087 //////////////////////////////////////////////////////////////////// 00088 // Function: NodePath::Copy Constructor 00089 // Access: Published 00090 // Description: 00091 //////////////////////////////////////////////////////////////////// 00092 INLINE NodePath:: 00093 NodePath(const NodePath ©) : 00094 _head(copy._head), 00095 _backup_key(copy._backup_key), 00096 _error_type(copy._error_type) 00097 { 00098 } 00099 00100 //////////////////////////////////////////////////////////////////// 00101 // Function: NodePath::Copy Assignment Operator 00102 // Access: Published 00103 // Description: 00104 //////////////////////////////////////////////////////////////////// 00105 INLINE void NodePath:: 00106 operator = (const NodePath ©) { 00107 _head = copy._head; 00108 _backup_key = copy._backup_key; 00109 _error_type = copy._error_type; 00110 } 00111 00112 //////////////////////////////////////////////////////////////////// 00113 // Function: NodePath::not_found named constructor 00114 // Access: Published, Static 00115 // Description: Creates a NodePath with the ET_not_found error type 00116 // set. 00117 //////////////////////////////////////////////////////////////////// 00118 INLINE NodePath NodePath:: 00119 not_found() { 00120 NodePath result; 00121 result._error_type = ET_not_found; 00122 return result; 00123 } 00124 00125 //////////////////////////////////////////////////////////////////// 00126 // Function: NodePath::removed named constructor 00127 // Access: Published, Static 00128 // Description: Creates a NodePath with the ET_removed error type 00129 // set. 00130 //////////////////////////////////////////////////////////////////// 00131 INLINE NodePath NodePath:: 00132 removed() { 00133 NodePath result; 00134 result._error_type = ET_removed; 00135 return result; 00136 } 00137 00138 //////////////////////////////////////////////////////////////////// 00139 // Function: NodePath::fail named constructor 00140 // Access: Published, Static 00141 // Description: Creates a NodePath with the ET_fail error type 00142 // set. 00143 //////////////////////////////////////////////////////////////////// 00144 INLINE NodePath NodePath:: 00145 fail() { 00146 NodePath result; 00147 result._error_type = ET_fail; 00148 return result; 00149 } 00150 00151 //////////////////////////////////////////////////////////////////// 00152 // Function: NodePath::set_max_search_depth 00153 // Access: Published, Static 00154 // Description: Certain operations, such as find() or 00155 // find_all_matches(), require a traversal of the scene 00156 // graph to search for the target node or nodes. This 00157 // traversal does not attempt to detect cycles, so an 00158 // arbitrary cap is set on the depth of the traversal as 00159 // a poor man's cycle detection, in the event that a 00160 // cycle has inadvertently been introduced into the 00161 // scene graph. 00162 // 00163 // There may be other reasons you'd want to truncate a 00164 // search before the bottom of the scene graph has been 00165 // reached. In any event, this function sets the limit 00166 // on the number of levels that a traversal will 00167 // continue, and hence the maximum length of a path that 00168 // may be returned by a traversal. 00169 // 00170 // This is a static method, and so changing this 00171 // parameter affects all of the NodePaths in the 00172 // universe. 00173 //////////////////////////////////////////////////////////////////// 00174 INLINE void NodePath:: 00175 set_max_search_depth(int max_search_depth) { 00176 _max_search_depth = max_search_depth; 00177 } 00178 00179 //////////////////////////////////////////////////////////////////// 00180 // Function: NodePath::get_max_search_depth 00181 // Access: Published, Static 00182 // Description: Returns the current setting of the search depth 00183 // limit. See set_max_search_depth. 00184 //////////////////////////////////////////////////////////////////// 00185 INLINE int NodePath:: 00186 get_max_search_depth() { 00187 return _max_search_depth; 00188 } 00189 00190 //////////////////////////////////////////////////////////////////// 00191 // Function: NodePath::is_empty 00192 // Access: Published 00193 // Description: Returns true if the NodePath contains no nodes. 00194 //////////////////////////////////////////////////////////////////// 00195 INLINE bool NodePath:: 00196 is_empty() const { 00197 return (_head == (NodePathComponent *)NULL); 00198 } 00199 00200 //////////////////////////////////////////////////////////////////// 00201 // Function: NodePath::is_singleton 00202 // Access: Published 00203 // Description: Returns true if the NodePath contains exactly one 00204 // node. 00205 //////////////////////////////////////////////////////////////////// 00206 INLINE bool NodePath:: 00207 is_singleton(Thread *current_thread) const { 00208 int pipeline_stage = current_thread->get_pipeline_stage(); 00209 return (_head != (NodePathComponent *)NULL && _head->is_top_node(pipeline_stage, current_thread)); 00210 } 00211 00212 //////////////////////////////////////////////////////////////////// 00213 // Function: NodePath::get_error_type 00214 // Access: Published 00215 // Description: If is_empty() is true, this returns a code that 00216 // represents the reason why the NodePath is empty. 00217 //////////////////////////////////////////////////////////////////// 00218 INLINE NodePath::ErrorType NodePath:: 00219 get_error_type() const { 00220 return _error_type; 00221 } 00222 00223 //////////////////////////////////////////////////////////////////// 00224 // Function: NodePath::get_top_node 00225 // Access: Published 00226 // Description: Returns the top node of the path, or NULL if the path 00227 // is empty. This requires iterating through the path. 00228 //////////////////////////////////////////////////////////////////// 00229 INLINE PandaNode *NodePath:: 00230 get_top_node(Thread *current_thread) const { 00231 if (is_empty()) { 00232 return (PandaNode *)NULL; 00233 } 00234 00235 return get_top(current_thread).node(); 00236 } 00237 00238 //////////////////////////////////////////////////////////////////// 00239 // Function: NodePath::node 00240 // Access: Published 00241 // Description: Returns the referenced node of the path. 00242 //////////////////////////////////////////////////////////////////// 00243 INLINE PandaNode *NodePath:: 00244 node() const { 00245 nassertr_always(!is_empty(), (PandaNode *)NULL); 00246 return _head->get_node(); 00247 } 00248 00249 //////////////////////////////////////////////////////////////////// 00250 // Function: NodePath::get_key 00251 // Access: Published 00252 // Description: Returns an integer that is guaranteed to be the same 00253 // for all NodePaths that represent the same node 00254 // instance, and different for all NodePaths that 00255 // represent a different node instance. 00256 // 00257 // The same key will be returned for a particular 00258 // instance as long as at least one NodePath exists that 00259 // represents that instance; if all NodePaths for a 00260 // particular instance destruct and a new one is later 00261 // created, it may have a different index. However, a 00262 // given key will never be reused for a different 00263 // instance (unless the app has been running long enough 00264 // that we overflow the integer key value). 00265 //////////////////////////////////////////////////////////////////// 00266 INLINE int NodePath:: 00267 get_key() const { 00268 if (is_empty()) { 00269 return _backup_key; 00270 } 00271 return _head->get_key(); 00272 } 00273 00274 //////////////////////////////////////////////////////////////////// 00275 // Function: NodePath::is_same_graph 00276 // Access: Published 00277 // Description: Returns true if the node represented by this NodePath 00278 // is parented within the same graph as that of the 00279 // other NodePath. This is essentially the same thing 00280 // as asking whether get_top() of both NodePaths is the 00281 // same (e.g., both "render"). 00282 //////////////////////////////////////////////////////////////////// 00283 INLINE bool NodePath:: 00284 is_same_graph(const NodePath &other, Thread *current_thread) const { 00285 // Actually, it's possible for the top nodes to be the same, but the 00286 // NodePaths still to be considered in different graphs. But even 00287 // in this case, get_top() will be different for each one. (They'll 00288 // be different singleton NodePaths that happen to reference the 00289 // same node). 00290 00291 // This will happen if one of the top nodes is considered a 00292 // different instance--for instance, render.instance_to(NodePath()) 00293 // returns a different instance of render that appears to have the 00294 // same top node. But this is a very rare thing to do. 00295 int a_count, b_count; 00296 return (find_common_ancestor(*this, other, a_count, b_count, current_thread) != (NodePathComponent *)NULL); 00297 } 00298 00299 //////////////////////////////////////////////////////////////////// 00300 // Function: NodePath::is_ancestor_of 00301 // Access: Published 00302 // Description: Returns true if the node represented by this NodePath 00303 // is a parent or other ancestor of the other NodePath, 00304 // or false if it is not. 00305 //////////////////////////////////////////////////////////////////// 00306 INLINE bool NodePath:: 00307 is_ancestor_of(const NodePath &other, Thread *current_thread) const { 00308 int a_count, b_count; 00309 if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == (NodePathComponent *)NULL) { 00310 // Not related. 00311 return false; 00312 } 00313 00314 // They are related; now b is descended from a only if a is the 00315 // common ancestor (which is to say, a_count == 0). 00316 return (a_count == 0); 00317 } 00318 00319 //////////////////////////////////////////////////////////////////// 00320 // Function: NodePath::get_common_ancestor 00321 // Access: Published 00322 // Description: Returns the lowest NodePath that both of these two 00323 // NodePaths have in common: the first ancestor that 00324 // both of them share. If the two NodePaths are 00325 // unrelated, returns NodePath::not_found(). 00326 //////////////////////////////////////////////////////////////////// 00327 INLINE NodePath NodePath:: 00328 get_common_ancestor(const NodePath &other, Thread *current_thread) const { 00329 int a_count, b_count; 00330 NodePathComponent *common = find_common_ancestor(*this, other, a_count, b_count, current_thread); 00331 if (common == (NodePathComponent *)NULL) { 00332 return NodePath::not_found(); 00333 } 00334 00335 NodePath result; 00336 result._head = common; 00337 return result; 00338 } 00339 00340 //////////////////////////////////////////////////////////////////// 00341 // Function: NodePath::get_num_children 00342 // Access: Published 00343 // Description: Returns the number of children of the referenced node. 00344 //////////////////////////////////////////////////////////////////// 00345 INLINE int NodePath:: 00346 get_num_children(Thread *current_thread) const { 00347 nassertr_always(!is_empty(), 0); 00348 return _head->get_node()->get_num_children(current_thread); 00349 } 00350 00351 //////////////////////////////////////////////////////////////////// 00352 // Function: NodePath::get_child 00353 // Access: Published 00354 // Description: Returns a NodePath representing the nth child of the 00355 // referenced node. 00356 //////////////////////////////////////////////////////////////////// 00357 INLINE NodePath NodePath:: 00358 get_child(int n, Thread *current_thread) const { 00359 nassertr_always(n >= 0 && n < get_num_children(current_thread), NodePath()); 00360 NodePath child; 00361 int pipeline_stage = current_thread->get_pipeline_stage(); 00362 child._head = PandaNode::get_component(_head, _head->get_node()->get_child(n, current_thread), 00363 pipeline_stage, current_thread); 00364 return child; 00365 } 00366 00367 //////////////////////////////////////////////////////////////////// 00368 // Function: NodePath::count_num_descendants 00369 // Access: Published 00370 // Description: Returns the number of nodes at and below this level. 00371 //////////////////////////////////////////////////////////////////// 00372 INLINE int NodePath:: 00373 count_num_descendants() const { 00374 if (is_empty()) { 00375 return 0; 00376 } 00377 return _head->get_node()->count_num_descendants(); 00378 } 00379 00380 //////////////////////////////////////////////////////////////////// 00381 // Function: NodePath::has_parent 00382 // Access: Published 00383 // Description: Returns true if the referenced node has a parent; 00384 // i.e. the NodePath chain contains at least two nodes. 00385 //////////////////////////////////////////////////////////////////// 00386 INLINE bool NodePath:: 00387 has_parent(Thread *current_thread) const { 00388 return !is_empty() && !is_singleton(current_thread); 00389 } 00390 00391 //////////////////////////////////////////////////////////////////// 00392 // Function: NodePath::get_parent 00393 // Access: Published 00394 // Description: Returns the NodePath to the parent of the referenced 00395 // node: that is, this NodePath, shortened by one node. 00396 // The parent of a singleton NodePath is defined to be 00397 // the empty NodePath. 00398 //////////////////////////////////////////////////////////////////// 00399 INLINE NodePath NodePath:: 00400 get_parent(Thread *current_thread) const { 00401 if (!has_parent(current_thread)) { 00402 return NodePath(); 00403 } 00404 00405 int pipeline_stage = current_thread->get_pipeline_stage(); 00406 00407 NodePath parent; 00408 parent._head = _head->get_next(pipeline_stage, current_thread); 00409 return parent; 00410 } 00411 00412 //////////////////////////////////////////////////////////////////// 00413 // Function: NodePath::attach_new_node 00414 // Access: Published 00415 // Description: Creates an ordinary PandaNode and attaches it below 00416 // the current NodePath, returning a new NodePath that 00417 // references it. 00418 //////////////////////////////////////////////////////////////////// 00419 INLINE NodePath NodePath:: 00420 attach_new_node(const string &name, int sort, Thread *current_thread) const { 00421 nassertr(verify_complete(current_thread), NodePath::fail()); 00422 00423 return attach_new_node(new PandaNode(name), sort, current_thread); 00424 } 00425 00426 //////////////////////////////////////////////////////////////////// 00427 // Function: NodePath::ls 00428 // Access: Published 00429 // Description: Lists the hierarchy at and below the referenced node. 00430 //////////////////////////////////////////////////////////////////// 00431 INLINE void NodePath:: 00432 ls() const { 00433 ls(nout); 00434 } 00435 00436 //////////////////////////////////////////////////////////////////// 00437 // Function: NodePath::ls 00438 // Access: Published 00439 // Description: Lists the hierarchy at and below the referenced node. 00440 //////////////////////////////////////////////////////////////////// 00441 INLINE void NodePath:: 00442 ls(ostream &out, int indent_level) const { 00443 if (is_empty()) { 00444 out << "(empty)\n"; 00445 } else { 00446 node()->ls(out, indent_level); 00447 } 00448 } 00449 00450 //////////////////////////////////////////////////////////////////// 00451 // Function: NodePath::reverse_ls 00452 // Access: Published 00453 // Description: Lists the hierarchy at and above the referenced node. 00454 //////////////////////////////////////////////////////////////////// 00455 INLINE void NodePath:: 00456 reverse_ls() const { 00457 reverse_ls(nout); 00458 } 00459 00460 //////////////////////////////////////////////////////////////////// 00461 // Function: NodePath::reverse_ls 00462 // Access: Published 00463 // Description: Lists the hierarchy at and above the referenced node. 00464 //////////////////////////////////////////////////////////////////// 00465 INLINE int NodePath:: 00466 reverse_ls(ostream &out, int indent_level) const { 00467 if (is_empty()) { 00468 out << "(empty)\n"; 00469 return 0; 00470 } else if (has_parent()) { 00471 indent_level = get_parent().reverse_ls(out, indent_level); 00472 } 00473 node()->write(out, indent_level); 00474 return indent_level + 2; 00475 } 00476 00477 //////////////////////////////////////////////////////////////////// 00478 // Function: NodePath::set_state 00479 // Access: Published 00480 // Description: Changes the complete state object on this node. 00481 //////////////////////////////////////////////////////////////////// 00482 INLINE void NodePath:: 00483 set_state(const RenderState *state, Thread *current_thread) { 00484 nassertv_always(!is_empty()); 00485 node()->set_state(state, current_thread); 00486 } 00487 00488 //////////////////////////////////////////////////////////////////// 00489 // Function: NodePath::get_net_state 00490 // Access: Published 00491 // Description: Returns the net state on this node from the root. 00492 //////////////////////////////////////////////////////////////////// 00493 INLINE CPT(RenderState) NodePath:: 00494 get_net_state(Thread *current_thread) const { 00495 nassertr(_error_type == ET_ok, RenderState::make_empty()); 00496 return r_get_net_state(_head, current_thread); 00497 } 00498 00499 //////////////////////////////////////////////////////////////////// 00500 // Function: NodePath::set_attrib 00501 // Access: Published 00502 // Description: Adds the indicated render attribute to the scene 00503 // graph on this node. This attribute will now apply to 00504 // this node and everything below. If there was already 00505 // an attribute of the same type, it is replaced. 00506 //////////////////////////////////////////////////////////////////// 00507 INLINE void NodePath:: 00508 set_attrib(const RenderAttrib *attrib, int priority) { 00509 nassertv_always(!is_empty()); 00510 node()->set_attrib(attrib, priority); 00511 } 00512 00513 //////////////////////////////////////////////////////////////////// 00514 // Function: NodePath::get_attrib 00515 // Access: Published 00516 // Description: Returns the render attribute of the indicated type, 00517 // if it is defined on the node, or NULL if it is not. 00518 // This checks only what is set on this particular node 00519 // level, and has nothing to do with what render 00520 // attributes may be inherited from parent nodes. 00521 //////////////////////////////////////////////////////////////////// 00522 INLINE const RenderAttrib *NodePath:: 00523 get_attrib(TypeHandle type) const { 00524 nassertr_always(!is_empty(), NULL); 00525 return node()->get_attrib(type); 00526 } 00527 00528 //////////////////////////////////////////////////////////////////// 00529 // Function: NodePath::has_attrib 00530 // Access: Published 00531 // Description: Returns true if there is a render attribute of the 00532 // indicated type defined on this node, or false if 00533 // there is not. 00534 //////////////////////////////////////////////////////////////////// 00535 INLINE bool NodePath:: 00536 has_attrib(TypeHandle type) const { 00537 nassertr_always(!is_empty(), false); 00538 return node()->has_attrib(type); 00539 } 00540 00541 //////////////////////////////////////////////////////////////////// 00542 // Function: NodePath::clear_attrib 00543 // Access: Published 00544 // Description: Removes the render attribute of the given type from 00545 // this node. This node, and the subgraph below, will 00546 // now inherit the indicated render attribute from the 00547 // nodes above this one. 00548 //////////////////////////////////////////////////////////////////// 00549 INLINE void NodePath:: 00550 clear_attrib(TypeHandle type) { 00551 nassertv_always(!is_empty()); 00552 node()->clear_attrib(type); 00553 } 00554 00555 //////////////////////////////////////////////////////////////////// 00556 // Function: NodePath::set_effect 00557 // Access: Published 00558 // Description: Adds the indicated render effect to the scene 00559 // graph on this node. If there was already an effect 00560 // of the same type, it is replaced. 00561 //////////////////////////////////////////////////////////////////// 00562 INLINE void NodePath:: 00563 set_effect(const RenderEffect *effect) { 00564 nassertv_always(!is_empty()); 00565 node()->set_effect(effect); 00566 } 00567 00568 //////////////////////////////////////////////////////////////////// 00569 // Function: NodePath::get_effect 00570 // Access: Published 00571 // Description: Returns the render effect of the indicated type, 00572 // if it is defined on the node, or NULL if it is not. 00573 //////////////////////////////////////////////////////////////////// 00574 INLINE const RenderEffect *NodePath:: 00575 get_effect(TypeHandle type) const { 00576 nassertr_always(!is_empty(), NULL); 00577 return node()->get_effect(type); 00578 } 00579 00580 //////////////////////////////////////////////////////////////////// 00581 // Function: NodePath::has_effect 00582 // Access: Published 00583 // Description: Returns true if there is a render effect of the 00584 // indicated type defined on this node, or false if 00585 // there is not. 00586 //////////////////////////////////////////////////////////////////// 00587 INLINE bool NodePath:: 00588 has_effect(TypeHandle type) const { 00589 nassertr_always(!is_empty(), false); 00590 return node()->has_effect(type); 00591 } 00592 00593 //////////////////////////////////////////////////////////////////// 00594 // Function: NodePath::clear_effect 00595 // Access: Published 00596 // Description: Removes the render effect of the given type from 00597 // this node. 00598 //////////////////////////////////////////////////////////////////// 00599 INLINE void NodePath:: 00600 clear_effect(TypeHandle type) { 00601 nassertv_always(!is_empty()); 00602 node()->clear_effect(type); 00603 } 00604 00605 //////////////////////////////////////////////////////////////////// 00606 // Function: NodePath::set_effects 00607 // Access: Published 00608 // Description: Sets the complete RenderEffects that will be applied 00609 // this node. This completely replaces whatever has 00610 // been set on this node via repeated calls to 00611 // set_attrib(). 00612 //////////////////////////////////////////////////////////////////// 00613 INLINE void NodePath:: 00614 set_effects(const RenderEffects *effects) { 00615 nassertv_always(!is_empty()); 00616 node()->set_effects(effects); 00617 } 00618 00619 //////////////////////////////////////////////////////////////////// 00620 // Function: NodePath::get_effects 00621 // Access: Published 00622 // Description: Returns the complete RenderEffects that will be 00623 // applied to this node. 00624 //////////////////////////////////////////////////////////////////// 00625 INLINE const RenderEffects *NodePath:: 00626 get_effects() const { 00627 nassertr_always(!is_empty(), RenderEffects::make_empty()); 00628 return node()->get_effects(); 00629 } 00630 00631 //////////////////////////////////////////////////////////////////// 00632 // Function: NodePath::clear_effects 00633 // Access: Published 00634 // Description: Resets this node to have no render effects. 00635 //////////////////////////////////////////////////////////////////// 00636 INLINE void NodePath:: 00637 clear_effects() { 00638 nassertv_always(!is_empty()); 00639 node()->clear_effects(); 00640 } 00641 00642 //////////////////////////////////////////////////////////////////// 00643 // Function: NodePath::clear_transform 00644 // Access: Published 00645 // Description: Sets the transform object on this node to identity. 00646 //////////////////////////////////////////////////////////////////// 00647 INLINE void NodePath:: 00648 clear_transform(Thread *current_thread) { 00649 set_transform(TransformState::make_identity(), current_thread); 00650 } 00651 00652 //////////////////////////////////////////////////////////////////// 00653 // Function: NodePath::set_transform 00654 // Access: Published 00655 // Description: Changes the complete transform object on this node. 00656 //////////////////////////////////////////////////////////////////// 00657 INLINE void NodePath:: 00658 set_transform(const TransformState *transform, Thread *current_thread) { 00659 nassertv_always(!is_empty()); 00660 node()->set_transform(transform, current_thread); 00661 } 00662 00663 //////////////////////////////////////////////////////////////////// 00664 // Function: NodePath::clear_transform 00665 // Access: Published 00666 // Description: Sets the transform object on this node to identity, 00667 // relative to the other node. This effectively places 00668 // this node at the same position as the other node. 00669 //////////////////////////////////////////////////////////////////// 00670 INLINE void NodePath:: 00671 clear_transform(const NodePath &other, Thread *current_thread) { 00672 set_transform(other, TransformState::make_identity(), current_thread); 00673 } 00674 00675 //////////////////////////////////////////////////////////////////// 00676 // Function: NodePath::get_net_transform 00677 // Access: Published 00678 // Description: Returns the net transform on this node from the root. 00679 //////////////////////////////////////////////////////////////////// 00680 INLINE CPT(TransformState) NodePath:: 00681 get_net_transform(Thread *current_thread) const { 00682 nassertr(_error_type == ET_ok, TransformState::make_identity()); 00683 return r_get_net_transform(_head, current_thread); 00684 } 00685 00686 //////////////////////////////////////////////////////////////////// 00687 // Function: NodePath::set_prev_transform 00688 // Access: Published 00689 // Description: Sets the transform that represents this node's 00690 // "previous" position, one frame ago, for the purposes 00691 // of detecting motion for accurate collision 00692 // calculations. 00693 //////////////////////////////////////////////////////////////////// 00694 INLINE void NodePath:: 00695 set_prev_transform(const TransformState *transform, Thread *current_thread) { 00696 nassertv_always(!is_empty()); 00697 node()->set_prev_transform(transform, current_thread); 00698 } 00699 00700 //////////////////////////////////////////////////////////////////// 00701 // Function: NodePath::get_net_prev_transform 00702 // Access: Published 00703 // Description: Returns the net "previous" transform on this node 00704 // from the root. See set_prev_transform(). 00705 //////////////////////////////////////////////////////////////////// 00706 INLINE CPT(TransformState) NodePath:: 00707 get_net_prev_transform(Thread *current_thread) const { 00708 nassertr(_error_type == ET_ok, TransformState::make_identity()); 00709 return r_get_net_prev_transform(_head, current_thread); 00710 } 00711 00712 //////////////////////////////////////////////////////////////////// 00713 // Function: NodePath::set_pos 00714 // Access: Published 00715 // Description: Sets the translation component of the transform, 00716 // leaving rotation and scale untouched. This also 00717 // resets the node's "previous" position, so that the 00718 // collision system will see the node as having suddenly 00719 // appeared in the new position, without passing any 00720 // points in between. 00721 //////////////////////////////////////////////////////////////////// 00722 INLINE void NodePath:: 00723 set_pos(float x, float y, float z) { 00724 set_pos(LPoint3f(x, y, z)); 00725 } 00726 00727 //////////////////////////////////////////////////////////////////// 00728 // Function: NodePath::set_fluid_pos 00729 // Access: Published 00730 // Description: Sets the translation component, without changing the 00731 // "previous" position, so that the collision system 00732 // will see the node as moving fluidly from its previous 00733 // position to its new position. 00734 //////////////////////////////////////////////////////////////////// 00735 INLINE void NodePath:: 00736 set_fluid_pos(float x, float y, float z) { 00737 set_fluid_pos(LPoint3f(x, y, z)); 00738 } 00739 00740 INLINE float NodePath:: 00741 get_x() const { 00742 return get_pos()[0]; 00743 } 00744 00745 INLINE float NodePath:: 00746 get_y() const { 00747 return get_pos()[1]; 00748 } 00749 00750 INLINE float NodePath:: 00751 get_z() const { 00752 return get_pos()[2]; 00753 } 00754 00755 //////////////////////////////////////////////////////////////////// 00756 // Function: NodePath::set_hpr 00757 // Access: Published 00758 // Description: Sets the rotation component of the transform, 00759 // leaving translation and scale untouched. 00760 //////////////////////////////////////////////////////////////////// 00761 INLINE void NodePath:: 00762 set_hpr(float h, float p, float r) { 00763 set_hpr(LVecBase3f(h, p, r)); 00764 } 00765 00766 INLINE float NodePath:: 00767 get_h() const { 00768 return get_hpr()[0]; 00769 } 00770 00771 INLINE float NodePath:: 00772 get_p() const { 00773 return get_hpr()[1]; 00774 } 00775 00776 INLINE float NodePath:: 00777 get_r() const { 00778 return get_hpr()[2]; 00779 } 00780 00781 //////////////////////////////////////////////////////////////////// 00782 // Function: NodePath::set_scale 00783 // Access: Published 00784 // Description: Sets the scale component of the transform, 00785 // leaving translation and rotation untouched. 00786 //////////////////////////////////////////////////////////////////// 00787 INLINE void NodePath:: 00788 set_scale(float scale) { 00789 set_scale(LVecBase3f(scale, scale, scale)); 00790 } 00791 00792 INLINE void NodePath:: 00793 set_scale(float sx, float sy, float sz) { 00794 set_scale(LVecBase3f(sx, sy, sz)); 00795 } 00796 00797 INLINE float NodePath:: 00798 get_sx() const { 00799 return get_scale()[0]; 00800 } 00801 00802 INLINE float NodePath:: 00803 get_sy() const { 00804 return get_scale()[1]; 00805 } 00806 00807 INLINE float NodePath:: 00808 get_sz() const { 00809 return get_scale()[2]; 00810 } 00811 00812 //////////////////////////////////////////////////////////////////// 00813 // Function: NodePath::set_shear 00814 // Access: Published 00815 // Description: Sets the shear component of the transform, 00816 // leaving translation, rotation, and scale untouched. 00817 //////////////////////////////////////////////////////////////////// 00818 INLINE void NodePath:: 00819 set_shear(float shxy, float shxz, float shyz) { 00820 set_shear(LVecBase3f(shxy, shxz, shyz)); 00821 } 00822 00823 INLINE float NodePath:: 00824 get_shxy() const { 00825 return get_shear()[0]; 00826 } 00827 00828 INLINE float NodePath:: 00829 get_shxz() const { 00830 return get_shear()[1]; 00831 } 00832 00833 INLINE float NodePath:: 00834 get_shyz() const { 00835 return get_shear()[2]; 00836 } 00837 00838 //////////////////////////////////////////////////////////////////// 00839 // Function: NodePath::set_pos_hpr 00840 // Access: Published 00841 // Description: Sets the translation and rotation component of the 00842 // transform, leaving scale untouched. 00843 //////////////////////////////////////////////////////////////////// 00844 INLINE void NodePath:: 00845 set_pos_hpr(float x, float y, float z, float h, float p, float r) { 00846 set_pos_hpr(LVecBase3f(x, y, z), LVecBase3f(h, p, r)); 00847 } 00848 00849 //////////////////////////////////////////////////////////////////// 00850 // Function: NodePath::set_hpr_scale 00851 // Access: Published 00852 // Description: Sets the rotation and scale components of the 00853 // transform, leaving translation untouched. 00854 //////////////////////////////////////////////////////////////////// 00855 INLINE void NodePath:: 00856 set_hpr_scale(float h, float p, float r, float sx, float sy, float sz) { 00857 set_hpr_scale(LVecBase3f(h, p, r), LVecBase3f(sx, sy, sz)); 00858 } 00859 00860 //////////////////////////////////////////////////////////////////// 00861 // Function: NodePath::set_pos_hpr_scale 00862 // Access: Published 00863 // Description: Completely replaces the transform with new 00864 // translation, rotation, and scale components. 00865 //////////////////////////////////////////////////////////////////// 00866 INLINE void NodePath:: 00867 set_pos_hpr_scale(float x, float y, float z, float h, float p, float r, 00868 float sx, float sy, float sz) { 00869 set_pos_hpr_scale(LVecBase3f(x, y, z), LVecBase3f(h, p, r), 00870 LVecBase3f(sx, sy, sz)); 00871 } 00872 00873 //////////////////////////////////////////////////////////////////// 00874 // Function: NodePath::clear_mat 00875 // Access: Published 00876 // Description: Completely removes any transform from the referenced 00877 // node. 00878 //////////////////////////////////////////////////////////////////// 00879 INLINE void NodePath:: 00880 clear_mat() { 00881 nassertv_always(!is_empty()); 00882 node()->clear_transform(); 00883 } 00884 00885 //////////////////////////////////////////////////////////////////// 00886 // Function: NodePath::has_mat 00887 // Access: Published 00888 // Description: Returns true if a non-identity transform matrix has 00889 // been applied to the referenced node, false otherwise. 00890 //////////////////////////////////////////////////////////////////// 00891 INLINE bool NodePath:: 00892 has_mat() const { 00893 nassertr_always(!is_empty(), false); 00894 return !node()->get_transform()->is_identity(); 00895 } 00896 00897 //////////////////////////////////////////////////////////////////// 00898 // Function: NodePath::get_mat 00899 // Access: Published 00900 // Description: Returns the transform matrix that has been applied to 00901 // the referenced node, or the identity matrix if no 00902 // matrix has been applied. 00903 //////////////////////////////////////////////////////////////////// 00904 INLINE const LMatrix4f &NodePath:: 00905 get_mat() const { 00906 nassertr_always(!is_empty(), LMatrix4f::ident_mat()); 00907 00908 return node()->get_transform()->get_mat(); 00909 } 00910 00911 00912 //////////////////////////////////////////////////////////////////// 00913 // Function: NodePath::look_at 00914 // Access: Published 00915 // Description: Sets the transform on this NodePath so that it 00916 // rotates to face the indicated point in space. This 00917 // will overwrite any previously existing scale on the 00918 // node, although it will preserve any translation. 00919 //////////////////////////////////////////////////////////////////// 00920 INLINE void NodePath:: 00921 look_at(float x, float y, float z) { 00922 look_at(LPoint3f(x, y, z)); 00923 } 00924 00925 //////////////////////////////////////////////////////////////////// 00926 // Function: NodePath::heads_up 00927 // Access: Published 00928 // Description: Behaves like look_at(), but with a strong preference 00929 // to keeping the up vector oriented in the indicated 00930 // "up" direction. 00931 //////////////////////////////////////////////////////////////////// 00932 INLINE void NodePath:: 00933 heads_up(float x, float y, float z) { 00934 heads_up(LPoint3f(x, y, z)); 00935 } 00936 00937 //////////////////////////////////////////////////////////////////// 00938 // Function: NodePath::set_pos 00939 // Access: Published 00940 // Description: Sets the translation component of the transform, 00941 // relative to the other node. 00942 //////////////////////////////////////////////////////////////////// 00943 INLINE void NodePath:: 00944 set_pos(const NodePath &other, float x, float y, float z) { 00945 set_pos(other, LPoint3f(x, y, z)); 00946 } 00947 00948 //////////////////////////////////////////////////////////////////// 00949 // Function: NodePath::set_fluid_pos 00950 // Access: Published 00951 // Description: Sets the translation component, without changing the 00952 // "previous" position, so that the collision system 00953 // will see the node as moving fluidly from its previous 00954 // position to its new position. 00955 //////////////////////////////////////////////////////////////////// 00956 INLINE void NodePath:: 00957 set_fluid_pos(const NodePath &other, float x, float y, float z) { 00958 set_fluid_pos(other, LPoint3f(x, y, z)); 00959 } 00960 00961 INLINE float NodePath:: 00962 get_x(const NodePath &other) const { 00963 return get_pos(other)[0]; 00964 } 00965 00966 INLINE float NodePath:: 00967 get_y(const NodePath &other) const { 00968 return get_pos(other)[1]; 00969 } 00970 00971 INLINE float NodePath:: 00972 get_z(const NodePath &other) const { 00973 return get_pos(other)[2]; 00974 } 00975 00976 //////////////////////////////////////////////////////////////////// 00977 // Function: NodePath::set_hpr 00978 // Access: Published 00979 // Description: Sets the rotation component of the transform, 00980 // relative to the other node. 00981 //////////////////////////////////////////////////////////////////// 00982 INLINE void NodePath:: 00983 set_hpr(const NodePath &other, float h, float p, float r) { 00984 set_hpr(other, LPoint3f(h, p, r)); 00985 } 00986 00987 INLINE float NodePath:: 00988 get_h(const NodePath &other) const { 00989 return get_hpr(other)[0]; 00990 } 00991 00992 INLINE float NodePath:: 00993 get_p(const NodePath &other) const { 00994 return get_hpr(other)[1]; 00995 } 00996 00997 INLINE float NodePath:: 00998 get_r(const NodePath &other) const { 00999 return get_hpr(other)[2]; 01000 } 01001 01002 //////////////////////////////////////////////////////////////////// 01003 // Function: NodePath::set_scale 01004 // Access: Published 01005 // Description: Sets the scale component of the transform, 01006 // relative to the other node. 01007 //////////////////////////////////////////////////////////////////// 01008 INLINE void NodePath:: 01009 set_scale(const NodePath &other, float scale) { 01010 set_scale(other, LPoint3f(scale, scale, scale)); 01011 } 01012 01013 //////////////////////////////////////////////////////////////////// 01014 // Function: NodePath::set_scale 01015 // Access: Published 01016 // Description: Sets the scale component of the transform, 01017 // relative to the other node. 01018 //////////////////////////////////////////////////////////////////// 01019 INLINE void NodePath:: 01020 set_scale(const NodePath &other, float sx, float sy, float sz) { 01021 set_scale(other, LPoint3f(sx, sy, sz)); 01022 } 01023 01024 //////////////////////////////////////////////////////////////////// 01025 // Function: NodePath::get_scale 01026 // Access: Published 01027 // Description: Returns the relative scale of the referenced node 01028 // as seen from the other node. 01029 //////////////////////////////////////////////////////////////////// 01030 INLINE float NodePath:: 01031 get_sx(const NodePath &other) const { 01032 return get_scale(other)[0]; 01033 } 01034 01035 INLINE float NodePath:: 01036 get_sy(const NodePath &other) const { 01037 return get_scale(other)[1]; 01038 } 01039 01040 INLINE float NodePath:: 01041 get_sz(const NodePath &other) const { 01042 return get_scale(other)[2]; 01043 } 01044 01045 //////////////////////////////////////////////////////////////////// 01046 // Function: NodePath::set_shear 01047 // Access: Published 01048 // Description: Sets the shear component of the transform, 01049 // relative to the other node. 01050 //////////////////////////////////////////////////////////////////// 01051 INLINE void NodePath:: 01052 set_shear(const NodePath &other, float shxy, float shxz, float shyz) { 01053 set_shear(other, LPoint3f(shxy, shxz, shyz)); 01054 } 01055 01056 //////////////////////////////////////////////////////////////////// 01057 // Function: NodePath::get_shear 01058 // Access: Published 01059 // Description: Returns the relative shear of the referenced node 01060 // as seen from the other node. 01061 //////////////////////////////////////////////////////////////////// 01062 INLINE float NodePath:: 01063 get_shxy(const NodePath &other) const { 01064 return get_shear(other)[0]; 01065 } 01066 01067 INLINE float NodePath:: 01068 get_shxz(const NodePath &other) const { 01069 return get_shear(other)[1]; 01070 } 01071 01072 INLINE float NodePath:: 01073 get_shyz(const NodePath &other) const { 01074 return get_shear(other)[2]; 01075 } 01076 01077 //////////////////////////////////////////////////////////////////// 01078 // Function: NodePath::set_pos_hpr 01079 // Access: Published 01080 // Description: Sets the translation and rotation component of the 01081 // transform, relative to the other node. 01082 //////////////////////////////////////////////////////////////////// 01083 INLINE void NodePath:: 01084 set_pos_hpr(const NodePath &other, 01085 float x, float y, float z, 01086 float h, float p, float r) { 01087 set_pos_hpr(other, LVecBase3f(x, y, z), LVecBase3f(h, p, r)); 01088 } 01089 01090 //////////////////////////////////////////////////////////////////// 01091 // Function: NodePath::set_hpr_scale 01092 // Access: Published 01093 // Description: Sets the rotation and scale components of the 01094 // transform, leaving translation untouched. This, or 01095 // set_pos_hpr_scale, is the preferred way to update a 01096 // transform when both hpr and scale are to be changed. 01097 //////////////////////////////////////////////////////////////////// 01098 INLINE void NodePath:: 01099 set_hpr_scale(const NodePath &other, 01100 float h, float p, float r, float sx, float sy, float sz) { 01101 set_hpr_scale(other, LVecBase3f(h, p, r), LVecBase3f(sx, sy, sz)); 01102 } 01103 01104 //////////////////////////////////////////////////////////////////// 01105 // Function: NodePath::set_pos_hpr_scale 01106 // Access: Published 01107 // Description: Completely replaces the transform with new 01108 // translation, rotation, and scale components, relative 01109 // to the other node. 01110 //////////////////////////////////////////////////////////////////// 01111 INLINE void NodePath:: 01112 set_pos_hpr_scale(const NodePath &other, 01113 float x, float y, float z, 01114 float h, float p, float r, 01115 float sx, float sy, float sz) { 01116 set_pos_hpr_scale(other, LVecBase3f(x, y, z), LVecBase3f(h, p, r), 01117 LVecBase3f(sx, sy, sz)); 01118 } 01119 01120 //////////////////////////////////////////////////////////////////// 01121 // Function: NodePath::look_at 01122 // Access: Published 01123 // Description: Sets the hpr on this NodePath so that it rotates to 01124 // face the indicated point in space, which is relative 01125 // to the other NodePath. 01126 //////////////////////////////////////////////////////////////////// 01127 INLINE void NodePath:: 01128 look_at(const NodePath &other, float x, float y, float z) { 01129 look_at(other, LPoint3f(x, y, z)); 01130 } 01131 01132 //////////////////////////////////////////////////////////////////// 01133 // Function: NodePath::heads_up 01134 // Access: Published 01135 // Description: Behaves like look_at(), but with a strong preference 01136 // to keeping the up vector oriented in the indicated 01137 // "up" direction. 01138 //////////////////////////////////////////////////////////////////// 01139 INLINE void NodePath:: 01140 heads_up(const NodePath &other, float x, float y, float z) { 01141 heads_up(other, LPoint3f(x, y, z)); 01142 } 01143 01144 //////////////////////////////////////////////////////////////////// 01145 // Function: NodePath::get_distance 01146 // Access: Published 01147 // Description: Returns the straight-line distance between this 01148 // referenced node's coordinate frame's origin, and that 01149 // of the other node's origin. 01150 //////////////////////////////////////////////////////////////////// 01151 INLINE float NodePath:: 01152 get_distance(const NodePath &other) const { 01153 LPoint3f pos = get_pos(other); 01154 return length(LVector3f(pos)); 01155 } 01156 01157 //////////////////////////////////////////////////////////////////// 01158 // Function: NodePath::set_color_scale 01159 // Access: Published 01160 // Description: Sets the color scale component of the transform 01161 //////////////////////////////////////////////////////////////////// 01162 INLINE void NodePath:: 01163 set_color_scale(float sr, float sg, float sb, float sa, int priority) { 01164 set_color_scale(LVecBase4f(sr, sg, sb, sa), priority); 01165 } 01166 01167 //////////////////////////////////////////////////////////////////// 01168 // Function: NodePath::compose_color_scale 01169 // Access: Published 01170 // Description: Sets the color scale component of the transform 01171 //////////////////////////////////////////////////////////////////// 01172 INLINE void NodePath:: 01173 compose_color_scale(float sr, float sg, float sb, float sa, int priority) { 01174 compose_color_scale(LVecBase4f(sr, sg, sb, sa), priority); 01175 } 01176 01177 //////////////////////////////////////////////////////////////////// 01178 // Function: NodePath::set_sr 01179 // Access: Published 01180 // Description: Sets the red scale component of the transform 01181 //////////////////////////////////////////////////////////////////// 01182 INLINE void NodePath:: 01183 set_sr(float sr) { 01184 LVecBase4f new_scale = get_color_scale(); 01185 new_scale[0] = sr; 01186 01187 set_color_scale(new_scale); 01188 } 01189 01190 //////////////////////////////////////////////////////////////////// 01191 // Function: NodePath::set_sg 01192 // Access: Published 01193 // Description: Sets the alpha scale component of the transform 01194 //////////////////////////////////////////////////////////////////// 01195 INLINE void NodePath:: 01196 set_sg(float sg) { 01197 LVecBase4f new_scale = get_color_scale(); 01198 new_scale[1] = sg; 01199 01200 set_color_scale(new_scale); 01201 } 01202 01203 //////////////////////////////////////////////////////////////////// 01204 // Function: NodePath::set_sb 01205 // Access: Published 01206 // Description: Sets the blue scale component of the transform 01207 //////////////////////////////////////////////////////////////////// 01208 INLINE void NodePath:: 01209 set_sb(float sb) { 01210 LVecBase4f new_scale = get_color_scale(); 01211 new_scale[2] = sb; 01212 01213 set_color_scale(new_scale); 01214 } 01215 01216 //////////////////////////////////////////////////////////////////// 01217 // Function: NodePath::set_sa 01218 // Access: Published 01219 // Description: Sets the alpha scale component of the transform 01220 //////////////////////////////////////////////////////////////////// 01221 INLINE void NodePath:: 01222 set_sa(float sa) { 01223 LVecBase4f new_scale = get_color_scale(); 01224 new_scale[3] = sa; 01225 01226 set_color_scale(new_scale); 01227 } 01228 01229 //////////////////////////////////////////////////////////////////// 01230 // Function: NodePath::get_sr 01231 // Access: Published 01232 // Description: Gets the red scale component of the transform 01233 //////////////////////////////////////////////////////////////////// 01234 INLINE float NodePath:: 01235 get_sr() const { 01236 return get_color_scale()[0]; 01237 } 01238 01239 //////////////////////////////////////////////////////////////////// 01240 // Function: NodePath::get_sg 01241 // Access: Published 01242 // Description: Gets the green scale component of the transform 01243 //////////////////////////////////////////////////////////////////// 01244 INLINE float NodePath:: 01245 get_sg() const { 01246 return get_color_scale()[1]; 01247 } 01248 01249 //////////////////////////////////////////////////////////////////// 01250 // Function: NodePath::get_sb 01251 // Access: Published 01252 // Description: Gets the blue scale component of the transform 01253 //////////////////////////////////////////////////////////////////// 01254 INLINE float NodePath:: 01255 get_sb() const { 01256 return get_color_scale()[2]; 01257 } 01258 01259 //////////////////////////////////////////////////////////////////// 01260 // Function: NodePath::get_sa 01261 // Access: Published 01262 // Description: Gets the alpha scale component of the transform 01263 //////////////////////////////////////////////////////////////////// 01264 INLINE float NodePath:: 01265 get_sa() const { 01266 return get_color_scale()[3]; 01267 } 01268 01269 //////////////////////////////////////////////////////////////////// 01270 // Function: NodePath::set_tex_offset 01271 // Access: Published 01272 // Description: Sets a texture matrix on the current node to apply 01273 // the indicated offset to UV's for the given stage. 01274 // 01275 // This call is appropriate for ordinary 2-d texture 01276 // coordinates. 01277 //////////////////////////////////////////////////////////////////// 01278 INLINE void NodePath:: 01279 set_tex_offset(TextureStage *stage, float u, float v) { 01280 set_tex_offset(stage, LVecBase2f(u, v)); 01281 } 01282 01283 //////////////////////////////////////////////////////////////////// 01284 // Function: NodePath::set_tex_offset 01285 // Access: Published 01286 // Description: Sets a texture matrix on the current node to apply 01287 // the indicated offset to UV's for the given stage. 01288 // 01289 // This call is appropriate for ordinary 2-d texture 01290 // coordinates. 01291 //////////////////////////////////////////////////////////////////// 01292 INLINE void NodePath:: 01293 set_tex_offset(TextureStage *stage, const LVecBase2f &uv) { 01294 nassertv_always(!is_empty()); 01295 set_tex_transform(stage, 01296 get_tex_transform(stage)->set_pos2d(uv)); 01297 } 01298 01299 //////////////////////////////////////////////////////////////////// 01300 // Function: NodePath::set_tex_rotate 01301 // Access: Published 01302 // Description: Sets a texture matrix on the current node to apply 01303 // the indicated rotation, clockwise in degrees, to UV's 01304 // for the given stage. 01305 // 01306 // This call is appropriate for ordinary 2-d texture 01307 // coordinates. 01308 //////////////////////////////////////////////////////////////////// 01309 INLINE void NodePath:: 01310 set_tex_rotate(TextureStage *stage, float r) { 01311 nassertv_always(!is_empty()); 01312 set_tex_transform(stage, 01313 get_tex_transform(stage)->set_rotate2d(r)); 01314 } 01315 01316 //////////////////////////////////////////////////////////////////// 01317 // Function: NodePath::set_tex_scale 01318 // Access: Published 01319 // Description: Sets a texture matrix on the current node to apply 01320 // the indicated scale to UVW's for the given stage. 01321 // 01322 // This call is appropriate for 2-d or 3-d texture 01323 // coordinates. 01324 //////////////////////////////////////////////////////////////////// 01325 INLINE void NodePath:: 01326 set_tex_scale(TextureStage *stage, float scale) { 01327 nassertv_always(!is_empty()); 01328 set_tex_transform(stage, 01329 get_tex_transform(stage)->set_scale(scale)); 01330 } 01331 01332 //////////////////////////////////////////////////////////////////// 01333 // Function: NodePath::set_tex_scale 01334 // Access: Published 01335 // Description: Sets a texture matrix on the current node to apply 01336 // the indicated scale to UV's for the given stage. 01337 // 01338 // This call is appropriate for ordinary 2-d texture 01339 // coordinates. 01340 //////////////////////////////////////////////////////////////////// 01341 INLINE void NodePath:: 01342 set_tex_scale(TextureStage *stage, float su, float sv) { 01343 set_tex_scale(stage, LVecBase2f(su, sv)); 01344 } 01345 01346 //////////////////////////////////////////////////////////////////// 01347 // Function: NodePath::set_tex_scale 01348 // Access: Published 01349 // Description: Sets a texture matrix on the current node to apply 01350 // the indicated scale to UV's for the given stage. 01351 // 01352 // This call is appropriate for ordinary 2-d texture 01353 // coordinates. 01354 //////////////////////////////////////////////////////////////////// 01355 INLINE void NodePath:: 01356 set_tex_scale(TextureStage *stage, const LVecBase2f &scale) { 01357 nassertv_always(!is_empty()); 01358 set_tex_transform(stage, 01359 get_tex_transform(stage)->set_scale2d(scale)); 01360 } 01361 01362 //////////////////////////////////////////////////////////////////// 01363 // Function: NodePath::get_tex_offset 01364 // Access: Published 01365 // Description: Returns the offset set for the UV's for the given 01366 // stage on the current node. 01367 // 01368 // This call is appropriate for ordinary 2-d texture 01369 // coordinates. 01370 //////////////////////////////////////////////////////////////////// 01371 INLINE LVecBase2f NodePath:: 01372 get_tex_offset(TextureStage *stage) const { 01373 nassertr_always(!is_empty(), LVecBase2f::zero()); 01374 return get_tex_transform(stage)->get_pos2d(); 01375 } 01376 01377 //////////////////////////////////////////////////////////////////// 01378 // Function: NodePath::get_tex_rotate 01379 // Access: Published 01380 // Description: Returns the rotation set for the UV's for the given 01381 // stage on the current node. 01382 // 01383 // This call is appropriate for ordinary 2-d texture 01384 // coordinates. 01385 //////////////////////////////////////////////////////////////////// 01386 INLINE float NodePath:: 01387 get_tex_rotate(TextureStage *stage) const { 01388 nassertr_always(!is_empty(), 0.0f); 01389 return get_tex_transform(stage)->get_rotate2d(); 01390 } 01391 01392 //////////////////////////////////////////////////////////////////// 01393 // Function: NodePath::get_tex_scale 01394 // Access: Published 01395 // Description: Returns the scale set for the UV's for the given 01396 // stage on the current node. 01397 // 01398 // This call is appropriate for ordinary 2-d texture 01399 // coordinates. 01400 //////////////////////////////////////////////////////////////////// 01401 INLINE LVecBase2f NodePath:: 01402 get_tex_scale(TextureStage *stage) const { 01403 nassertr_always(!is_empty(), LVecBase2f(1.0f, 1.0f)); 01404 return get_tex_transform(stage)->get_scale2d(); 01405 } 01406 01407 //////////////////////////////////////////////////////////////////// 01408 // Function: NodePath::set_tex_pos 01409 // Access: Published 01410 // Description: Sets a texture matrix on the current node to apply 01411 // the indicated offset to UVW's for the given stage. 01412 // 01413 // This call is appropriate for 3-d texture coordinates. 01414 //////////////////////////////////////////////////////////////////// 01415 INLINE void NodePath:: 01416 set_tex_pos(TextureStage *stage, float u, float v, float w) { 01417 set_tex_pos(stage, LVecBase3f(u, v, w)); 01418 } 01419 01420 //////////////////////////////////////////////////////////////////// 01421 // Function: NodePath::set_tex_pos 01422 // Access: Published 01423 // Description: Sets a texture matrix on the current node to apply 01424 // the indicated offset to UVW's for the given stage. 01425 // 01426 // This call is appropriate for 3-d texture coordinates. 01427 //////////////////////////////////////////////////////////////////// 01428 INLINE void NodePath:: 01429 set_tex_pos(TextureStage *stage, const LVecBase3f &uvw) { 01430 nassertv_always(!is_empty()); 01431 set_tex_transform(stage, 01432 get_tex_transform(stage)->set_pos(uvw)); 01433 } 01434 01435 //////////////////////////////////////////////////////////////////// 01436 // Function: NodePath::set_tex_hpr 01437 // Access: Published 01438 // Description: Sets a texture matrix on the current node to apply 01439 // the indicated rotation, as a 3-D HPR, to UVW's 01440 // for the given stage. 01441 // 01442 // This call is appropriate for 3-d texture coordinates. 01443 //////////////////////////////////////////////////////////////////// 01444 INLINE void NodePath:: 01445 set_tex_hpr(TextureStage *stage, float h, float p, float r) { 01446 set_tex_hpr(stage, LVecBase3f(h, p, r)); 01447 } 01448 01449 //////////////////////////////////////////////////////////////////// 01450 // Function: NodePath::set_tex_hpr 01451 // Access: Published 01452 // Description: Sets a texture matrix on the current node to apply 01453 // the indicated rotation, as a 3-D HPR, to UVW's 01454 // for the given stage. 01455 // 01456 // This call is appropriate for 3-d texture coordinates. 01457 //////////////////////////////////////////////////////////////////// 01458 INLINE void NodePath:: 01459 set_tex_hpr(TextureStage *stage, const LVecBase3f &hpr) { 01460 nassertv_always(!is_empty()); 01461 set_tex_transform(stage, 01462 get_tex_transform(stage)->set_hpr(hpr)); 01463 } 01464 01465 //////////////////////////////////////////////////////////////////// 01466 // Function: NodePath::set_tex_scale 01467 // Access: Published 01468 // Description: Sets a texture matrix on the current node to apply 01469 // the indicated scale to UVW's for the given stage. 01470 // 01471 // This call is appropriate for 3-d texture coordinates. 01472 //////////////////////////////////////////////////////////////////// 01473 INLINE void NodePath:: 01474 set_tex_scale(TextureStage *stage, float su, float sv, float sw) { 01475 set_tex_scale(stage, LVecBase3f(su, sv, sw)); 01476 } 01477 01478 //////////////////////////////////////////////////////////////////// 01479 // Function: NodePath::set_tex_scale 01480 // Access: Published 01481 // Description: Sets a texture matrix on the current node to apply 01482 // the indicated scale to UVW's for the given stage. 01483 // 01484 // This call is appropriate for 3-d texture coordinates. 01485 //////////////////////////////////////////////////////////////////// 01486 INLINE void NodePath:: 01487 set_tex_scale(TextureStage *stage, const LVecBase3f &scale) { 01488 nassertv_always(!is_empty()); 01489 set_tex_transform(stage, 01490 get_tex_transform(stage)->set_scale(scale)); 01491 } 01492 01493 //////////////////////////////////////////////////////////////////// 01494 // Function: NodePath::get_tex_pos 01495 // Access: Published 01496 // Description: Returns the offset set for the UVW's for the given 01497 // stage on the current node. 01498 // 01499 // This call is appropriate for 3-d texture coordinates. 01500 //////////////////////////////////////////////////////////////////// 01501 INLINE LVecBase3f NodePath:: 01502 get_tex_pos(TextureStage *stage) const { 01503 nassertr_always(!is_empty(), LVecBase3f::zero()); 01504 return get_tex_transform(stage)->get_pos(); 01505 } 01506 01507 //////////////////////////////////////////////////////////////////// 01508 // Function: NodePath::get_tex_hpr 01509 // Access: Published 01510 // Description: Returns the 3-D HPR set for the UVW's for the given 01511 // stage on the current node. 01512 // 01513 // This call is appropriate for 3-d texture coordinates. 01514 //////////////////////////////////////////////////////////////////// 01515 INLINE LVecBase3f NodePath:: 01516 get_tex_hpr(TextureStage *stage) const { 01517 nassertr_always(!is_empty(), LVecBase3f::zero()); 01518 return get_tex_transform(stage)->get_hpr(); 01519 } 01520 01521 //////////////////////////////////////////////////////////////////// 01522 // Function: NodePath::get_tex_scale_3d 01523 // Access: Published 01524 // Description: Returns the scale set for the UVW's for the given 01525 // stage on the current node. 01526 // 01527 // This call is appropriate for 3-d texture coordinates. 01528 //////////////////////////////////////////////////////////////////// 01529 INLINE LVecBase3f NodePath:: 01530 get_tex_scale_3d(TextureStage *stage) const { 01531 nassertr_always(!is_empty(), LVecBase3f(1.0f, 1.0f, 1.0f)); 01532 return get_tex_transform(stage)->get_scale(); 01533 } 01534 01535 //////////////////////////////////////////////////////////////////// 01536 // Function: NodePath::set_tex_offset 01537 // Access: Published 01538 // Description: Sets a texture matrix on the current node to apply 01539 // the indicated offset to UV's for the given stage. 01540 // 01541 // This call is appropriate for ordinary 2-d texture 01542 // coordinates. 01543 //////////////////////////////////////////////////////////////////// 01544 INLINE void NodePath:: 01545 set_tex_offset(const NodePath &other, TextureStage *stage, float u, float v) { 01546 set_tex_offset(other, stage, LVecBase2f(u, v)); 01547 } 01548 01549 //////////////////////////////////////////////////////////////////// 01550 // Function: NodePath::set_tex_offset 01551 // Access: Published 01552 // Description: Sets a texture matrix on the current node to apply 01553 // the indicated offset to UV's for the given stage. 01554 // 01555 // This call is appropriate for ordinary 2-d texture 01556 // coordinates. 01557 //////////////////////////////////////////////////////////////////// 01558 INLINE void NodePath:: 01559 set_tex_offset(const NodePath &other, TextureStage *stage, const LVecBase2f &uv) { 01560 nassertv_always(!is_empty()); 01561 set_tex_transform(other, stage, 01562 get_tex_transform(other, stage)->set_pos2d(uv)); 01563 } 01564 01565 //////////////////////////////////////////////////////////////////// 01566 // Function: NodePath::set_tex_rotate 01567 // Access: Published 01568 // Description: Sets a texture matrix on the current node to apply 01569 // the indicated rotation, clockwise in degrees, to UV's 01570 // for the given stage. 01571 // 01572 // This call is appropriate for ordinary 2-d texture 01573 // coordinates. 01574 //////////////////////////////////////////////////////////////////// 01575 INLINE void NodePath:: 01576 set_tex_rotate(const NodePath &other, TextureStage *stage, float r) { 01577 nassertv_always(!is_empty()); 01578 set_tex_transform(other, stage, 01579 get_tex_transform(other, stage)->set_rotate2d(r)); 01580 } 01581 01582 //////////////////////////////////////////////////////////////////// 01583 // Function: NodePath::set_tex_scale 01584 // Access: Published 01585 // Description: Sets a texture matrix on the current node to apply 01586 // the indicated scale to UV's for the given stage. 01587 // 01588 // This call is appropriate for 2-d or 3-d texture 01589 // coordinates. 01590 //////////////////////////////////////////////////////////////////// 01591 INLINE void NodePath:: 01592 set_tex_scale(const NodePath &other, TextureStage *stage, float scale) { 01593 nassertv_always(!is_empty()); 01594 set_tex_transform(other, stage, 01595 get_tex_transform(stage)->set_scale(scale)); 01596 } 01597 01598 //////////////////////////////////////////////////////////////////// 01599 // Function: NodePath::set_tex_scale 01600 // Access: Published 01601 // Description: Sets a texture matrix on the current node to apply 01602 // the indicated scale to UV's for the given stage. 01603 // 01604 // This call is appropriate for ordinary 2-d texture 01605 // coordinates. 01606 //////////////////////////////////////////////////////////////////// 01607 INLINE void NodePath:: 01608 set_tex_scale(const NodePath &other, TextureStage *stage, float su, float sv) { 01609 set_tex_scale(other, stage, LVecBase2f(su, sv)); 01610 } 01611 01612 //////////////////////////////////////////////////////////////////// 01613 // Function: NodePath::set_tex_scale 01614 // Access: Published 01615 // Description: Sets a texture matrix on the current node to apply 01616 // the indicated scale to UV's for the given stage. 01617 // 01618 // This call is appropriate for ordinary 2-d texture 01619 // coordinates. 01620 //////////////////////////////////////////////////////////////////// 01621 INLINE void NodePath:: 01622 set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase2f &scale) { 01623 nassertv_always(!is_empty()); 01624 set_tex_transform(other, stage, 01625 get_tex_transform(stage)->set_scale2d(scale)); 01626 } 01627 01628 //////////////////////////////////////////////////////////////////// 01629 // Function: NodePath::get_tex_offset 01630 // Access: Published 01631 // Description: Returns the offset set for the UV's for the given 01632 // stage on the current node. 01633 // 01634 // This call is appropriate for ordinary 2-d texture 01635 // coordinates. 01636 //////////////////////////////////////////////////////////////////// 01637 INLINE LVecBase2f NodePath:: 01638 get_tex_offset(const NodePath &other, TextureStage *stage) const { 01639 nassertr_always(!is_empty(), LVecBase2f::zero()); 01640 return get_tex_transform(other, stage)->get_pos2d(); 01641 } 01642 01643 //////////////////////////////////////////////////////////////////// 01644 // Function: NodePath::get_tex_rotate 01645 // Access: Published 01646 // Description: Returns the rotation set for the UV's for the given 01647 // stage on the current node. 01648 // 01649 // This call is appropriate for ordinary 2-d texture 01650 // coordinates. 01651 //////////////////////////////////////////////////////////////////// 01652 INLINE float NodePath:: 01653 get_tex_rotate(const NodePath &other, TextureStage *stage) const { 01654 nassertr_always(!is_empty(), 0.0f); 01655 return get_tex_transform(other, stage)->get_rotate2d(); 01656 } 01657 01658 //////////////////////////////////////////////////////////////////// 01659 // Function: NodePath::get_tex_scale 01660 // Access: Published 01661 // Description: Returns the scale set for the UV's for the given 01662 // stage on the current node. 01663 // 01664 // This call is appropriate for ordinary 2-d texture 01665 // coordinates. 01666 //////////////////////////////////////////////////////////////////// 01667 INLINE LVecBase2f NodePath:: 01668 get_tex_scale(const NodePath &other, TextureStage *stage) const { 01669 nassertr_always(!is_empty(), LVecBase2f(1.0f, 1.0f)); 01670 return get_tex_transform(other, stage)->get_scale2d(); 01671 } 01672 01673 //////////////////////////////////////////////////////////////////// 01674 // Function: NodePath::set_tex_pos 01675 // Access: Published 01676 // Description: Sets a texture matrix on the current node to apply 01677 // the indicated offset to UVW's for the given stage. 01678 // 01679 // This call is appropriate for 3-d texture coordinates. 01680 //////////////////////////////////////////////////////////////////// 01681 INLINE void NodePath:: 01682 set_tex_pos(const NodePath &other, TextureStage *stage, float u, float v, float w) { 01683 set_tex_pos(other, stage, LVecBase3f(u, v, w)); 01684 } 01685 01686 //////////////////////////////////////////////////////////////////// 01687 // Function: NodePath::set_tex_pos 01688 // Access: Published 01689 // Description: Sets a texture matrix on the current node to apply 01690 // the indicated offset to UVW's for the given stage. 01691 // 01692 // This call is appropriate for 3-d texture coordinates. 01693 //////////////////////////////////////////////////////////////////// 01694 INLINE void NodePath:: 01695 set_tex_pos(const NodePath &other, TextureStage *stage, const LVecBase3f &uvw) { 01696 nassertv_always(!is_empty()); 01697 set_tex_transform(other, stage, 01698 get_tex_transform(stage)->set_pos(uvw)); 01699 } 01700 01701 //////////////////////////////////////////////////////////////////// 01702 // Function: NodePath::set_tex_hpr 01703 // Access: Published 01704 // Description: Sets a texture matrix on the current node to apply 01705 // the indicated rotation, as a 3-D HPR, to UVW's 01706 // for the given stage. 01707 // 01708 // This call is appropriate for 3-d texture coordinates. 01709 //////////////////////////////////////////////////////////////////// 01710 INLINE void NodePath:: 01711 set_tex_hpr(const NodePath &other, TextureStage *stage, float h, float p, float r) { 01712 set_tex_hpr(other, stage, LVecBase3f(h, p, r)); 01713 } 01714 01715 //////////////////////////////////////////////////////////////////// 01716 // Function: NodePath::set_tex_hpr 01717 // Access: Published 01718 // Description: Sets a texture matrix on the current node to apply 01719 // the indicated rotation, as a 3-D HPR, to UVW's 01720 // for the given stage. 01721 // 01722 // This call is appropriate for 3-d texture coordinates. 01723 //////////////////////////////////////////////////////////////////// 01724 INLINE void NodePath:: 01725 set_tex_hpr(const NodePath &other, TextureStage *stage, const LVecBase3f &hpr) { 01726 nassertv_always(!is_empty()); 01727 set_tex_transform(other, stage, 01728 get_tex_transform(stage)->set_hpr(hpr)); 01729 } 01730 01731 //////////////////////////////////////////////////////////////////// 01732 // Function: NodePath::set_tex_scale 01733 // Access: Published 01734 // Description: Sets a texture matrix on the current node to apply 01735 // the indicated scale to UVW's for the given stage. 01736 // 01737 // This call is appropriate for 3-d texture coordinates. 01738 //////////////////////////////////////////////////////////////////// 01739 INLINE void NodePath:: 01740 set_tex_scale(const NodePath &other, TextureStage *stage, float su, float sv, float sw) { 01741 set_tex_scale(other, stage, LVecBase3f(su, sv, sw)); 01742 } 01743 01744 //////////////////////////////////////////////////////////////////// 01745 // Function: NodePath::set_tex_scale 01746 // Access: Published 01747 // Description: Sets a texture matrix on the current node to apply 01748 // the indicated scale to UVW's for the given stage. 01749 // 01750 // This call is appropriate for 3-d texture coordinates. 01751 //////////////////////////////////////////////////////////////////// 01752 INLINE void NodePath:: 01753 set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase3f &scale) { 01754 nassertv_always(!is_empty()); 01755 set_tex_transform(other, stage, 01756 get_tex_transform(stage)->set_scale(scale)); 01757 } 01758 01759 //////////////////////////////////////////////////////////////////// 01760 // Function: NodePath::get_tex_pos 01761 // Access: Published 01762 // Description: Returns the offset set for the UVW's for the given 01763 // stage on the current node. 01764 // 01765 // This call is appropriate for 3-d texture coordinates. 01766 //////////////////////////////////////////////////////////////////// 01767 INLINE LVecBase3f NodePath:: 01768 get_tex_pos(const NodePath &other, TextureStage *stage) const { 01769 nassertr_always(!is_empty(), LVecBase3f::zero()); 01770 return get_tex_transform(stage)->get_pos(); 01771 } 01772 01773 //////////////////////////////////////////////////////////////////// 01774 // Function: NodePath::get_tex_hpr 01775 // Access: Published 01776 // Description: Returns the 3-D HPR set for the UVW's for the given 01777 // stage on the current node. 01778 // 01779 // This call is appropriate for 3-d texture coordinates. 01780 //////////////////////////////////////////////////////////////////// 01781 INLINE LVecBase3f NodePath:: 01782 get_tex_hpr(const NodePath &other, TextureStage *stage) const { 01783 nassertr_always(!is_empty(), LVecBase3f::zero()); 01784 return get_tex_transform(stage)->get_hpr(); 01785 } 01786 01787 //////////////////////////////////////////////////////////////////// 01788 // Function: NodePath::get_tex_scale_3d 01789 // Access: Published 01790 // Description: Returns the scale set for the UVW's for the given 01791 // stage on the current node. 01792 // 01793 // This call is appropriate for 3-d texture coordinates. 01794 //////////////////////////////////////////////////////////////////// 01795 INLINE LVecBase3f NodePath:: 01796 get_tex_scale_3d(const NodePath &other, TextureStage *stage) const { 01797 nassertr_always(!is_empty(), LVecBase3f(1.0f, 1.0f, 1.0f)); 01798 return get_tex_transform(stage)->get_scale(); 01799 } 01800 01801 //////////////////////////////////////////////////////////////////// 01802 // Function: NodePath::clear_project_texture 01803 // Access: Published 01804 // Description: Undoes the effect of project_texture(). 01805 //////////////////////////////////////////////////////////////////// 01806 INLINE void NodePath:: 01807 clear_project_texture(TextureStage *stage) { 01808 clear_texture(stage); 01809 clear_tex_gen(stage); 01810 clear_tex_projector(stage); 01811 } 01812 01813 //////////////////////////////////////////////////////////////////// 01814 // Function: NodePath::has_texcoord 01815 // Access: Published 01816 // Description: Returns true if there are at least some vertices at 01817 // this node and below that use the named texture 01818 // coordinate set, false otherwise. Pass the empty 01819 // string for the default texture coordinate set. 01820 //////////////////////////////////////////////////////////////////// 01821 INLINE bool NodePath:: 01822 has_texcoord(const string &texcoord_name) const { 01823 return has_vertex_column(InternalName::get_texcoord_name(texcoord_name)); 01824 } 01825 01826 //////////////////////////////////////////////////////////////////// 01827 // Function: NodePath::set_billboard_axis 01828 // Access: Published 01829 // Description: Puts a billboard transition on the node such that it 01830 // will rotate in two dimensions around the up axis. 01831 //////////////////////////////////////////////////////////////////// 01832 INLINE void NodePath:: 01833 set_billboard_axis(float offset) { 01834 set_billboard_axis(NodePath(), offset); 01835 } 01836 01837 //////////////////////////////////////////////////////////////////// 01838 // Function: NodePath::set_billboard_point_eye 01839 // Access: Published 01840 // Description: Puts a billboard transition on the node such that it 01841 // will rotate in three dimensions about the origin, 01842 // keeping its up vector oriented to the top of the 01843 // camera. 01844 //////////////////////////////////////////////////////////////////// 01845 INLINE void NodePath:: 01846 set_billboard_point_eye(float offset) { 01847 set_billboard_point_eye(NodePath(), offset); 01848 } 01849 01850 //////////////////////////////////////////////////////////////////// 01851 // Function: NodePath::set_billboard_point_world 01852 // Access: Published 01853 // Description: Puts a billboard transition on the node such that it 01854 // will rotate in three dimensions about the origin, 01855 // keeping its up vector oriented to the sky. 01856 //////////////////////////////////////////////////////////////////// 01857 INLINE void NodePath:: 01858 set_billboard_point_world(float offset) { 01859 set_billboard_point_world(NodePath(), offset); 01860 } 01861 01862 //////////////////////////////////////////////////////////////////// 01863 // Function: NodePath::adjust_all_priorities 01864 // Access: Published 01865 // Description: Adds the indicated adjustment amount (which may be 01866 // negative) to the priority for all transitions on the 01867 // referenced node, and for all nodes in the subgraph 01868 // below. This can be used to force these nodes not to 01869 // be overridden by a high-level state change above. If 01870 // the priority would drop below zero, it is set to 01871 // zero. 01872 //////////////////////////////////////////////////////////////////// 01873 INLINE void NodePath:: 01874 adjust_all_priorities(int adjustment) { 01875 nassertv_always(!is_empty()); 01876 r_adjust_all_priorities(node(), adjustment); 01877 } 01878 01879 //////////////////////////////////////////////////////////////////// 01880 // Function: NodePath::show 01881 // Access: Published 01882 // Description: Undoes the effect of a previous hide() on this node: 01883 // makes the referenced node (and the entire subgraph 01884 // below this node) visible to all cameras. 01885 // 01886 // This will not reveal the node if a parent node has 01887 // been hidden. 01888 //////////////////////////////////////////////////////////////////// 01889 INLINE void NodePath:: 01890 show() { 01891 nassertv_always(!is_empty()); 01892 node()->adjust_draw_mask(DrawMask::all_off(), DrawMask::all_off(), PandaNode::get_overall_bit()); 01893 } 01894 01895 //////////////////////////////////////////////////////////////////// 01896 // Function: NodePath::show 01897 // Access: Published 01898 // Description: Makes the referenced node visible just to the 01899 // cameras whose camera_mask shares the indicated bits. 01900 // 01901 // This undoes the effect of a previous hide() call. It 01902 // will not reveal the node if a parent node has been 01903 // hidden. However, see show_through(). 01904 //////////////////////////////////////////////////////////////////// 01905 INLINE void NodePath:: 01906 show(DrawMask camera_mask) { 01907 nassertv_always(!is_empty()); 01908 camera_mask &= ~PandaNode::get_overall_bit(); 01909 node()->adjust_draw_mask(DrawMask::all_off(), DrawMask::all_off(), camera_mask); 01910 } 01911 01912 //////////////////////////////////////////////////////////////////// 01913 // Function: NodePath::show_through 01914 // Access: Published 01915 // Description: Makes the referenced node visible just to the 01916 // cameras whose camera_mask shares the indicated bits. 01917 // 01918 // Unlike show(), this will reveal the node even if a 01919 // parent node has been hidden, thus "showing through" a 01920 // parent's hide(). 01921 //////////////////////////////////////////////////////////////////// 01922 INLINE void NodePath:: 01923 show_through() { 01924 nassertv_always(!is_empty()); 01925 node()->adjust_draw_mask(PandaNode::get_overall_bit(), DrawMask::all_off(), DrawMask::all_off()); 01926 } 01927 01928 //////////////////////////////////////////////////////////////////// 01929 // Function: NodePath::show_through 01930 // Access: Published 01931 // Description: Makes the referenced node visible just to the 01932 // cameras whose camera_mask shares the indicated bits. 01933 // 01934 // Unlike show(), this will reveal the node even if a 01935 // parent node has been hidden via the one-parameter 01936 // hide() method, thus "showing through" a parent's 01937 // hide(). (However, it will not show through a 01938 // parent's hide() call if the no-parameter form of 01939 // hide() was used.) 01940 //////////////////////////////////////////////////////////////////// 01941 INLINE void NodePath:: 01942 show_through(DrawMask camera_mask) { 01943 nassertv_always(!is_empty()); 01944 camera_mask &= ~PandaNode::get_overall_bit(); 01945 node()->adjust_draw_mask(camera_mask, DrawMask::all_off(), DrawMask::all_off()); 01946 } 01947 01948 //////////////////////////////////////////////////////////////////// 01949 // Function: NodePath::hide 01950 // Access: Published 01951 // Description: Makes the referenced node (and the entire subgraph 01952 // below this node) invisible to all cameras. It 01953 // remains part of the scene graph, its bounding volume 01954 // still contributes to its parent's bounding volume, 01955 // and it will still be involved in collision tests. 01956 //////////////////////////////////////////////////////////////////// 01957 INLINE void NodePath:: 01958 hide() { 01959 nassertv_always(!is_empty()); 01960 node()->adjust_draw_mask(DrawMask::all_off(), PandaNode::get_overall_bit(), DrawMask::all_off()); 01961 } 01962 01963 //////////////////////////////////////////////////////////////////// 01964 // Function: NodePath::hide 01965 // Access: Published 01966 // Description: Makes the referenced node invisible just to the 01967 // cameras whose camera_mask shares the indicated bits. 01968 // 01969 // This will also hide any nodes below this node in the 01970 // scene graph, including those nodes for which show() 01971 // has been called, but it will not hide descendent 01972 // nodes for which show_through() has been called. 01973 //////////////////////////////////////////////////////////////////// 01974 INLINE void NodePath:: 01975 hide(DrawMask camera_mask) { 01976 nassertv_always(!is_empty()); 01977 camera_mask &= ~PandaNode::get_overall_bit(); 01978 node()->adjust_draw_mask(DrawMask::all_off(), camera_mask, DrawMask::all_off()); 01979 } 01980 01981 //////////////////////////////////////////////////////////////////// 01982 // Function: NodePath::is_hidden 01983 // Access: Published 01984 // Description: Returns true if the referenced node is hidden from 01985 // the indicated camera(s) either directly, or because 01986 // some ancestor is hidden. 01987 //////////////////////////////////////////////////////////////////// 01988 INLINE bool NodePath:: 01989 is_hidden(DrawMask camera_mask) const { 01990 return !get_hidden_ancestor(camera_mask).is_empty(); 01991 } 01992 01993 //////////////////////////////////////////////////////////////////// 01994 // Function: NodePath::is_stashed 01995 // Access: Published 01996 // Description: Returns true if the referenced node is stashed either 01997 // directly, or because some ancestor is stashed. 01998 //////////////////////////////////////////////////////////////////// 01999 INLINE bool NodePath:: 02000 is_stashed() const { 02001 return !get_stashed_ancestor().is_empty(); 02002 } 02003 02004 //////////////////////////////////////////////////////////////////// 02005 // Function: NodePath::get_collide_mask 02006 // Access: Published 02007 // Description: Returns the union of all of the into_collide_masks 02008 // for nodes at this level and below. This is the same 02009 // thing as node()->get_net_collide_mask(). 02010 // 02011 // If you want to return what the into_collide_mask of 02012 // this node itself is, without regard to its children, 02013 // use node()->get_into_collide_mask(). 02014 //////////////////////////////////////////////////////////////////// 02015 INLINE CollideMask NodePath:: 02016 get_collide_mask() const { 02017 nassertr_always(!is_empty(), CollideMask::all_off()); 02018 return node()->get_net_collide_mask(); 02019 } 02020 02021 //////////////////////////////////////////////////////////////////// 02022 // Function: NodePath::set_collide_mask 02023 // Access: Published 02024 // Description: Recursively applies the indicated CollideMask to the 02025 // into_collide_masks for all nodes at this level and 02026 // below. If node_type is not TypeHandle::none(), then 02027 // only nodes matching (or inheriting from) the 02028 // indicated PandaNode subclass are modified. 02029 // 02030 // The default is to change all bits, but if 02031 // bits_to_change is not all bits on, then only the bits 02032 // that are set in bits_to_change are modified, allowing 02033 // this call to change only a subset of the bits in the 02034 // subgraph. 02035 //////////////////////////////////////////////////////////////////// 02036 INLINE void NodePath:: 02037 set_collide_mask(CollideMask new_mask, CollideMask bits_to_change, 02038 TypeHandle node_type) { 02039 nassertv_always(!is_empty()); 02040 if (node_type == TypeHandle::none()) { 02041 node_type = PandaNode::get_class_type(); 02042 } 02043 02044 r_set_collide_mask(node(), ~bits_to_change, new_mask & bits_to_change, 02045 node_type); 02046 } 02047 02048 //////////////////////////////////////////////////////////////////// 02049 // Function: NodePath::operator == 02050 // Access: Published 02051 // Description: Returns true if the two paths are equivalent; that 02052 // is, if they contain the same list of nodes in the same 02053 // order. 02054 //////////////////////////////////////////////////////////////////// 02055 INLINE bool NodePath:: 02056 operator == (const NodePath &other) const { 02057 return _head == other._head; 02058 } 02059 02060 //////////////////////////////////////////////////////////////////// 02061 // Function: NodePath::operator != 02062 // Access: Published 02063 // Description: Returns true if the two paths are not equivalent. 02064 //////////////////////////////////////////////////////////////////// 02065 INLINE bool NodePath:: 02066 operator != (const NodePath &other) const { 02067 return _head != other._head; 02068 } 02069 02070 //////////////////////////////////////////////////////////////////// 02071 // Function: NodePath::operator < 02072 // Access: Published 02073 // Description: Returns true if this NodePath sorts before the other 02074 // one, false otherwise. The sorting order of two 02075 // nonequivalent NodePaths is consistent but undefined, 02076 // and is useful only for storing NodePaths in a sorted 02077 // container like an STL set. 02078 //////////////////////////////////////////////////////////////////// 02079 INLINE bool NodePath:: 02080 operator < (const NodePath &other) const { 02081 return _head < other._head; 02082 } 02083 02084 //////////////////////////////////////////////////////////////////// 02085 // Function: NodePath::compare_to 02086 // Access: Published 02087 // Description: Returns a number less than zero if this NodePath 02088 // sorts before the other one, greater than zero if it 02089 // sorts after, or zero if they are equivalent. 02090 // 02091 // Two NodePaths are considered equivalent if they 02092 // consist of exactly the same list of nodes in the same 02093 // order. Otherwise, they are different; different 02094 // NodePaths will be ranked in a consistent but 02095 // undefined ordering; the ordering is useful only for 02096 // placing the NodePaths in a sorted container like an 02097 // STL set. 02098 //////////////////////////////////////////////////////////////////// 02099 INLINE int NodePath:: 02100 compare_to(const NodePath &other) const { 02101 // Nowadays, the NodePathComponents at the head are pointerwise 02102 // equivalent if and only if the NodePaths are equivalent. So we 02103 // only have to compare pointers. 02104 if (_head != other._head) { 02105 return _head < other._head ? -1 : 1; 02106 } 02107 return 0; 02108 } 02109 02110 //////////////////////////////////////////////////////////////////// 02111 // Function: NodePath::clear_model_nodes 02112 // Access: Published 02113 // Description: Recursively walks through the scene graph at this 02114 // level and below, looking for ModelNodes, and calls 02115 // model_node->set_preserve_transform(PT_drop_node) on 02116 // each one. This allows a subsequent call to 02117 // flatten_strong() to eliminate all of the ModelNodes. 02118 // 02119 // Returns the number of ModelNodes found. 02120 //////////////////////////////////////////////////////////////////// 02121 INLINE int NodePath:: 02122 clear_model_nodes() { 02123 nassertr_always(!is_empty(), 0); 02124 return r_clear_model_nodes(node()); 02125 } 02126 02127 //////////////////////////////////////////////////////////////////// 02128 // Function: NodePath::set_tag 02129 // Access: Published 02130 // Description: Associates a user-defined value with a user-defined 02131 // key which is stored on the node. This value has no 02132 // meaning to Panda; but it is stored indefinitely on 02133 // the node until it is requested again. 02134 // 02135 // Each unique key stores a different string value. 02136 // There is no effective limit on the number of 02137 // different keys that may be stored or on the length of 02138 // any one key's value. 02139 //////////////////////////////////////////////////////////////////// 02140 INLINE void NodePath:: 02141 set_tag(const string &key, const string &value) { 02142 nassertv_always(!is_empty()); 02143 node()->set_tag(key, value); 02144 } 02145 02146 //////////////////////////////////////////////////////////////////// 02147 // Function: NodePath::get_tag 02148 // Access: Published 02149 // Description: Retrieves the user-defined value that was previously 02150 // set on this node for the particular key, if any. If 02151 // no value has been previously set, returns the empty 02152 // string. See also get_net_tag(). 02153 //////////////////////////////////////////////////////////////////// 02154 INLINE string NodePath:: 02155 get_tag(const string &key) const { 02156 // An empty NodePath quietly returns no tags. This makes 02157 // get_net_tag() easier to implement. 02158 if (is_empty()) { 02159 return string(); 02160 } 02161 return node()->get_tag(key); 02162 } 02163 02164 //////////////////////////////////////////////////////////////////// 02165 // Function: NodePath::has_tag 02166 // Access: Published 02167 // Description: Returns true if a value has been defined on this node 02168 // for the particular key (even if that value is the 02169 // empty string), or false if no value has been set. 02170 // See also has_net_tag(). 02171 //////////////////////////////////////////////////////////////////// 02172 INLINE bool NodePath:: 02173 has_tag(const string &key) const { 02174 // An empty NodePath quietly has no tags. This makes has_net_tag() 02175 // easier to implement. 02176 if (is_empty()) { 02177 return false; 02178 } 02179 return node()->has_tag(key); 02180 } 02181 02182 //////////////////////////////////////////////////////////////////// 02183 // Function: NodePath::clear_tag 02184 // Access: Published 02185 // Description: Removes the value defined for this key on this 02186 // particular node. After a call to clear_tag(), 02187 // has_tag() will return false for the indicated key. 02188 //////////////////////////////////////////////////////////////////// 02189 INLINE void NodePath:: 02190 clear_tag(const string &key) { 02191 nassertv_always(!is_empty()); 02192 node()->clear_tag(key); 02193 } 02194 02195 //////////////////////////////////////////////////////////////////// 02196 // Function: NodePath::get_net_tag 02197 // Access: Published 02198 // Description: Returns the tag value that has been defined on this 02199 // node, or the nearest ancestor node, for the indicated 02200 // key. If no value has been defined for the indicated 02201 // key on any ancestor node, returns the empty string. 02202 // See also get_tag(). 02203 //////////////////////////////////////////////////////////////////// 02204 INLINE string NodePath:: 02205 get_net_tag(const string &key) const { 02206 return find_net_tag(key).get_tag(key); 02207 } 02208 02209 //////////////////////////////////////////////////////////////////// 02210 // Function: NodePath::has_net_tag 02211 // Access: Published 02212 // Description: Returns true if the indicated tag value has been 02213 // defined on this node or on any ancestor node, or 02214 // false otherwise. See also has_tag(). 02215 //////////////////////////////////////////////////////////////////// 02216 INLINE bool NodePath:: 02217 has_net_tag(const string &key) const { 02218 return !find_net_tag(key).is_empty(); 02219 } 02220 02221 #ifdef HAVE_PYTHON 02222 //////////////////////////////////////////////////////////////////// 02223 // Function: NodePath::set_python_tag 02224 // Access: Published 02225 // Description: Associates an arbitrary Python object with a 02226 // user-defined key which is stored on the node. This 02227 // object has no meaning to Panda; but it is stored 02228 // indefinitely on the node until it is requested again. 02229 // 02230 // Each unique key stores a different Python object. 02231 // There is no effective limit on the number of 02232 // different keys that may be stored or on the nature of 02233 // any one key's object. 02234 //////////////////////////////////////////////////////////////////// 02235 INLINE void NodePath:: 02236 set_python_tag(const string &key, PyObject *value) { 02237 nassertv_always(!is_empty()); 02238 node()->set_python_tag(key, value); 02239 } 02240 #endif // HAVE_PYTHON 02241 02242 #ifdef HAVE_PYTHON 02243 //////////////////////////////////////////////////////////////////// 02244 // Function: NodePath::get_python_tag 02245 // Access: Published 02246 // Description: Retrieves the Python object that was previously 02247 // set on this node for the particular key, if any. If 02248 // no object has been previously set, returns None. 02249 // See also get_net_python_tag(). 02250 //////////////////////////////////////////////////////////////////// 02251 INLINE PyObject *NodePath:: 02252 get_python_tag(const string &key) const { 02253 // An empty NodePath quietly returns no tags. This makes 02254 // get_net_python_tag() easier to implement. 02255 if (is_empty()) { 02256 Py_INCREF(Py_None); 02257 return Py_None; 02258 } 02259 return node()->get_python_tag(key); 02260 } 02261 #endif // HAVE_PYTHON 02262 02263 #ifdef HAVE_PYTHON 02264 //////////////////////////////////////////////////////////////////// 02265 // Function: NodePath::has_python_tag 02266 // Access: Published 02267 // Description: Returns true if a Python object has been defined on 02268 // this node for the particular key (even if that value 02269 // is the empty string), or false if no value has been 02270 // set. See also has_net_python_tag(). 02271 //////////////////////////////////////////////////////////////////// 02272 INLINE bool NodePath:: 02273 has_python_tag(const string &key) const { 02274 // An empty NodePath quietly has no tags. This makes has_net_python_tag() 02275 // easier to implement. 02276 if (is_empty()) { 02277 return false; 02278 } 02279 return node()->has_python_tag(key); 02280 } 02281 #endif // HAVE_PYTHON 02282 02283 #ifdef HAVE_PYTHON 02284 //////////////////////////////////////////////////////////////////// 02285 // Function: NodePath::clear_python_tag 02286 // Access: Published 02287 // Description: Removes the Python object defined for this key on this 02288 // particular node. After a call to clear_python_tag(), 02289 // has_python_tag() will return false for the indicated 02290 // key. 02291 //////////////////////////////////////////////////////////////////// 02292 INLINE void NodePath:: 02293 clear_python_tag(const string &key) { 02294 nassertv_always(!is_empty()); 02295 node()->clear_python_tag(key); 02296 } 02297 #endif // HAVE_PYTHON 02298 02299 #ifdef HAVE_PYTHON 02300 //////////////////////////////////////////////////////////////////// 02301 // Function: NodePath::get_net_python_tag 02302 // Access: Published 02303 // Description: Returns the Python object that has been defined on 02304 // this node, or the nearest ancestor node, for the 02305 // indicated key. If no value has been defined for the 02306 // indicated key on any ancestor node, returns None. 02307 // See also get_python_tag(). 02308 //////////////////////////////////////////////////////////////////// 02309 INLINE PyObject *NodePath:: 02310 get_net_python_tag(const string &key) const { 02311 return find_net_python_tag(key).get_python_tag(key); 02312 } 02313 #endif // HAVE_PYTHON 02314 02315 #ifdef HAVE_PYTHON 02316 //////////////////////////////////////////////////////////////////// 02317 // Function: NodePath::has_net_python_tag 02318 // Access: Published 02319 // Description: Returns true if the indicated Python object has been 02320 // defined on this node or on any ancestor node, or 02321 // false otherwise. See also has_python_tag(). 02322 //////////////////////////////////////////////////////////////////// 02323 INLINE bool NodePath:: 02324 has_net_python_tag(const string &key) const { 02325 return !find_net_python_tag(key).is_empty(); 02326 } 02327 #endif // HAVE_PYTHON 02328 02329 //////////////////////////////////////////////////////////////////// 02330 // Function: NodePath::list_tags 02331 // Access: Published 02332 // Description: Lists the tags to the nout stream, one per line. See 02333 // PandaNode::list_tags() for a variant that allows you 02334 // to specify the output stream. 02335 //////////////////////////////////////////////////////////////////// 02336 INLINE void NodePath:: 02337 list_tags() const { 02338 nassertv_always(!is_empty()); 02339 node()->list_tags(nout); 02340 nout << "\n"; 02341 } 02342 02343 //////////////////////////////////////////////////////////////////// 02344 // Function: NodePath::set_name 02345 // Access: Published 02346 // Description: Changes the name of the referenced node. 02347 //////////////////////////////////////////////////////////////////// 02348 INLINE void NodePath:: 02349 set_name(const string &name) { 02350 nassertv_always(!is_empty()); 02351 node()->set_name(name); 02352 } 02353 02354 //////////////////////////////////////////////////////////////////// 02355 // Function: NodePath::get_name 02356 // Access: Published 02357 // Description: Returns the name of the referenced node. 02358 //////////////////////////////////////////////////////////////////// 02359 INLINE string NodePath:: 02360 get_name() const { 02361 nassertr_always(!is_empty(), string()); 02362 return node()->get_name(); 02363 } 02364 02365 //////////////////////////////////////////////////////////////////// 02366 // Function: NodePath::encode_to_bam_stream 02367 // Access: Published 02368 // Description: Converts the NodePath object into a single 02369 // stream of data using a BamWriter, and returns that 02370 // data as a string string. Returns empty string on 02371 // failure. This is similar to write_bam_stream(). 02372 // 02373 // This method is used by __reduce__ to handle streaming 02374 // of NodePaths to a pickle file. 02375 //////////////////////////////////////////////////////////////////// 02376 INLINE string NodePath:: 02377 encode_to_bam_stream() const { 02378 string data; 02379 if (!encode_to_bam_stream(data)) { 02380 return string(); 02381 } 02382 return data; 02383 } 02384 02385 02386 INLINE ostream &operator << (ostream &out, const NodePath &node_path) { 02387 node_path.output(out); 02388 return out; 02389 } 02390