#include <eggTextureCollection.h>
Public Types | |
typedef OrderedTextures::const_iterator | iterator |
typedef iterator | const_iterator |
typedef OrderedTextures::size_type | size_type |
typedef pmap< PT_EggTexture, PT_EggTexture > | TextureReplacement |
Public Member Functions | |
EggTextureCollection () | |
EggTextureCollection (const EggTextureCollection ©) | |
EggTextureCollection & | operator= (const EggTextureCollection ©) |
~EggTextureCollection () | |
void | clear () |
Removes all textures from the collection. | |
int | extract_textures (EggGroupNode *node) |
Walks the egg hierarchy beginning at the indicated node, and removes any EggTextures encountered in the hierarchy, adding them to the collection. | |
EggGroupNode::iterator | insert_textures (EggGroupNode *node) |
Adds a series of EggTexture nodes to the beginning of the indicated node to reflect each of the textures in the collection. | |
EggGroupNode::iterator | insert_textures (EggGroupNode *node, EggGroupNode::iterator position) |
Adds a series of EggTexture nodes to the beginning of the indicated node to reflect each of the textures in the collection. | |
int | find_used_textures (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. | |
void | remove_unused_textures (EggNode *node) |
Removes any textures from the collection that aren't referenced by any primitives in the indicated egg hierarchy. | |
int | collapse_equivalent_textures (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()). | |
int | collapse_equivalent_textures (int eq, TextureReplacement &removed) |
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()). | |
void | uniquify_trefs () |
Guarantees that each texture in the collection has a unique TRef name. | |
void | sort_by_tref () |
Sorts all the textures into alphabetical order by TRef name. | |
iterator | begin () const |
iterator | end () const |
bool | empty () const |
size_type | size () const |
bool | add_texture (EggTexture *texture) |
Explicitly adds a new texture to the collection. | |
bool | remove_texture (EggTexture *texture) |
Explicitly removes a texture from the collection. | |
EggTexture * | create_unique_texture (const EggTexture ©, int eq) |
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. | |
EggTexture * | find_tref (const string &tref_name) const |
Returns the texture with the indicated TRef name, or NULL if no texture matches. | |
EggTexture * | find_filename (const Filename &filename) const |
Returns the texture with the indicated filename, or NULL if no texture matches. | |
Static Public Member Functions | |
void | replace_textures (EggGroupNode *node, const TextureReplacement &replace) |
Walks the egg hierarchy, changing out any reference to a texture appearing on the left side of the map with its corresponding texture on the right side. | |
Private Types | |
typedef pmap< PT_EggTexture, int > | Textures |
typedef vector_PT_EggTexture | OrderedTextures |
Private Attributes | |
Textures | _textures |
OrderedTextures | _ordered_textures |
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.
Definition at line 49 of file eggTextureCollection.h.
|
Definition at line 61 of file eggTextureCollection.h. |
|
Definition at line 60 of file eggTextureCollection.h. |
|
Definition at line 57 of file eggTextureCollection.h. |
|
Definition at line 62 of file eggTextureCollection.h. Referenced by empty(). |
|
Definition at line 64 of file eggTextureCollection.h. |
|
Definition at line 56 of file eggTextureCollection.h. |
|
Definition at line 39 of file eggTextureCollection.cxx. |
|
Definition at line 50 of file eggTextureCollection.cxx. References _ordered_textures, and _textures. |
|
Definition at line 78 of file eggTextureCollection.cxx. References _ordered_textures. |
|
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. Definition at line 477 of file eggTextureCollection.cxx. References _ordered_textures, and tex. |
|
Definition at line 23 of file eggTextureCollection.I. References _ordered_textures. |
|
Removes all textures from the collection.
Definition at line 90 of file eggTextureCollection.cxx. References EggGroupNode::find_textures(). |
|
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. Definition at line 341 of file eggTextureCollection.cxx. |
|
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. Definition at line 297 of file eggTextureCollection.cxx. References EggGroupNode::begin(), DCAST, EggGroupNode::end(), EggGroupNode::get_class_type(), EggPrimitive::get_class_type(), EggPrimitive::get_texture(), EggPrimitive::has_texture(), TypedObject::is_of_type(), EggGroupNode::iterator, PT, replace_textures(), EggPrimitive::set_texture(), and tex. Referenced by find_used_textures(), EggData::merge(), and EggData::set_coordinate_system(). |
|
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.
Definition at line 547 of file eggTextureCollection.cxx. |
|
Definition at line 35 of file eggTextureCollection.I. References _ordered_textures, _textures, INLINE, nassertr, PointerToArray< PointerTo< Texture > >::size(), and size_type. |
|
Definition at line 30 of file eggTextureCollection.I. References _ordered_textures, and INLINE. |
|
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. Definition at line 110 of file eggTextureCollection.cxx. References _ordered_textures, EggGroupNode::insert(), and EggGroupNode::iterator. Referenced by EggData::set_coordinate_system(). |
|
Returns the texture with the indicated filename, or NULL if no texture matches.
Definition at line 603 of file eggTextureCollection.cxx. |
|
Returns the texture with the indicated TRef name, or NULL if no texture matches.
Definition at line 576 of file eggTextureCollection.cxx. |
|
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(). Definition at line 213 of file eggTextureCollection.cxx. References collapse_equivalent_textures(), and replace_textures(). Referenced by insert_textures(), and EggData::merge(). |
|
Adds a series of EggTexture nodes to the beginning of the indicated node to reflect each of the textures in the collection. Returns an iterator representing the first position after the newly inserted textures. Definition at line 150 of file eggTextureCollection.cxx. References _ordered_textures, _textures, EggGroupNode::begin(), DCAST, EggGroupNode::end(), PointerToArray< PointerTo< Texture > >::end(), find_used_textures(), EggGroupNode::get_class_type(), EggPrimitive::get_class_type(), EggPrimitive::get_texture(), EggPrimitive::has_texture(), PointerToArray< PointerTo< Texture > >::insert(), TypedObject::is_of_type(), EggGroupNode::iterator, and tex. |
|
Adds a series of EggTexture nodes to the beginning of the indicated node to reflect each of the textures in the collection. Returns an iterator representing the first position after the newly inserted textures. Definition at line 131 of file eggTextureCollection.cxx. |
|
Definition at line 64 of file eggTextureCollection.cxx. |
|
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. Definition at line 509 of file eggTextureCollection.cxx. |
|
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. Definition at line 264 of file eggTextureCollection.cxx. References tex. Referenced by EggData::set_coordinate_system(). |
|
Walks the egg hierarchy, changing out any reference to a texture appearing on the left side of the map with its corresponding texture on the right side. This is most often done following a call to collapse_equivalent_textures(). It does not directly affect the Collection. Definition at line 394 of file eggTextureCollection.cxx. References _textures. Referenced by collapse_equivalent_textures(), and find_used_textures(). |
|
Definition at line 40 of file eggTextureCollection.I. |
|
Sorts all the textures into alphabetical order by TRef name. Subsequent operations using begin()/end() will traverse in this sorted order. Definition at line 459 of file eggTextureCollection.cxx. Referenced by EggData::set_coordinate_system(). |
|
Guarantees that each texture in the collection has a unique TRef name. This is essential before writing an egg file. Definition at line 433 of file eggTextureCollection.cxx. References tex. Referenced by EggData::set_coordinate_system(). |
|
Definition at line 115 of file eggTextureCollection.h. Referenced by add_texture(), begin(), EggTextureCollection(), empty(), end(), extract_textures(), insert_textures(), and ~EggTextureCollection(). |
|
Definition at line 114 of file eggTextureCollection.h. Referenced by EggTextureCollection(), empty(), insert_textures(), and replace_textures(). |