Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PaletteGroup Class Reference

This is the highest level of grouping for TextureImages. More...

#include <paletteGroup.h>

Inheritance diagram for PaletteGroup:

TypedWritable Namable TypedObject List of all members.

Public Member Functions

 PaletteGroup ()
void set_dirname (const string &dirname)
 Sets the directory name associated with the palette group.

bool has_dirname () const
 Returns true if the directory name has been explicitly set for this group.

const string & get_dirname () const
 Returns the directory name associated with the palette group.

void clear_depends ()
 Eliminates all the dependency information for this group.

void group_with (PaletteGroup *other)
 Indicates a dependency of this group on some other group.

const PaletteGroupsget_groups () const
 Returns the set of groups this group depends on.

void get_placements (pvector< TexturePlacement * > &placements) const
 Adds the set of TexturePlacements associated with this group to the indicated vector.

void get_complete_placements (pvector< TexturePlacement * > &placements) const
 Adds the set of TexturePlacements associated with this group and all dependent groups to the indicated vector.

void reset_dependency_level ()
 Unconditionally sets the dependency level and order of this group to zero, in preparation for a later call to set_dependency_level().

void set_dependency_level (int level)
 Sets the dependency level of this group to the indicated level, provided that level is not lower than the level that was set previously.

bool set_dependency_order ()
 Updates the dependency order of this group.

int get_dependency_level () const
 Returns the dependency level of this group.

int get_dependency_order () const
 Returns the dependency order of this group.

int get_dirname_order () const
 Returns the dependency order of this group.

bool is_preferred_over (const PaletteGroup &other) const
 Returns true if this group should be preferred for adding textures over the other group, if both are available.

void increment_egg_count ()
 Increments by one the number of egg files that are known to reference this PaletteGroup.

int get_egg_count () const
 Returns the number of egg files that share this PaletteGroup.

PalettePageget_page (const TextureProperties &properties)
 Returns the page associated with the indicated properties.

TexturePlacementprepare (TextureImage *texture)
 Marks the indicated Texture as ready for placing somewhere within this group, and returns a placeholder TexturePlacement object.

void unplace (TexturePlacement *placement)
 Removes the texture from its position on a PaletteImage, if it has been so placed.

void place_all ()
 Once all the textures have been assigned to this group, try to place them all onto suitable PaletteImages.

void update_unknown_textures (const TxaFile &txa_file)
 Checks for new information on any textures within the group for which some of the saved information is incomplete.

void write_image_info (ostream &out, int indent_level=0) const
 Writes a list of the PaletteImages associated with this group, and all of their textures, to the indicated output stream.

void optimal_resize ()
 Attempts to resize each PalettteImage down to its smallest possible size.

void reset_images ()
 Throws away all of the current PaletteImages, so that new ones may be created (and the packing made more optimal).

void setup_shadow_images ()
 Ensures that each PaletteImage's _shadow_image has the correct filename and image types, based on what was supplied on the command line and in the .txa file.

void update_images (bool redo_all)
 Regenerates each PaletteImage on this group that needs it.

virtual void write_datagram (BamWriter *writer, Datagram &datagram)
 Fills the indicated datagram up with a binary representation of the current object, in preparation for writing to a Bam file.

virtual int complete_pointers (TypedWritable **p_list, BamReader *manager)
 Called after the object is otherwise completely read from a Bam file, this function's job is to store the pointers that were retrieved from the Bam file for each pointer object written.

virtual void finalize ()
 This method is called by the BamReader after all pointers everywhere in the world have been completely read in.

virtual TypeHandle get_type () const
virtual TypeHandle force_init_type (void)
int get_type_index () const
bool is_of_type (TypeHandle handle) const
bool is_exact_type (TypeHandle handle) const
void set_name (const string &name)
void clear_name ()
bool has_name () const
const string & get_name () const
void output (ostream &out) const

Static Public Member Functions

void register_with_read_factory ()
 Registers the current object as something that can be read from a Bam file.

TypeHandle get_class_type ()
void init_type ()

Static Public Attributes

TypedWritable *const Null

Protected Member Functions

void fillin (DatagramIterator &scan, BamReader *manager)
 Reads the binary data from the given datagram iterator, which was written by a previous call to write_datagram().


Static Protected Member Functions

TypedWritablemake_PaletteGroup (const FactoryParams &params)
 This method is called by the BamReader when an object of this type is encountered in a Bam file; it should allocate and return a new object with all the data read.


Protected Attributes

string _name

Private Types

typedef pset< TexturePlacement * > Placements
typedef pmap< TextureProperties,
PalettePage * > 
Pages

Private Attributes

string _dirname
int _egg_count
PaletteGroups _dependent
int _dependency_level
int _dependency_order
int _dirname_order
Placements _placements
Pages _pages
int _num_placements
int _num_pages
pvector< PalettePage * > _load_pages

