EggTextureCollection

from panda3d.egg import EggTextureCollection
class EggTextureCollection

Bases: DTOOL_SUPER_BASE

This is a collection of textures by TRef name. It can extract the textures from an egg file and sort them all together; it can also manage the creation of unique textures and the assignment of unique TRef names.

Inheritance diagram

Inheritance diagram of EggTextureCollection

__init__(*args, **kwargs)
addTexture()

C++ Interface: add_texture(const EggTextureCollection self, EggTexture texture)

/**
  • Explicitly adds a new texture to the collection. Returns true if the

  • texture was added, false if it was already there or if there was some

  • error.

*/

add_texture()

C++ Interface: add_texture(const EggTextureCollection self, EggTexture texture)

/**
  • Explicitly adds a new texture to the collection. Returns true if the

  • texture was added, false if it was already there or if there was some

  • error.

*/

assign()

C++ Interface: assign(const EggTextureCollection self, const EggTextureCollection copy)

/**

*/

clear()

C++ Interface: clear(const EggTextureCollection self)

/**
  • Removes all textures from the collection.

*/

collapseEquivalentTextures()

C++ Interface: collapse_equivalent_textures(const EggTextureCollection self, int eq, EggGroupNode node)

/**
  • Walks through the collection and collapses together any separate textures

  • that are equivalent according to the indicated equivalence factor, eq (see

  • EggTexture::is_equivalent_to()). The return value is the number of

  • textures removed.

  • This flavor of collapse_equivalent_textures() automatically adjusts all the

  • primitives in the egg hierarchy to refer to the new texture pointers.

*/

/**
  • Walks through the collection and collapses together any separate textures

  • that are equivalent according to the indicated equivalence factor, eq (see

  • EggTexture::is_equivalent_to()). The return value is the number of

  • textures removed.

  • This flavor of collapse_equivalent_textures() does not adjust any

  • primitives in the egg hierarchy; instead, it fills up the ‘removed’ map

  • with an entry for each removed texture, mapping it back to the equivalent

  • retained texture. It’s up to the user to then call replace_textures() with

  • this map, if desired, to apply these changes to the egg hierarchy.

*/

collapse_equivalent_textures()

C++ Interface: collapse_equivalent_textures(const EggTextureCollection self, int eq, EggGroupNode node)

/**
  • Walks through the collection and collapses together any separate textures

  • that are equivalent according to the indicated equivalence factor, eq (see

  • EggTexture::is_equivalent_to()). The return value is the number of

  • textures removed.

  • This flavor of collapse_equivalent_textures() automatically adjusts all the

  • primitives in the egg hierarchy to refer to the new texture pointers.

*/

/**
  • Walks through the collection and collapses together any separate textures

  • that are equivalent according to the indicated equivalence factor, eq (see

  • EggTexture::is_equivalent_to()). The return value is the number of

  • textures removed.

  • This flavor of collapse_equivalent_textures() does not adjust any

  • primitives in the egg hierarchy; instead, it fills up the ‘removed’ map

  • with an entry for each removed texture, mapping it back to the equivalent

  • retained texture. It’s up to the user to then call replace_textures() with

  • this map, if desired, to apply these changes to the egg hierarchy.

*/

createUniqueTexture()

C++ Interface: create_unique_texture(const EggTextureCollection self, const EggTexture copy, int eq)

// create_unique_texture() creates a new texture if there is not already one // equivalent (according to eq, see EggTexture::is_equivalent_to()) to the // indicated texture, or returns the existing one if there is.

/**
  • Creates a new texture if there is not already one equivalent (according to

  • eq, see EggTexture::is_equivalent_to()) to the indicated texture, or

  • returns the existing one if there is.

*/

create_unique_texture()

C++ Interface: create_unique_texture(const EggTextureCollection self, const EggTexture copy, int eq)

// create_unique_texture() creates a new texture if there is not already one // equivalent (according to eq, see EggTexture::is_equivalent_to()) to the // indicated texture, or returns the existing one if there is.

/**
  • Creates a new texture if there is not already one equivalent (according to

  • eq, see EggTexture::is_equivalent_to()) to the indicated texture, or

  • returns the existing one if there is.

*/

extractTextures()

C++ Interface: extract_textures(const EggTextureCollection self, EggGroupNode node)

/**
  • Walks the egg hierarchy beginning at the indicated node, and removes any

  • EggTextures encountered in the hierarchy, adding them to the collection.

  • Returns the number of EggTextures encountered.

*/

extract_textures()

C++ Interface: extract_textures(const EggTextureCollection self, EggGroupNode node)

/**
  • Walks the egg hierarchy beginning at the indicated node, and removes any

  • EggTextures encountered in the hierarchy, adding them to the collection.

  • Returns the number of EggTextures encountered.

*/

findFilename()

C++ Interface: find_filename(EggTextureCollection self, const Filename filename)

// Find a texture with a particular filename.

/**
  • Returns the texture with the indicated filename, or NULL if no texture

  • matches.

*/

findTref()

C++ Interface: find_tref(EggTextureCollection self, str tref_name)

// Find a texture with a particular TRef name.

/**
  • Returns the texture with the indicated TRef name, or NULL if no texture

  • matches.

*/

findUsedTextures()

C++ Interface: find_used_textures(const EggTextureCollection self, EggNode node)

