EggMaterialCollection
from panda3d.egg import EggMaterialCollection
- class EggMaterialCollection
Bases:
DTOOL_SUPER_BASE
This is a collection of materials by MRef name. It can extract the materials from an egg file and sort them all together; it can also manage the creation of unique materials and the assignment of unique MRef names.
Inheritance diagram
- __init__(*args, **kwargs)
- addMaterial()
C++ Interface: add_material(const EggMaterialCollection self, EggMaterial material)
- /**
Explicitly adds a new material to the collection. Returns true if the
material was added, false if it was already there or if there was some
error.
*/
- add_material()
C++ Interface: add_material(const EggMaterialCollection self, EggMaterial material)
- /**
Explicitly adds a new material to the collection. Returns true if the
material was added, false if it was already there or if there was some
error.
*/
- assign()
C++ Interface: assign(const EggMaterialCollection self, const EggMaterialCollection copy)
- /**
*/
- clear()
C++ Interface: clear(const EggMaterialCollection self)
- /**
Removes all materials from the collection.
*/
- collapseEquivalentMaterials()
C++ Interface: collapse_equivalent_materials(const EggMaterialCollection self, int eq, EggGroupNode node)
- /**
Walks through the collection and collapses together any separate materials
that are equivalent according to the indicated equivalence factor, eq (see
EggMaterial::is_equivalent_to()). The return value is the number of
materials removed.
This flavor of collapse_equivalent_materials() automatically adjusts all
the primitives in the egg hierarchy to refer to the new material pointers.
*/
- /**
Walks through the collection and collapses together any separate materials
that are equivalent according to the indicated equivalence factor, eq (see
EggMaterial::is_equivalent_to()). The return value is the number of
materials removed.
This flavor of collapse_equivalent_materials() does not adjust any
primitives in the egg hierarchy; instead, it fills up the ‘removed’ map
with an entry for each removed material, mapping it back to the equivalent
retained material. It’s up to the user to then call replace_materials()
with this map, if desired, to apply these changes to the egg hierarchy.
*/
- collapse_equivalent_materials()
C++ Interface: collapse_equivalent_materials(const EggMaterialCollection self, int eq, EggGroupNode node)
- /**
Walks through the collection and collapses together any separate materials
that are equivalent according to the indicated equivalence factor, eq (see
EggMaterial::is_equivalent_to()). The return value is the number of
materials removed.
This flavor of collapse_equivalent_materials() automatically adjusts all
the primitives in the egg hierarchy to refer to the new material pointers.
*/
- /**
Walks through the collection and collapses together any separate materials
that are equivalent according to the indicated equivalence factor, eq (see
EggMaterial::is_equivalent_to()). The return value is the number of
materials removed.
This flavor of collapse_equivalent_materials() does not adjust any
primitives in the egg hierarchy; instead, it fills up the ‘removed’ map
with an entry for each removed material, mapping it back to the equivalent
retained material. It’s up to the user to then call replace_materials()
with this map, if desired, to apply these changes to the egg hierarchy.
*/
- createUniqueMaterial()
C++ Interface: create_unique_material(const EggMaterialCollection self, const EggMaterial copy, int eq)
// create_unique_material() creates a new material if there is not already // one equivalent (according to eq, see EggMaterial::is_equivalent_to()) to // the indicated material, or returns the existing one if there is.
- /**
Creates a new material if there is not already one equivalent (according to
eq, see EggMaterial::is_equivalent_to()) to the indicated material, or
returns the existing one if there is.
*/
- create_unique_material()
C++ Interface: create_unique_material(const EggMaterialCollection self, const EggMaterial copy, int eq)
// create_unique_material() creates a new material if there is not already // one equivalent (according to eq, see EggMaterial::is_equivalent_to()) to // the indicated material, or returns the existing one if there is.
- /**
Creates a new material if there is not already one equivalent (according to
eq, see EggMaterial::is_equivalent_to()) to the indicated material, or
returns the existing one if there is.
*/
- extractMaterials()
C++ Interface: extract_materials(const EggMaterialCollection self, EggGroupNode node)
- /**
Walks the egg hierarchy beginning at the indicated node, and removes any
EggMaterials encountered in the hierarchy, adding them to the collection.
Returns the number of EggMaterials encountered.
*/
- extract_materials()
C++ Interface: extract_materials(const EggMaterialCollection self, EggGroupNode node)
- /**
Walks the egg hierarchy beginning at the indicated node, and removes any
EggMaterials encountered in the hierarchy, adding them to the collection.
Returns the number of EggMaterials encountered.
*/
- findMref()
C++ Interface: find_mref(EggMaterialCollection self, str mref_name)
// Find a material with a particular MRef name.
- /**
Returns the material with the indicated MRef name, or NULL if no material
matches.
*/
- findUsedMaterials()
C++ Interface: find_used_materials(const EggMaterialCollection self, EggNode node)
- /**
Walks the egg hierarchy beginning at the indicated node, looking for
materials that are referenced by primitives but are not already members of
the collection, adding them to the collection.
If this is called following extract_materials(), it can be used to pick up
any additional material references that appeared in the egg hierarchy (but
whose EggMaterial node was not actually part of the hierarchy).
If this is called in lieu of extract_materials(), it will fill up the
collection with all of the referenced materials (and only the referenced
materials), without destructively removing the EggMaterials from the
hierarchy.
This also has the side effect of incrementing the internal usage count for
a material in the collection each time a material reference is encountered.
This side effect is taken advantage of by remove_unused_materials().
*/
- find_mref()
C++ Interface: find_mref(EggMaterialCollection self, str mref_name)
// Find a material with a particular MRef name.
- /**
Returns the material with the indicated MRef name, or NULL if no material
matches.
*/
- find_used_materials()
C++ Interface: find_used_materials(const EggMaterialCollection self, EggNode node)
- /**
Walks the egg hierarchy beginning at the indicated node, looking for
materials that are referenced by primitives but are not already members of
the collection, adding them to the collection.
If this is called following extract_materials(), it can be used to pick up
any additional material references that appeared in the egg hierarchy (but
whose EggMaterial node was not actually part of the hierarchy).
If this is called in lieu of extract_materials(), it will fill up the
collection with all of the referenced materials (and only the referenced
materials), without destructively removing the EggMaterials from the
hierarchy.
This also has the side effect of incrementing the internal usage count for
a material in the collection each time a material reference is encountered.
This side effect is taken advantage of by remove_unused_materials().
*/
- removeMaterial()
C++ Interface: remove_material(const EggMaterialCollection self, EggMaterial material)
- /**
Explicitly removes a material from the collection. Returns true if the
material was removed, false if it wasn’t there or if there was some error.
*/
- removeUnusedMaterials()
C++ Interface: remove_unused_materials(const EggMaterialCollection self, EggNode node)
- /**
Removes any materials from the collection that aren’t referenced by any
primitives in the indicated egg hierarchy. This also, incidentally, adds
materials to the collection that had been referenced by primitives but had
not previously appeared in the collection.
*/
- remove_material()
C++ Interface: remove_material(const EggMaterialCollection self, EggMaterial material)
- /**
Explicitly removes a material from the collection. Returns true if the
material was removed, false if it wasn’t there or if there was some error.
*/
- remove_unused_materials()
C++ Interface: remove_unused_materials(const EggMaterialCollection self, EggNode node)
- /**
Removes any materials from the collection that aren’t referenced by any
primitives in the indicated egg hierarchy. This also, incidentally, adds
materials to the collection that had been referenced by primitives but had
not previously appeared in the collection.
*/
- sortByMref()
C++ Interface: sort_by_mref(const EggMaterialCollection self)
- /**
Sorts all the materials into alphabetical order by MRef name. Subsequent
operations using begin()/end() will traverse in this sorted order.
*/
- sort_by_mref()
C++ Interface: sort_by_mref(const EggMaterialCollection self)
- /**
Sorts all the materials into alphabetical order by MRef name. Subsequent
operations using begin()/end() will traverse in this sorted order.
*/