Static Private Attributes

TypeHandle _type_handle

Friends

class PaletteGroups

Detailed Description

This is the highest level of grouping for TextureImages.

Textures are assigned to one or several PaletteGroups based on the information in the .txa file; each PaletteGroup is conceptually a collection of textures that are to be moved around (into texture memory, downloaded, etc.) in one big chunk. It is the set of all textures that may be displayed together at any given time.

Definition at line 63 of file paletteGroup.h.


Member Typedef Documentation

typedef pmap<TextureProperties, PalettePage *> PaletteGroup::Pages [private]
 

Definition at line 116 of file paletteGroup.h.

typedef pset<TexturePlacement *> PaletteGroup::Placements [private]
 

Definition at line 113 of file paletteGroup.h.


Constructor & Destructor Documentation

PaletteGroup::PaletteGroup  ) 
 

Definition at line 47 of file paletteGroup.cxx.


Member Function Documentation

void PaletteGroup::clear_depends  ) 
 

Eliminates all the dependency information for this group.

Definition at line 116 of file paletteGroup.cxx.

References _dependent.

int PaletteGroup::complete_pointers TypedWritable **  p_list,
BamReader manager
[virtual]
 

Called after the object is otherwise completely read from a Bam file, this function's job is to store the pointers that were retrieved from the Bam file for each pointer object written.

The return value is the number of pointers processed from the list.

Reimplemented from TypedWritable.

Definition at line 858 of file paletteGroup.cxx.

void PaletteGroup::fillin DatagramIterator scan,
BamReader manager
[protected]
 

Reads the binary data from the given datagram iterator, which was written by a previous call to write_datagram().

Reimplemented from TypedWritable.

Definition at line 954 of file paletteGroup.cxx.

void PaletteGroup::finalize  )  [virtual]
 

This method is called by the BamReader after all pointers everywhere in the world have been completely read in.

It's a hook at which the object can do whatever final setup it requires that depends on other pointers being valid.

Reimplemented from TypedWritable.

Definition at line 902 of file paletteGroup.cxx.

TypeHandle PaletteGroup::get_class_type void   )  [inline, static]
 

Reimplemented from Namable.

Definition at line 140 of file paletteGroup.h.

References _type_handle.

void PaletteGroup::get_complete_placements pvector< TexturePlacement * > &  placements  )  const
 

Adds the set of TexturePlacements associated with this group and all dependent groups to the indicated vector.

See get_placements().

Definition at line 202 of file paletteGroup.cxx.

int PaletteGroup::get_dependency_level  )  const
 

Returns the dependency level of this group.

This is a measure of how specific the group is; the lower the dependency level, the more specific the group.

Groups depend on other groups in a hierarchical relationship. In general, if group a depends on group b, then b->get_dependency_level() > a->get_dependency_level().

Thus, groups that lots of other groups depend on have a higher dependency level; groups that no one else depends on have a low dependency level. This is important when deciding which groups are best suited for assigning a texture to; in general, the texture should be assigned to the most specific suitable group (i.e. the one with the lowest dependency level).

Definition at line 367 of file paletteGroup.cxx.

References _pages, and nassertr.

int PaletteGroup::get_dependency_order  )  const
 

Returns the dependency order of this group.

This is similar in principle to the dependency level, but it represents the inverse concept: if group a depends on group b, then a->get_dependency_order() > b->get_dependency_order().

This is not exactly the same thing as n - get_dependency_level(). In particular, this can be used to sort the groups into an ordering such that all the groups that group a depends on appear before group a in the list.

Definition at line 400 of file paletteGroup.cxx.

References _placements, TexturePlacement::get_group(), TexturePlacement::get_page(), TexturePlacement::is_placed(), nassertv, and PalettePage::unplace().

const string & PaletteGroup::get_dirname  )  const
 

Returns the directory name associated with the palette group.

See set_dirname().

Definition at line 101 of file paletteGroup.cxx.

References _dependent, and PaletteGroups::insert().

Referenced by ImageFile::get_properties().

int PaletteGroup::get_dirname_order  )  const
 

Returns the dependency order of this group.

This is similar in principle to the dependency level, but it represents the inverse concept: if group a depends on group b, then a->get_dirname_order() > b->get_dirname_order().

This is not exactly the same thing as n - get_dependency_level(). In particular, this can be used to sort the groups into an ordering such that all the groups that group a depends on appear before group a in the list.

Definition at line 433 of file paletteGroup.cxx.

References _placements, and OR_working.

int PaletteGroup::get_egg_count  )  const
 

Returns the number of egg files that share this PaletteGroup.

Definition at line 496 of file paletteGroup.cxx.