/**
  • Walks the egg hierarchy beginning at the indicated node, looking for

  • textures that are referenced by primitives but are not already members of

  • the collection, adding them to the collection.

  • If this is called following extract_textures(), it can be used to pick up

  • any additional texture references that appeared in the egg hierarchy (but

  • whose EggTexture node was not actually part of the hierarchy).

  • If this is called in lieu of extract_textures(), it will fill up the

  • collection with all of the referenced textures (and only the referenced

  • textures), without destructively removing the EggTextures from the

  • hierarchy.

  • This also has the side effect of incrementing the internal usage count for

  • a texture in the collection each time a texture reference is encountered.

  • This side effect is taken advantage of by remove_unused_textures().

  • And one more side effect: this function identifies the presence of

  • multitexturing in the egg file, and calls multitexture_over() on each

  • texture appropriately so that, after this call, you may expect

  • get_multitexture_sort() to return a reasonable value for each texture.

*/

find_filename()

C++ Interface: find_filename(EggTextureCollection self, const Filename filename)

// Find a texture with a particular filename.

/**
  • Returns the texture with the indicated filename, or NULL if no texture

  • matches.

*/

find_tref()

C++ Interface: find_tref(EggTextureCollection self, str tref_name)

// Find a texture with a particular TRef name.

/**
  • Returns the texture with the indicated TRef name, or NULL if no texture

  • matches.

*/

find_used_textures()

C++ Interface: find_used_textures(const EggTextureCollection self, EggNode node)

/**
  • Walks the egg hierarchy beginning at the indicated node, looking for

  • textures that are referenced by primitives but are not already members of

  • the collection, adding them to the collection.

  • If this is called following extract_textures(), it can be used to pick up

  • any additional texture references that appeared in the egg hierarchy (but

  • whose EggTexture node was not actually part of the hierarchy).

  • If this is called in lieu of extract_textures(), it will fill up the

  • collection with all of the referenced textures (and only the referenced

  • textures), without destructively removing the EggTextures from the

  • hierarchy.

  • This also has the side effect of incrementing the internal usage count for

  • a texture in the collection each time a texture reference is encountered.

  • This side effect is taken advantage of by remove_unused_textures().

  • And one more side effect: this function identifies the presence of

  • multitexturing in the egg file, and calls multitexture_over() on each

  • texture appropriately so that, after this call, you may expect

  • get_multitexture_sort() to return a reasonable value for each texture.

*/

getNumTextures()

C++ Interface: get_num_textures(EggTextureCollection self)

/**
  • Returns the number of EggTextures in the collection.

*/

getTexture()

C++ Interface: get_texture(EggTextureCollection self, int index)

/**
  • Returns the nth EggTexture in the collection.

*/

getTextures()
get_num_textures()

C++ Interface: get_num_textures(EggTextureCollection self)

/**
  • Returns the number of EggTextures in the collection.

*/

get_texture()

C++ Interface: get_texture(EggTextureCollection self, int index)

/**
  • Returns the nth EggTexture in the collection.

*/

get_textures()
isEmpty()

C++ Interface: is_empty(EggTextureCollection self)

/**
  • Returns true if there are no EggTexures in the collection, false otherwise.

*/

is_empty()

C++ Interface: is_empty(EggTextureCollection self)

/**
  • Returns true if there are no EggTexures in the collection, false otherwise.

*/

removeTexture()

C++ Interface: remove_texture(const EggTextureCollection self, EggTexture texture)

/**
  • Explicitly removes a texture from the collection. Returns true if the

  • texture was removed, false if it wasn’t there or if there was some error.

*/

removeUnusedTextures()

C++ Interface: remove_unused_textures(const EggTextureCollection self, EggNode node)

/**
  • Removes any textures from the collection that aren’t referenced by any

  • primitives in the indicated egg hierarchy. This also, incidentally, adds

  • textures to the collection that had been referenced by primitives but had

  • not previously appeared in the collection.

*/

remove_texture()

C++ Interface: remove_texture(const EggTextureCollection self, EggTexture texture)

/**
  • Explicitly removes a texture from the collection. Returns true if the

  • texture was removed, false if it wasn’t there or if there was some error.

*/

remove_unused_textures()

C++ Interface: remove_unused_textures(const EggTextureCollection self, EggNode node)

/**
  • Removes any textures from the collection that aren’t referenced by any

  • primitives in the indicated egg hierarchy. This also, incidentally, adds

  • textures to the collection that had been referenced by primitives but had

  • not previously appeared in the collection.

*/

sortByBasename()

C++ Interface: sort_by_basename(const EggTextureCollection self)

/**
  • Sorts all the textures into alphabetical order by the basename part

  • (including extension) of the filename. Subsequent operations using

  • begin()/end() will traverse in this sorted order.

*/

sortByTref()

C++ Interface: sort_by_tref(const EggTextureCollection self)

/**
  • Sorts all the textures into alphabetical order by TRef name. Subsequent

  • operations using begin()/end() will traverse in this sorted order.

*/

sort_by_basename()

C++ Interface: sort_by_basename(const EggTextureCollection self)

/**
  • Sorts all the textures into alphabetical order by the basename part

  • (including extension) of the filename. Subsequent operations using

  • begin()/end() will traverse in this sorted order.

*/

sort_by_tref()

C++ Interface: sort_by_tref(const EggTextureCollection self)

/**
  • Sorts all the textures into alphabetical order by TRef name. Subsequent

  • operations using begin()/end() will traverse in this sorted order.

*/

uniquifyTrefs()

C++ Interface: uniquify_trefs(const EggTextureCollection self)

/**
  • Guarantees that each texture in the collection has a unique TRef name.

  • This is essential before writing an egg file.

*/

uniquify_trefs()

C++ Interface: uniquify_trefs(const EggTextureCollection self)

/**
  • Guarantees that each texture in the collection has a unique TRef name.

  • This is essential before writing an egg file.

*/