Panda3D
Loading...
Searching...
No Matches
nodePathCollection.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file nodePathCollection.h
10 * @author drose
11 * @date 2002-03-06
12 */
13
14#ifndef NODEPATHCOLLECTION_H
15#define NODEPATHCOLLECTION_H
16
17#include "pandabase.h"
18#include "nodePath.h"
19#include "pointerToArray.h"
20
21/**
22 * This is a set of zero or more NodePaths. It's handy for returning from
23 * functions that need to return multiple NodePaths (for instance,
24 * NodePaths::get_children).
25 */
26class EXPCL_PANDA_PGRAPH NodePathCollection {
27PUBLISHED:
28 NodePathCollection() = default;
29
30#ifdef HAVE_PYTHON
31 EXTENSION(NodePathCollection(PyObject *self, PyObject *sequence));
32 EXTENSION(PyObject *__reduce__(PyObject *self) const);
33#endif
34
35 void add_path(const NodePath &node_path);
36 bool remove_path(const NodePath &node_path);
37 void add_paths_from(const NodePathCollection &other);
38 void remove_paths_from(const NodePathCollection &other);
40 bool has_path(const NodePath &path) const;
41 void clear();
42 void reserve(size_t num);
43
44 bool is_empty() const;
45 int get_num_paths() const;
46 NodePath get_path(int index) const;
47 MAKE_SEQ(get_paths, get_num_paths, get_path);
48 NodePath operator [] (size_t index) const;
49 size_t size() const;
50 INLINE void operator += (const NodePathCollection &other);
51 INLINE NodePathCollection operator + (const NodePathCollection &other) const;
52
53 // Method names to satisfy Python's conventions.
54 INLINE void append(const NodePath &node_path);
55 INLINE void extend(const NodePathCollection &other);
56
57 // Handy operations on many NodePaths at once.
58 INLINE void ls() const;
59 void ls(std::ostream &out, int indent_level = 0) const;
60
61 NodePathCollection find_all_matches(const std::string &path) const;
62 void reparent_to(const NodePath &other);
63 void wrt_reparent_to(const NodePath &other);
64
65 void show();
66 void hide();
67 void stash();
68 void unstash();
69 void detach();
70
71 CollideMask get_collide_mask() const;
72 void set_collide_mask(CollideMask new_mask, CollideMask bits_to_change = CollideMask::all_on(),
73 TypeHandle node_type = TypeHandle::none());
74
75 bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point) const;
76
77 EXTENSION(PyObject *get_tight_bounds() const);
78
79 void set_texture(Texture *tex, int priority = 0);
80 void set_texture(TextureStage *stage, Texture *tex, int priority = 0);
81 void set_texture_off(int priority = 0);
82 void set_texture_off(TextureStage *stage, int priority = 0);
83
84 INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0,
85 int priority = 0);
86 void set_color(const LColor &color, int priority = 0);
87
88 INLINE void set_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0,
89 int priority = 0);
90 void set_color_scale(const LVecBase4 &scale, int priority = 0);
91
92 INLINE void compose_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0,
93 int priority = 0);
94 void compose_color_scale(const LVecBase4 &scale, int priority = 0);
95
96 void set_attrib(const RenderAttrib *attrib, int priority = 0);
97
98 void output(std::ostream &out) const;
99 void write(std::ostream &out, int indent_level = 0) const;
100
101private:
102 typedef PTA(NodePath) NodePaths;
103 NodePaths _node_paths;
104
105 // This typedef is used in set_attrib() and similar methods.
106 typedef pmap<CPT(RenderState), CPT(RenderState) > StateMap;
107};
108
109INLINE std::ostream &operator << (std::ostream &out, const NodePathCollection &col) {
110 col.output(out);
111 return out;
112}
113
114#include "nodePathCollection.I"
115
116#endif
static BitMask< uint32_t, nbits > all_on()
This is a set of zero or more NodePaths.
void reparent_to(const NodePath &other)
Reparents all the NodePaths in the collection to the indicated node.
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 unstash()
Unstashes all NodePaths in the collection.
void add_path(const NodePath &node_path)
Adds a new NodePath to the collection.
void set_attrib(const RenderAttrib *attrib, int priority=0)
Applies the indicated RenderAttrib to all NodePaths in the collection.
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 add_paths_from(const NodePathCollection &other)
Adds all the NodePaths indicated in the other collection to this path.
size_t size() const
Returns the number of paths in 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...
void extend(const NodePathCollection &other)
Appends the other list onto the end of this one.
void write(std::ostream &out, int indent_level=0) const
Writes a complete multi-line description of the NodePathCollection to the indicated output stream.
void ls() const
Lists all the nodes at and below each node in the collection hierarchically.
void detach()
Detaches all NodePaths in the collection.
void remove_paths_from(const NodePathCollection &other)
Removes from this collection all of the NodePaths listed in the other collection.
void set_texture_off(int priority=0)
Sets the geometry at this level and below to render using no texture, on any stage.
void remove_duplicate_paths()
Removes any duplicate entries of the same NodePaths on this collection.
void show()
Shows 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.
void reserve(size_t num)
This is a hint to Panda to allocate enough memory to hold the given number of NodePaths,...
bool remove_path(const NodePath &node_path)
Removes the indicated NodePath from the collection.
bool is_empty() const
Returns true if there are no NodePaths in the collection, false otherwise.
void stash()
Stashes all NodePaths in the collection.
void append(const NodePath &node_path)
Adds a new NodePath to the collection.
void hide()
Hides all NodePaths in the collection.
get_num_paths
Returns the number of NodePaths in the collection.
NodePathCollection find_all_matches(const std::string &path) const
Returns the complete set of all NodePaths that begin with any NodePath in this collection and can be ...
void output(std::ostream &out) const
Writes a brief one-line description of the NodePathCollection to the indicated output stream.
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.
void wrt_reparent_to(const NodePath &other)
Reparents all the NodePaths in the collection to the indicated node, adjusting each transform so as n...
bool has_path(const NodePath &path) const
Returns true if the indicated NodePath appears in this collection, false otherwise.
get_path
Returns the nth NodePath 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...
bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point) const
Calculates the minimum and maximum vertices of all Geoms at these NodePath's bottom nodes and below T...
void clear()
Removes all NodePaths from the collection.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
This is the base class for a number of render attributes (other than transform) that may be set on sc...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
Defines the properties of a named stage of the multitexture pipeline.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition texture.h:72
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.