References _placements, and OR_none.

const PaletteGroups & PaletteGroup::get_groups  )  const
 

Returns the set of groups this group depends on.

Definition at line 159 of file paletteGroup.cxx.

PalettePage * PaletteGroup::get_page const TextureProperties properties  ) 
 

Returns the page associated with the indicated properties.

If no page object has yet been created, creates one.

Definition at line 513 of file paletteGroup.cxx.

References TexturePlacement::get_omit_reason(), TexturePlacement::get_uv_area(), TexturePlacement::get_x_size(), TexturePlacement::get_y_size(), OR_coverage, and OR_size.

void PaletteGroup::get_placements pvector< TexturePlacement * > &  placements  )  const
 

Adds the set of TexturePlacements associated with this group to the indicated vector.

The vector is not cleared before this operation; if the user wants to retrieve the set of placements particular to this group only, it is the user's responsibility to clear the vector first.

Definition at line 182 of file paletteGroup.cxx.

References _dependency_level, _dependent, PaletteGroups::begin(), PaletteGroups::end(), PaletteGroups::iterator, and set_dependency_level().

virtual TypeHandle PaletteGroup::get_type void   )  const [inline, virtual]
 

Reimplemented from TypedWritable.

Definition at line 150 of file paletteGroup.h.

void PaletteGroup::group_with PaletteGroup *  other  ) 
 

Indicates a dependency of this group on some other group.

This means that the textures assigned to this group may be considered successfully assigned if they are actually placed in the other group. In practice, this means that the textures associated with the other palette group will always be resident at runtime when textures from this palette group are required.

Definition at line 146 of file paletteGroup.cxx.

References _dependent, PaletteGroups::begin(), PaletteGroups::end(), PaletteGroups::iterator, and PaletteGroups::make_complete().

bool PaletteGroup::has_dirname  )  const
 

Returns true if the directory name has been explicitly set for this group.

If it has not, get_dirname() returns an empty string.

Definition at line 86 of file paletteGroup.cxx.

References _dependency_level, _dependency_order, _dependent, _dirname_order, and PaletteGroups::clear().

Referenced by Palettizer::get_egg_file().

void PaletteGroup::increment_egg_count  ) 
 

Increments by one the number of egg files that are known to reference this PaletteGroup.

This is designed to aid the heuristics in texture placing; it's useful to know how many different egg files are sharing a particular PaletteGroup.

Definition at line 481 of file paletteGroup.cxx.

References _pages, and PalettePage::write_image_info().

void PaletteGroup::init_type void   )  [inline, static]
 

Reimplemented from Namable.

Definition at line 143 of file paletteGroup.h.

bool PaletteGroup::is_preferred_over const PaletteGroup &  other  )  const
 

Returns true if this group should be preferred for adding textures over the other group, if both are available.

In other words, this is a more specific group than the other one.

Definition at line 452 of file paletteGroup.cxx.

References _placements, TexturePlacement::determine_size(), TexturePlacement::get_texture(), TextureImage::got_txa_file(), TexturePlacement::is_size_known(), TxaFile::match_texture(), TextureImage::post_txa_file(), and TextureImage::pre_txa_file().

TypedWritable * PaletteGroup::make_PaletteGroup const FactoryParams params  )  [static, protected]
 

This method is called by the BamReader when an object of this type is encountered in a Bam file; it should allocate and return a new object with all the data read.

Definition at line 930 of file paletteGroup.cxx.

void PaletteGroup::optimal_resize  ) 
 

Attempts to resize each PalettteImage down to its smallest possible size.

Definition at line 718 of file paletteGroup.cxx.

void PaletteGroup::place_all  ) 
 

Once all the textures have been assigned to this group, try to place them all onto suitable PaletteImages.

Definition at line 591 of file paletteGroup.cxx.

References _pages.

TexturePlacement * PaletteGroup::prepare TextureImage texture  ) 
 

Marks the indicated Texture as ready for placing somewhere within this group, and returns a placeholder TexturePlacement object.

The texture is not placed immediately, but may be placed later when place_all() is called; at this time, the TexturePlacement fields will be filled in as appropriate.

Definition at line 546 of file paletteGroup.cxx.

void PaletteGroup::register_with_read_factory void   )  [static]
 

Registers the current object as something that can be read from a Bam file.

Definition at line 800 of file paletteGroup.cxx.

void PaletteGroup::reset_dependency_level  ) 
 

Unconditionally sets the dependency level and order of this group to zero, in preparation for a later call to set_dependency_level().

See set_dependency_level().

Definition at line 230 of file paletteGroup.cxx.

void PaletteGroup::reset_images  ) 
 

Throws away all of the current PaletteImages, so that new ones may be created (and the packing made more optimal).

