Panda3D
nodePathCollection.cxx
1 // Filename: nodePathCollection.cxx
2 // Created by: drose (06Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "nodePathCollection.h"
16 #include "findApproxPath.h"
17 #include "findApproxLevelEntry.h"
18 #include "textureAttrib.h"
19 #include "colorScaleAttrib.h"
20 #include "colorAttrib.h"
21 #include "indent.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Function: NodePathCollection::Constructor
25 // Access: Published
26 // Description:
27 ////////////////////////////////////////////////////////////////////
28 NodePathCollection::
29 NodePathCollection() {
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function: NodePathCollection::Copy Constructor
34 // Access: Published
35 // Description:
36 ////////////////////////////////////////////////////////////////////
37 NodePathCollection::
38 NodePathCollection(const NodePathCollection &copy) :
39  _node_paths(copy._node_paths)
40 {
41 }
42 
43 ////////////////////////////////////////////////////////////////////
44 // Function: NodePathCollection::Copy Assignment Operator
45 // Access: Published
46 // Description:
47 ////////////////////////////////////////////////////////////////////
48 void NodePathCollection::
49 operator = (const NodePathCollection &copy) {
50  _node_paths = copy._node_paths;
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: NodePathCollection::add_path
55 // Access: Published
56 // Description: Adds a new NodePath to the collection.
57 ////////////////////////////////////////////////////////////////////
59 add_path(const NodePath &node_path) {
60  // If the pointer to our internal array is shared by any other
61  // NodePathCollections, we have to copy the array now so we won't
62  // inadvertently modify any of our brethren NodePathCollection
63  // objects.
64 
65  if (_node_paths.get_ref_count() > 1) {
66  NodePaths old_node_paths = _node_paths;
67  _node_paths = NodePaths::empty_array(0);
68  _node_paths.v() = old_node_paths.v();
69  }
70 
71  _node_paths.push_back(node_path);
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: NodePathCollection::remove_path
76 // Access: Published
77 // Description: Removes the indicated NodePath from the collection.
78 // Returns true if the path was removed, false if it was
79 // not a member of the collection.
80 ////////////////////////////////////////////////////////////////////
82 remove_path(const NodePath &node_path) {
83  int path_index = -1;
84  for (int i = 0; path_index == -1 && i < (int)_node_paths.size(); i++) {
85  if (_node_paths[i] == node_path) {
86  path_index = i;
87  }
88  }
89 
90  if (path_index == -1) {
91  // The indicated path was not a member of the collection.
92  return false;
93  }
94 
95  // If the pointer to our internal array is shared by any other
96  // NodePathCollections, we have to copy the array now so we won't
97  // inadvertently modify any of our brethren NodePathCollection
98  // objects.
99 
100  if (_node_paths.get_ref_count() > 1) {
101  NodePaths old_node_paths = _node_paths;
102  _node_paths = NodePaths::empty_array(0);
103  _node_paths.v() = old_node_paths.v();
104  }
105 
106  _node_paths.erase(_node_paths.begin() + path_index);
107  return true;
108 }
109 
110 ////////////////////////////////////////////////////////////////////
111 // Function: NodePathCollection::add_paths_from
112 // Access: Published
113 // Description: Adds all the NodePaths indicated in the other
114 // collection to this path. The other paths are simply
115 // appended to the end of the paths in this list;
116 // duplicates are not automatically removed.
117 ////////////////////////////////////////////////////////////////////
120  int other_num_paths = other.get_num_paths();
121  for (int i = 0; i < other_num_paths; i++) {
122  add_path(other.get_path(i));
123  }
124 }
125 
126 
127 ////////////////////////////////////////////////////////////////////
128 // Function: NodePathCollection::remove_paths_from
129 // Access: Published
130 // Description: Removes from this collection all of the NodePaths
131 // listed in the other collection.
132 ////////////////////////////////////////////////////////////////////
135  NodePaths new_paths;
136  int num_paths = get_num_paths();
137  for (int i = 0; i < num_paths; i++) {
138  NodePath path = get_path(i);
139  if (!other.has_path(path)) {
140  new_paths.push_back(path);
141  }
142  }
143  _node_paths = new_paths;
144 }
145 
146 ////////////////////////////////////////////////////////////////////
147 // Function: NodePathCollection::remove_duplicate_paths
148 // Access: Published
149 // Description: Removes any duplicate entries of the same NodePaths
150 // on this collection. If a NodePath appears multiple
151 // times, the first appearance is retained; subsequent
152 // appearances are removed.
153 ////////////////////////////////////////////////////////////////////
156  NodePaths new_paths;
157 
158  int num_paths = get_num_paths();
159  for (int i = 0; i < num_paths; i++) {
160  NodePath path = get_path(i);
161  bool duplicated = false;
162 
163  for (int j = 0; j < i && !duplicated; j++) {
164  duplicated = (path == get_path(j));
165  }
166 
167  if (!duplicated) {
168  new_paths.push_back(path);
169  }
170  }
171 
172  _node_paths = new_paths;
173 }
174 
175 ////////////////////////////////////////////////////////////////////
176 // Function: NodePathCollection::has_path
177 // Access: Published
178 // Description: Returns true if the indicated NodePath appears in
179 // this collection, false otherwise.
180 ////////////////////////////////////////////////////////////////////
182 has_path(const NodePath &path) const {
183  for (int i = 0; i < get_num_paths(); i++) {
184  if (path == get_path(i)) {
185  return true;
186  }
187  }
188  return false;
189 }
190 
191 ////////////////////////////////////////////////////////////////////
192 // Function: NodePathCollection::clear
193 // Access: Published
194 // Description: Removes all NodePaths from the collection.
195 ////////////////////////////////////////////////////////////////////
197 clear() {
198  _node_paths.clear();
199 }
200 
201 ////////////////////////////////////////////////////////////////////
202 // Function: NodePathCollection::reserve
203 // Access: Published
204 // Description: This is a hint to Panda to allocate enough memory
205 // to hold the given number of NodePaths, if you know
206 // ahead of time how many you will be adding.
207 ////////////////////////////////////////////////////////////////////
209 reserve(size_t num) {
210  _node_paths.reserve(num);
211 }
212 
213 ////////////////////////////////////////////////////////////////////
214 // Function: NodePathCollection::is_empty
215 // Access: Published
216 // Description: Returns true if there are no NodePaths in the
217 // collection, false otherwise.
218 ////////////////////////////////////////////////////////////////////
220 is_empty() const {
221  return _node_paths.empty();
222 }
223 
224 ////////////////////////////////////////////////////////////////////
225 // Function: NodePathCollection::get_num_paths
226 // Access: Published
227 // Description: Returns the number of NodePaths in the collection.
228 ////////////////////////////////////////////////////////////////////
230 get_num_paths() const {
231  return _node_paths.size();
232 }
233 
234 ////////////////////////////////////////////////////////////////////
235 // Function: NodePathCollection::get_path
236 // Access: Published
237 // Description: Returns the nth NodePath in the collection.
238 ////////////////////////////////////////////////////////////////////
240 get_path(int index) const {
241  nassertr(index >= 0 && index < (int)_node_paths.size(), NodePath());
242 
243  return _node_paths[index];
244 }
245 
246 ////////////////////////////////////////////////////////////////////
247 // Function: NodePathCollection::operator []
248 // Access: Published
249 // Description: Returns the nth NodePath in the collection. This is
250 // the same as get_path(), but it may be a more
251 // convenient way to access it.
252 ////////////////////////////////////////////////////////////////////
254 operator [] (int index) const {
255  nassertr(index >= 0 && index < (int)_node_paths.size(), NodePath());
256 
257  return _node_paths[index];
258 }
259 
260 ////////////////////////////////////////////////////////////////////
261 // Function: NodePathCollection::size
262 // Access: Published
263 // Description: Returns the number of paths in the collection. This
264 // is the same thing as get_num_paths().
265 ////////////////////////////////////////////////////////////////////
267 size() const {
268  return _node_paths.size();
269 }
270 
271 ////////////////////////////////////////////////////////////////////
272 // Function: NodePathCollection::ls
273 // Access: Published
274 // Description: Lists all the nodes at and below each node in the
275 // collection hierarchically.
276 ////////////////////////////////////////////////////////////////////
278 ls(ostream &out, int indent_level) const {
279  for (int i = 0; i < get_num_paths(); i++) {
280  NodePath path = get_path(i);
281  indent(out, indent_level) << path << "\n";
282  path.ls(out, indent_level + 2);
283  out << "\n";
284  }
285 }
286 
287 ////////////////////////////////////////////////////////////////////
288 // Function: NodePathCollection::find_all_matches
289 // Access: Published
290 // Description: Returns the complete set of all NodePaths that begin
291 // with any NodePath in this collection and can be
292 // extended by path. The shortest paths will be listed
293 // first.
294 ////////////////////////////////////////////////////////////////////
296 find_all_matches(const string &path) const {
297  NodePathCollection result;
298 
299  FindApproxPath approx_path;
300  if (approx_path.add_string(path)) {
301  if (!is_empty()) {
302  FindApproxLevelEntry *level = NULL;
303  for (int i = 0; i < get_num_paths(); i++) {
304  FindApproxLevelEntry *start =
305  new FindApproxLevelEntry(get_path(i), approx_path);
306  start->_next = level;
307  level = start;
308  }
309  get_path(0).find_matches(result, level, -1);
310  }
311  }
312 
313  return result;
314 }
315 
316 ////////////////////////////////////////////////////////////////////
317 // Function: NodePathCollection::reparent_to
318 // Access: Published
319 // Description: Reparents all the NodePaths in the collection to the
320 // indicated node.
321 ////////////////////////////////////////////////////////////////////
323 reparent_to(const NodePath &other) {
324  for (int i = 0; i < get_num_paths(); i++) {
325  get_path(i).reparent_to(other);
326  }
327 }
328 
329 ////////////////////////////////////////////////////////////////////
330 // Function: NodePathCollection::wrt_reparent_to
331 // Access: Published
332 // Description: Reparents all the NodePaths in the collection to the
333 // indicated node, adjusting each transform so as not to
334 // move in world coordinates.
335 ////////////////////////////////////////////////////////////////////
337 wrt_reparent_to(const NodePath &other) {
338  for (int i = 0; i < get_num_paths(); i++) {
339  get_path(i).wrt_reparent_to(other);
340  }
341 }
342 
343 ////////////////////////////////////////////////////////////////////
344 // Function: NodePathCollection::show
345 // Access: Published
346 // Description: Shows all NodePaths in the collection.
347 ////////////////////////////////////////////////////////////////////
349 show() {
350  for (int i = 0; i < get_num_paths(); i++) {
351  get_path(i).show();
352  }
353 }
354 
355 ////////////////////////////////////////////////////////////////////
356 // Function: NodePathCollection::show
357 // Access: Published
358 // Description: Hides all NodePaths in the collection.
359 ////////////////////////////////////////////////////////////////////
361 hide() {
362  for (int i = 0; i < get_num_paths(); i++) {
363  get_path(i).hide();
364  }
365 }
366 
367 ////////////////////////////////////////////////////////////////////
368 // Function: NodePathCollection::stash
369 // Access: Published
370 // Description: Stashes all NodePaths in the collection.
371 ////////////////////////////////////////////////////////////////////
373 stash() {
374  for (int i = 0; i < get_num_paths(); i++) {
375  get_path(i).stash();
376  }
377 }
378 
379 ////////////////////////////////////////////////////////////////////
380 // Function: NodePathCollection::unstash
381 // Access: Published
382 // Description: Unstashes all NodePaths in the collection.
383 ////////////////////////////////////////////////////////////////////
386  for (int i = 0; i < get_num_paths(); i++) {
387  get_path(i).unstash();
388  }
389 }
390 
391 ////////////////////////////////////////////////////////////////////
392 // Function: NodePathCollection::detach
393 // Access: Published
394 // Description: Detaches all NodePaths in the collection.
395 ////////////////////////////////////////////////////////////////////
398  for (int i = 0; i < get_num_paths(); i++) {
399  get_path(i).detach_node();
400  }
401 }
402 
403 ////////////////////////////////////////////////////////////////////
404 // Function: NodePathCollection::get_collide_mask
405 // Access: Published
406 // Description: Returns the union of all of the into_collide_masks
407 // for nodes at this level and below. This is the same
408 // thing as node()->get_net_collide_mask().
409 //
410 // If you want to return what the into_collide_mask of
411 // this node itself is, without regard to its children,
412 // use node()->get_into_collide_mask().
413 ////////////////////////////////////////////////////////////////////
416  CollideMask collide_mask;
417  for (int i = 0; i < get_num_paths(); i++) {
418  collide_mask |= get_path(i).get_collide_mask();
419  }
420  return collide_mask;
421 }
422 
423 ////////////////////////////////////////////////////////////////////
424 // Function: NodePathCollection::set_collide_mask
425 // Access: Published
426 // Description: Recursively applies the indicated CollideMask to the
427 // into_collide_masks for all nodes at this level and
428 // below.
429 //
430 // The default is to change all bits, but if
431 // bits_to_change is not all bits on, then only the bits
432 // that are set in bits_to_change are modified, allowing
433 // this call to change only a subset of the bits in the
434 // subgraph.
435 ////////////////////////////////////////////////////////////////////
437 set_collide_mask(CollideMask new_mask, CollideMask bits_to_change,
438  TypeHandle node_type) {
439  for (int i = 0; i < get_num_paths(); i++) {
440  get_path(i).set_collide_mask(new_mask, bits_to_change, node_type);
441  }
442 }
443 
444 ////////////////////////////////////////////////////////////////////
445 // Function: NodePathCollection::calc_tight_bounds
446 // Access: Published
447 // Description: Calculates the minimum and maximum vertices of all
448 // Geoms at these NodePath's bottom nodes and below
449 // This is a tight bounding box; it will generally be
450 // tighter than the bounding volume returned by
451 // get_bounds() (but it is more expensive to compute).
452 //
453 // The return value is true if any points are within the
454 // bounding volume, or false if none are.
455 ////////////////////////////////////////////////////////////////////
457 calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point) const {
458  bool have_bounds = false;
459 
460  for (int i = 0; i < get_num_paths(); i++) {
461  LPoint3 tmp_min;
462  LPoint3 tmp_max;
463 
464  if (get_path(i).is_empty()) {
465  continue;
466  }
467 
468  if (get_path(i).calc_tight_bounds(tmp_min, tmp_max)) {
469  if (!have_bounds) {
470  min_point = tmp_min;
471  max_point = tmp_max;
472  have_bounds = true;
473  } else {
474  min_point.set(min(min_point._v(0), tmp_min._v(0)),
475  min(min_point._v(1), tmp_min._v(1)),
476  min(min_point._v(2), tmp_min._v(2)));
477  max_point.set(max(max_point._v(0), tmp_max._v(0)),
478  max(max_point._v(1), tmp_max._v(1)),
479  max(max_point._v(2), tmp_max._v(2)));
480  }
481  }
482  }
483 
484  return have_bounds;
485 }
486 
487 ////////////////////////////////////////////////////////////////////
488 // Function: NodePathCollection::set_texture
489 // Access: Published
490 // Description: Adds the indicated texture to the list of textures
491 // that will be rendered on the default texture stage.
492 //
493 // This is the deprecated single-texture variant of this
494 // method; it is now superceded by set_texture() that
495 // accepts a stage and texture. However, this method
496 // may be used in the presence of multitexture if you
497 // just want to adjust the default stage.
498 ////////////////////////////////////////////////////////////////////
500 set_texture(Texture *tex, int priority) {
502  set_texture(stage, tex, priority);
503 }
504 
505 ////////////////////////////////////////////////////////////////////
506 // Function: NodePathCollection::set_texture
507 // Access: Published
508 // Description: Adds the indicated texture to the list of textures
509 // that will be rendered on the indicated multitexture
510 // stage. If there are multiple texture stages
511 // specified (possibly on multiple different nodes at
512 // different levels), they will all be applied to
513 // geometry together, according to the stage
514 // specification set up in the TextureStage object.
515 ////////////////////////////////////////////////////////////////////
517 set_texture(TextureStage *stage, Texture *tex, int priority) {
518  StateMap state_map;
519 
520  NodePaths::iterator npi;
521  for (npi = _node_paths.begin(); npi != _node_paths.end(); ++npi) {
522  NodePath &np = (*npi);
523  CPT(RenderState) orig_state = np.get_state();
524  StateMap::iterator smi = state_map.find(orig_state);
525  if (smi != state_map.end()) {
526  // This RenderState has already been encountered; reuse it.
527  np.set_state((*smi).second);
528  } else {
529  // This RenderState has not yet been encountered; apply the
530  // attrib to it.
531  np.set_texture(stage, tex, priority);
532  state_map[orig_state] = np.get_state();
533  }
534  }
535 }
536 
537 ////////////////////////////////////////////////////////////////////
538 // Function: NodePathCollection::set_texture_off
539 // Access: Published
540 // Description: Sets the geometry at this level and below to render
541 // using no texture, on any stage. This is different
542 // from not specifying a texture; rather, this
543 // specifically contradicts set_texture() at a higher
544 // node level (or, with a priority, overrides a
545 // set_texture() at a lower level).
546 ////////////////////////////////////////////////////////////////////
548 set_texture_off(int priority) {
549  nassertv_always(!is_empty());
550  set_attrib(TextureAttrib::make_all_off(), priority);
551 }
552 
553 ////////////////////////////////////////////////////////////////////
554 // Function: NodePathCollection::set_texture_off
555 // Access: Published
556 // Description: Sets the geometry at this level and below to render
557 // using no texture, on the indicated stage. This is
558 // different from not specifying a texture; rather, this
559 // specifically contradicts set_texture() at a higher
560 // node level (or, with a priority, overrides a
561 // set_texture() at a lower level).
562 ////////////////////////////////////////////////////////////////////
564 set_texture_off(TextureStage *stage, int priority) {
565  StateMap state_map;
566 
567  NodePaths::iterator npi;
568  for (npi = _node_paths.begin(); npi != _node_paths.end(); ++npi) {
569  NodePath &np = (*npi);
570  CPT(RenderState) orig_state = np.get_state();
571  StateMap::iterator smi = state_map.find(orig_state);
572  if (smi != state_map.end()) {
573  // This RenderState has already been encountered; reuse it.
574  np.set_state((*smi).second);
575  } else {
576  // This RenderState has not yet been encountered; apply the
577  // attrib to it.
578  np.set_texture_off(stage, priority);
579  state_map[orig_state] = np.get_state();
580  }
581  }
582 }
583 
584 ////////////////////////////////////////////////////////////////////
585 // Function: NodePathCollection::set_color
586 // Access: Published
587 // Description: Colors all NodePaths in the collection
588 ////////////////////////////////////////////////////////////////////
590 set_color(const LColor &color, int priority) {
591  set_attrib(ColorAttrib::make_flat(color), priority);
592 }
593 
594 ////////////////////////////////////////////////////////////////////
595 // Function: NodePathCollection::set_color_scale
596 // Access: Published
597 // Description: Applies color scales to all NodePaths in the
598 // collection. The existing color scale is replaced.
599 ////////////////////////////////////////////////////////////////////
601 set_color_scale(const LVecBase4 &scale, int priority) {
602  StateMap state_map;
603 
604  NodePaths::iterator npi;
605  for (npi = _node_paths.begin(); npi != _node_paths.end(); ++npi) {
606  NodePath &np = (*npi);
607  CPT(RenderState) orig_state = np.get_state();
608  StateMap::iterator smi = state_map.find(orig_state);
609  if (smi != state_map.end()) {
610  // This RenderState has already been encountered; reuse it.
611  np.set_state((*smi).second);
612  } else {
613  // This RenderState has not yet been encountered; apply the
614  // attrib to it.
615  np.set_color_scale(scale, priority);
616  state_map[orig_state] = np.get_state();
617  }
618  }
619 }
620 
621 ////////////////////////////////////////////////////////////////////
622 // Function: NodePathCollection::compose_color_scale
623 // Access: Published
624 // Description: Applies color scales to all NodePaths in the
625 // collection. The existing color scale, if any, is
626 // multiplied by the specified color scale.
627 ////////////////////////////////////////////////////////////////////
629 compose_color_scale(const LVecBase4 &scale, int priority) {
630  StateMap state_map;
631 
632  NodePaths::iterator npi;
633  for (npi = _node_paths.begin(); npi != _node_paths.end(); ++npi) {
634  NodePath &np = (*npi);
635  CPT(RenderState) orig_state = np.get_state();
636  StateMap::iterator smi = state_map.find(orig_state);
637  if (smi != state_map.end()) {
638  // This RenderState has already been encountered; reuse it.
639  np.set_state((*smi).second);
640  } else {
641  // This RenderState has not yet been encountered; apply the
642  // attrib to it.
643  np.compose_color_scale(scale, priority);
644  state_map[orig_state] = np.get_state();
645  }
646  }
647 }
648 
649 ////////////////////////////////////////////////////////////////////
650 // Function: NodePathCollection::set_attrib
651 // Access: Published
652 // Description: Applies the indicated RenderAttrib to all NodePaths
653 // in the collection. An effort is made to apply the
654 // attrib to many NodePaths as quickly as possible;
655 // redundant RenderState compositions are not
656 // duplicated.
657 ////////////////////////////////////////////////////////////////////
659 set_attrib(const RenderAttrib *attrib, int priority) {
660  StateMap state_map;
661 
662  NodePaths::iterator npi;
663  for (npi = _node_paths.begin(); npi != _node_paths.end(); ++npi) {
664  NodePath &np = (*npi);
665  CPT(RenderState) orig_state = np.get_state();
666  StateMap::iterator smi = state_map.find(orig_state);
667  if (smi != state_map.end()) {
668  // This RenderState has already been encountered; reuse it.
669  np.set_state((*smi).second);
670  } else {
671  // This RenderState has not yet been encountered; apply the
672  // attrib to it.
673  np.set_attrib(attrib, priority);
674  state_map[orig_state] = np.get_state();
675  }
676  }
677 }
678 
679 ////////////////////////////////////////////////////////////////////
680 // Function: NodePathCollection::output
681 // Access: Published
682 // Description: Writes a brief one-line description of the
683 // NodePathCollection to the indicated output stream.
684 ////////////////////////////////////////////////////////////////////
686 output(ostream &out) const {
687  if (get_num_paths() == 1) {
688  out << "1 NodePath";
689  } else {
690  out << get_num_paths() << " NodePaths";
691  }
692 }
693 
694 ////////////////////////////////////////////////////////////////////
695 // Function: NodePathCollection::write
696 // Access: Published
697 // Description: Writes a complete multi-line description of the
698 // NodePathCollection to the indicated output stream.
699 ////////////////////////////////////////////////////////////////////
701 write(ostream &out, int indent_level) const {
702  for (int i = 0; i < get_num_paths(); i++) {
703  indent(out, indent_level) << get_path(i) << "\n";
704  }
705 }
void unstash(int sort=0, Thread *current_thread=Thread::get_current_thread())
Undoes the effect of a previous stash() on this node: makes the referenced node (and the entire subgr...
Definition: nodePath.cxx:5927
void ls() const
Lists all the nodes at and below each node in the collection hierarchically.
bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, Thread *current_thread=Thread::get_current_thread()) const
Calculates the minimum and maximum vertices of all Geoms at this NodePath&#39;s bottom node and below...
Definition: nodePath.cxx:6198
bool remove_path(const NodePath &node_path)
Removes the indicated NodePath from the collection.
This is our own Panda specialization on the default STL map.
Definition: pmap.h:52
void add_path(const NodePath &node_path)
Adds a new NodePath to the collection.
void set_collide_mask(CollideMask new_mask, CollideMask bits_to_change=CollideMask::all_on(), TypeHandle node_type=TypeHandle::none())
Recursively applies the indicated CollideMask to the into_collide_masks for all nodes at this level a...
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
void set_collide_mask(CollideMask new_mask, CollideMask bits_to_change=CollideMask::all_on(), TypeHandle node_type=TypeHandle::none())
Recursively applies the indicated CollideMask to the into_collide_masks for all nodes at this level a...
Definition: nodePath.I:2349
NodePathCollection find_all_matches(const string &path) const
Returns the complete set of all NodePaths that begin with any NodePath in this collection and can be ...
bool is_empty() const
Returns true if the NodePath contains no nodes.
Definition: nodePath.I:236
This class is local to this package only; it doesn&#39;t get exported.
void unstash()
Unstashes all NodePaths in the collection.
void clear()
Removes all NodePaths from the collection.
bool is_empty() const
Returns true if there are no NodePaths in the collection, false otherwise.
void add_paths_from(const NodePathCollection &other)
Adds all the NodePaths indicated in the other collection to this path.
void remove_paths_from(const NodePathCollection &other)
Removes from this collection all of the NodePaths listed in the other collection. ...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
This class is local to this package only; it doesn&#39;t get exported.
void wrt_reparent_to(const NodePath &other)
Reparents all the NodePaths in the collection to the indicated node, adjusting each transform so as n...
void compose_color_scale(const LVecBase4 &scale, int priority=0)
multiplies the color scale component of the transform, with previous color scale leaving translation ...
Definition: nodePath.cxx:2392
void show()
Shows all NodePaths in the collection.
void write(ostream &out, int indent_level=0) const
Writes a complete multi-line description of the NodePathCollection to the indicated output stream...
void hide()
Hides all NodePaths in the collection.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
void show()
Undoes the effect of a previous hide() on this node: makes the referenced node (and the entire subgra...
Definition: nodePath.I:2202
void set_texture(Texture *tex, int priority=0)
Adds the indicated texture to the list of textures that will be rendered on the default texture stage...
Definition: nodePath.cxx:3346
void stash()
Stashes all NodePaths in the collection.
void compose_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a=1.0, int priority=0)
Applies color scales to all NodePaths in the collection.
void set_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a=1.0, int priority=0)
Applies color scales to all NodePaths in the collection.
CollideMask get_collide_mask() const
Returns the union of all of the into_collide_masks for nodes at this level and below.
Definition: nodePath.I:2328
void reparent_to(const NodePath &other, int sort=0, Thread *current_thread=Thread::get_current_thread())
Removes the referenced node of the NodePath from its current parent and attaches it to the referenced...
Definition: nodePath.cxx:523
bool has_path(const NodePath &path) const
Returns true if the indicated NodePath appears in this collection, false otherwise.
void set_attrib(const RenderAttrib *attrib, int priority=0)
Applies the indicated RenderAttrib to all NodePaths in the collection.
void detach()
Detaches all NodePaths in the collection.
void output(ostream &out) const
Writes a brief one-line description of the NodePathCollection to the indicated output stream...
NodePath operator[](int index) const
Returns the nth NodePath in the collection.
NodePath get_path(int index) const
Returns the nth NodePath in the collection.
int get_num_paths() const
Returns the number of NodePaths in the collection.
void set_texture(Texture *tex, int priority=0)
Adds the indicated texture to the list of textures that will be rendered on the default texture stage...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
void set_texture_off(int priority=0)
Sets the geometry at this level and below to render using no texture, on any stage.
Definition: nodePath.cxx:3457
void wrt_reparent_to(const NodePath &other, int sort=0, Thread *current_thread=Thread::get_current_thread())
This functions identically to reparent_to(), except the transform on this node is also adjusted so th...
Definition: nodePath.cxx:572
void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a=1.0, int priority=0)
Colors all NodePaths in the collection.
void reserve(size_t num)
This is a hint to Panda to allocate enough memory to hold the given number of NodePaths, if you know ahead of time how many you will be adding.
bool add_string(const string &str_path)
Adds a sequence of components separated by slashes, followed optionally by a semicolon and a sequence...
int size() const
Returns the number of paths in the collection.
void stash(int sort=0, Thread *current_thread=Thread::get_current_thread())
Removes the referenced node (and the entire subgraph below this node) from the scene graph in any nor...
Definition: nodePath.cxx:5907
bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point) const
Calculates the minimum and maximum vertices of all Geoms at these NodePath&#39;s bottom nodes and below T...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
static TextureStage * get_default()
Returns the default TextureStage that will be used for all texturing that does not name a particular ...
Definition: textureStage.I:766
void hide()
Makes the referenced node (and the entire subgraph below this node) invisible to all cameras...
Definition: nodePath.I:2270
void set_texture_off(int priority=0)
Sets the geometry at this level and below to render using no texture, on any stage.
void ls() const
Lists the hierarchy at and below the referenced node.
Definition: nodePath.I:492
Defines the properties of a named stage of the multitexture pipeline.
Definition: textureStage.h:38
void remove_duplicate_paths()
Removes any duplicate entries of the same NodePaths on this collection.
void detach_node(Thread *current_thread=Thread::get_current_thread())
Disconnects the referenced node from its parent, but does not immediately delete it.
Definition: nodePath.cxx:804
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
void set_state(const RenderState *state, Thread *current_thread=Thread::get_current_thread())
Changes the complete state object on this node.
Definition: nodePath.I:543
void set_color_scale(const LVecBase4 &scale, int priority=0)
Sets the color scale component of the transform, leaving translation and rotation untouched...
Definition: nodePath.cxx:2424
CollideMask get_collide_mask() const
Returns the union of all of the into_collide_masks for nodes at this level and below.
void reparent_to(const NodePath &other)
Reparents all the NodePaths in the collection to the indicated node.
const RenderState * get_state(Thread *current_thread=Thread::get_current_thread()) const
Returns the complete state object set on this node.
Definition: nodePath.cxx:848
This is a set of zero or more NodePaths.