22 MaterialCollection() {
30 _materials(copy._materials)
37 void MaterialCollection::
39 _materials = copy._materials;
51 if (_materials.get_ref_count() > 1) {
52 Materials old_materials = _materials;
53 _materials = Materials::empty_array(0);
54 _materials.v() = old_materials.v();
57 _materials.push_back(node_material);
66 int material_index = -1;
67 for (
int i = 0; material_index == -1 && i < (int)_materials.size(); i++) {
68 if (_materials[i] == node_material) {
73 if (material_index == -1) {
82 if (_materials.get_ref_count() > 1) {
83 Materials old_materials = _materials;
84 _materials = Materials::empty_array(0);
85 _materials.v() = old_materials.v();
88 _materials.erase(_materials.begin() + material_index);
100 for (
int i = 0; i < other_num_materials; i++) {
112 Materials new_materials;
114 for (
int i = 0; i < num_materials; i++) {
117 new_materials.push_back(material);
120 _materials = new_materials;
130 Materials new_materials;
133 for (
int i = 0; i < num_materials; i++) {
135 bool duplicated =
false;
137 for (
int j = 0; j < i && !duplicated; j++) {
142 new_materials.push_back(material);
146 _materials = new_materials;
178 for (
int i = 0; i < num_materials; i++) {
180 if (material->get_name() == name) {
192 return _materials.size();
200 nassertr(index >= 0 && index < (
int)_materials.size(),
nullptr);
202 return _materials[index];
211 nassertr(index >= 0 && index < (
int)_materials.size(),
nullptr);
213 return _materials[index];
222 return _materials.size();
243 write(std::ostream &out,
int indent_level)
const {
Material * operator [](int index) const
Returns the nth Material in the collection.
bool has_material(Material *material) const
Returns true if the indicated Material appears in this collection, false otherwise.
int size() const
Returns the number of materials in the collection.
void add_material(Material *node_material)
Adds a new Material to the collection.
void write(std::ostream &out, int indent_level=0) const
Writes a complete multi-line description of the MaterialCollection to the indicated output stream.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
void output(std::ostream &out) const
Writes a brief one-line description of the MaterialCollection to the indicated output stream.
Material * get_material(int index) const
Returns the nth Material in the collection.
Material * find_material(const std::string &name) const
Returns the material in the collection with the indicated name, if any, or NULL if no material has th...
void clear()
Removes all Materials from the collection.
Defines the way an object appears in the presence of lighting.
void remove_duplicate_materials()
Removes any duplicate entries of the same Materials on this collection.
void remove_materials_from(const MaterialCollection &other)
Removes from this collection all of the Materials listed in the other collection.
void add_materials_from(const MaterialCollection &other)
Adds all the Materials indicated in the other collection to this material.
int get_num_materials() const
Returns the number of Materials in the collection.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool remove_material(Material *node_material)
Removes the indicated Material from the collection.