Definition at line 739 of file paletteGroup.cxx.

References _num_pages, and _num_placements.

void PaletteGroup::set_dependency_level int  level  ) 
 

Sets the dependency level of this group to the indicated level, provided that level is not lower than the level that was set previously.

Also cascades to all dependent groups. See get_dependency_level().

This call recurses to correctly set the dependency level of all PaletteGroups in the hierarchy.

Definition at line 259 of file paletteGroup.cxx.

References _dependency_level.

Referenced by get_placements().

bool PaletteGroup::set_dependency_order  ) 
 

Updates the dependency order of this group.

This number is the inverse of the dependency level, and can be used to rank the groups in order so that all the groups that a given group depends on will appear first in the list. See get_dependency_order().

This function returns true if anything was changed, false otherwise.

Definition at line 293 of file paletteGroup.cxx.

References _dependency_order.

void PaletteGroup::set_dirname const string &  dirname  ) 
 

Sets the directory name associated with the palette group.

This is an optional feature that can be used to place the maps for the different palette groups into different install directories.

Definition at line 69 of file paletteGroup.cxx.

References _dirname.

Referenced by Palettizer::get_egg_file().

void PaletteGroup::setup_shadow_images  ) 
 

Ensures that each PaletteImage's _shadow_image has the correct filename and image types, based on what was supplied on the command line and in the .txa file.

Definition at line 762 of file paletteGroup.cxx.

void PaletteGroup::unplace TexturePlacement placement  ) 
 

Removes the texture from its position on a PaletteImage, if it has been so placed.

Definition at line 564 of file paletteGroup.cxx.

void PaletteGroup::update_images bool  redo_all  ) 
 

Regenerates each PaletteImage on this group that needs it.

Definition at line 781 of file paletteGroup.cxx.

void PaletteGroup::update_unknown_textures const TxaFile txa_file  ) 
 

Checks for new information on any textures within the group for which some of the saved information is incomplete.

This may be necessary before we can properly place all of the textures.

Definition at line 627 of file paletteGroup.cxx.

References _placements, and writer().

void PaletteGroup::write_datagram BamWriter writer,
Datagram datagram
[virtual]
 

Fills the indicated datagram up with a binary representation of the current object, in preparation for writing to a Bam file.

Reimplemented from TypedWritable.

Definition at line 818 of file paletteGroup.cxx.

void PaletteGroup::write_image_info ostream &  out,
int  indent_level = 0
const
 

Writes a list of the PaletteImages associated with this group, and all of their textures, to the indicated output stream.

Definition at line 661 of file paletteGroup.cxx.


Friends And Related Function Documentation

friend class PaletteGroups [friend]
 

Definition at line 157 of file paletteGroup.h.


Member Data Documentation

int PaletteGroup::_dependency_level [private]
 

Definition at line 109 of file paletteGroup.h.

Referenced by get_placements(), has_dirname(), and set_dependency_level().

int PaletteGroup::_dependency_order [private]
 

Definition at line 110 of file paletteGroup.h.

Referenced by has_dirname(), and set_dependency_order().

PaletteGroups PaletteGroup::_dependent [private]
 

Definition at line 108 of file paletteGroup.h.

Referenced by clear_depends(), get_dirname(), get_placements(), group_with(), has_dirname(), and PaletteGroups::output().

string PaletteGroup::_dirname [private]
 

Definition at line 106 of file paletteGroup.h.

Referenced by set_dirname().

int PaletteGroup::_dirname_order [private]
 

Definition at line 111 of file paletteGroup.h.

Referenced by has_dirname().

int PaletteGroup::_egg_count [private]
 

Definition at line 107 of file paletteGroup.h.

pvector<PalettePage *> PaletteGroup::_load_pages [private]
 

Definition at line 137 of file paletteGroup.h.

int PaletteGroup::_num_pages [private]
 

Definition at line 136 of file paletteGroup.h.

Referenced by reset_images().

int PaletteGroup::_num_placements [private]
 

Definition at line 135 of file paletteGroup.h.

Referenced by reset_images().

Pages PaletteGroup::_pages [private]
 

Definition at line 117 of file paletteGroup.h.

Referenced by get_dependency_level(), increment_egg_count(), and place_all().

Placements PaletteGroup::_placements [private]
 

Definition at line 114 of file paletteGroup.h.

Referenced by get_dependency_order(), get_dirname_order(), get_egg_count(), is_preferred_over(), and update_unknown_textures().

TypeHandle PaletteGroup::_type_handle [static, private]
 

Reimplemented from Namable.

Definition at line 37 of file paletteGroup.cxx.

Referenced by get_class_type().


The documentation for this class was generated from the following files:
Generated on Fri May 2 03:27:43 2003 for Panda-Tool by doxygen1.3