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

EggFile Class Reference

This represents a single egg file known to the palettizer. More...

#include <eggFile.h>

Inheritance diagram for EggFile:

TypedWritable Namable TypedObject List of all members.

Public Member Functions

 EggFile ()
void from_command_line (EggData *data, const Filename &source_filename, const Filename &dest_filename, const string &egg_comment)
 Accepts the information about the egg file as supplied from the command line.

void scan_textures ()
 Scans the egg file for texture references and updates the _textures list appropriately.

void get_textures (pset< TextureImage * > &result) const
 Fills up the indicated set with the set of textures referenced by this egg file.

void pre_txa_file ()
 Does some processing prior to scanning the .txa file.

void match_txa_groups (const PaletteGroups &groups)
 Adds the indicated set of groups, read from the .txa file, to the set of groups to which the egg file is assigned.

void post_txa_file ()
 Once the egg file has been matched against all of the matching lines the .txa file, do whatever adjustment is necessary.

const PaletteGroupsget_explicit_groups () const
 Returns the set of PaletteGroups that the egg file has been explicitly assigned to in the .txa file.

PaletteGroupget_default_group () const
 Returns the PaletteGroup that was specified as the default group on the command line at the time the egg file last appeared on the command line.

const PaletteGroupsget_complete_groups () const
 Returns the complete set of PaletteGroups that the egg file is assigned to.

void clear_surprise ()
 Removes the 'surprise' flag; this file has been successfully matched against a line in the .txa file.

bool is_surprise () const
 Returns true if this particular egg file is a 'surprise', i.e.

void mark_stale ()
 Marks this particular egg file as stale, meaning that something has changed, such as the location of a texture within its palette, which causes the egg file to need to be regenerated.

bool is_stale () const
 Returns true if the egg file needs to be updated, i.e.

void build_cross_links ()
 Calls TextureImage::note_egg_file() and SourceTextureImage::increment_egg_count() for each texture the egg file references, and PaletteGroup::increment_egg_count() for each palette group it wants.

void apply_properties_to_source ()
 Calls apply_properties_to_source() for each texture reference, updating all the referenced source textures with the complete set of property information from this egg file.

void choose_placements ()
 Once all the textures have been assigned to groups (but before they may actually be placed), chooses a suitable TexturePlacement for each texture that appears in the egg file.

bool has_data () const
 Returns true if the EggData for this EggFile has ever been loaded.

void update_egg ()
 Once all textures have been placed appropriately, updates the egg file with all the information to reference the new textures.

void remove_egg ()
 Removes this egg file from all things that reference it, in preparation for removing it from the database.

bool read_egg ()
 Reads in the egg file from its _source_filename.

bool write_egg ()
 Writes out the egg file to its _dest_filename.

void write_description (ostream &out, int indent_level=0) const
 Writes a one-line description of the egg file and its group assignments to the indicated output stream.

void write_texture_refs (ostream &out, int indent_level=0) const
 Writes the list of texture references to the indicated output stream, one per line.

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 TypeHandle get_type () const
virtual void finalize ()
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_EggFile (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 pvector< TextureReference * > Textures

Private Member Functions

void remove_backstage (EggGroupNode *node)
 Recursively walks the egg hierarchy and removes any "backstage" nodes found from the scene graph completely.


Private Attributes

EggData_data
Filename _current_directory
Filename _source_filename
Filename _dest_filename
string _egg_comment
Textures _textures
bool _first_txa_match
PaletteGroups _explicitly_assigned_groups
PaletteGroup_default_group
PaletteGroups _complete_groups
bool _is_surprise
bool _is_stale
int _num_textures

Static Private Attributes

TypeHandle _type_handle

Detailed Description

This represents a single egg file known to the palettizer.

It may reference a number of textures, and may also be assigned to a number of groups. All of its textures will try to assign themselves to one of its groups.

Definition at line 54 of file eggFile.h.


Member Typedef Documentation

typedef pvector<TextureReference *> EggFile::Textures [private]
 

Definition at line 103 of file eggFile.h.


Constructor & Destructor Documentation

EggFile::EggFile  ) 
 

Definition at line 52 of file eggFile.cxx.

References _first_txa_match.


Member Function Documentation

void EggFile::apply_properties_to_source  ) 
 

Calls apply_properties_to_source() for each texture reference, updating all the referenced source textures with the complete set of property information from this egg file.

Definition at line 416 of file eggFile.cxx.

References _textures.

void EggFile::build_cross_links  ) 
 

Calls TextureImage::note_egg_file() and SourceTextureImage::increment_egg_count() for each texture the egg file references, and PaletteGroup::increment_egg_count() for each palette group it wants.

This sets up some of the back references to support determining an ideal texture assignment.

Definition at line 367 of file eggFile.cxx.

References get_complete_groups(), TextureImage::get_groups(), Namable::get_name(), nout, and PaletteGroups::write().

void EggFile::choose_placements  ) 
 

Once all the textures have been assigned to groups (but before they may actually be placed), chooses a suitable TexturePlacement for each texture that appears in the egg file.

This will be necessary to do at some point before writing out the egg file anyway, and doing it before the textures are placed allows us to decide what the necessary UV range is for each to-be-placed texture.

Definition at line 447 of file eggFile.cxx.

References _current_directory, _data, _egg_comment, _source_filename, DSearchPath::append_directory(), EggData::begin(), Filename::empty(), Filename::exists(), EggData::insert(), EggData::load_externals(), nassertr, nout, NULL, EggData::read(), remove_backstage(), and EggData::resolve_filenames().

void EggFile::clear_surprise  ) 
 

Removes the 'surprise' flag; this file has been successfully matched against a line in the .txa file.

Definition at line 289 of file eggFile.cxx.

References _complete_groups, _default_group, _explicitly_assigned_groups, PaletteGroups::clear(), PaletteGroups::insert(), and PaletteGroups::make_complete().

int EggFile::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 792 of file eggFile.cxx.

void EggFile::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 852 of file eggFile.cxx.

Referenced by write_texture_refs().

void EggFile::from_command_line EggData data,
const Filename source_filename,
const Filename dest_filename,
const string &  egg_comment
 

Accepts the information about the egg file as supplied from the command line.

Definition at line 71 of file eggFile.cxx.

References _current_directory, _default_group, _dest_filename, _egg_comment, _source_filename, and pal.

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

Reimplemented from Namable.

Definition at line 131 of file eggFile.h.

const PaletteGroups & EggFile::get_complete_groups  )  const
 

Returns the complete set of PaletteGroups that the egg file is assigned to.

This is the set of all the groups it is explicitly assigned to, plus all the groups that these groups depend on.

Definition at line 274 of file eggFile.cxx.

Referenced by build_cross_links(), and is_stale().

PaletteGroup * EggFile::get_default_group  )  const
 

Returns the PaletteGroup that was specified as the default group on the command line at the time the egg file last appeared on the command line.

Definition at line 255 of file eggFile.cxx.

References _is_stale.

const PaletteGroups & EggFile::get_explicit_groups  )  const
 

Returns the set of PaletteGroups that the egg file has been explicitly assigned to in the .txa file.

Definition at line 238 of file eggFile.cxx.

References _is_surprise.

void EggFile::get_textures pset< TextureImage * > &  result  )  const
 

Fills up the indicated set with the set of textures referenced by this egg file.

It is the user's responsibility to ensure the set is empty before making this call; otherwise, the new textures will be appended to the existing set.

Definition at line 163 of file eggFile.cxx.

References _explicitly_assigned_groups, _first_txa_match, PaletteGroups::clear(), and PaletteGroups::make_union().

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

Reimplemented from TypedWritable.

Definition at line 141 of file eggFile.h.

bool EggFile::has_data  )  const
 

Returns true if the EggData for this EggFile has ever been loaded.

Definition at line 501 of file eggFile.cxx.

References _data, and _is_stale.

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

Reimplemented from Namable.

Definition at line 134 of file eggFile.h.

References _type_handle.

bool EggFile::is_stale  )  const
 

Returns true if the egg file needs to be updated, i.e.

some palettizations have changed affecting it, or false otherwise.

Definition at line 342 of file eggFile.cxx.

References _textures, PaletteGroups::count(), get_complete_groups(), TexturePlacement::get_group(), TextureImage::get_groups(), TextureReference::get_placement(), TextureReference::get_texture(), PaletteGroups::make_intersection(), and NULL.

Referenced by update_egg().

bool EggFile::is_surprise  )  const
 

Returns true if this particular egg file is a 'surprise', i.e.

it wasn't matched by a line in the .txa file that didn't include the keyword 'cont'.

Definition at line 306 of file eggFile.cxx.

TypedWritable * EggFile::make_EggFile 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 829 of file eggFile.cxx.

void EggFile::mark_stale  ) 
 

Marks this particular egg file as stale, meaning that something has changed, such as the location of a texture within its palette, which causes the egg file to need to be regenerated.

Definition at line 325 of file eggFile.cxx.

References _textures, and TextureReference::apply_properties_to_source().

void EggFile::match_txa_groups const PaletteGroups groups  ) 
 

Adds the indicated set of groups, read from the .txa file, to the set of groups to which the egg file is assigned.

Definition at line 197 of file eggFile.cxx.

References _explicitly_assigned_groups.

void EggFile::post_txa_file  ) 
 

Once the egg file has been matched against all of the matching lines the .txa file, do whatever adjustment is necessary.

Definition at line 224 of file eggFile.cxx.

References _complete_groups.

void EggFile::pre_txa_file  ) 
 

Does some processing prior to scanning the .txa file.

Definition at line 179 of file eggFile.cxx.

bool EggFile::read_egg  ) 
 

Reads in the egg file from its _source_filename.

It is only valid to call this if it has not already been read in, e.g. from the command line. Returns true if successful, false if there is an error.

Definition at line 561 of file eggFile.cxx.

References EggGroupNode::iterator.

void EggFile::register_with_read_factory void   )  [static]
 

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

Definition at line 730 of file eggFile.cxx.

void EggFile::remove_backstage EggGroupNode node  )  [private]
 

Recursively walks the egg hierarchy and removes any "backstage" nodes found from the scene graph completely.

These aren't part of the egg scene anyway, and removing them early helps reduce confusion.

Definition at line 694 of file eggFile.cxx.

References _current_directory, _dest_filename, _egg_comment, Palettizer::_read_pi_version, _source_filename, and DatagramIterator::get_string().

Referenced by choose_placements().

void EggFile::remove_egg  ) 
 

Removes this egg file from all things that reference it, in preparation for removing it from the database.

Definition at line 537 of file eggFile.cxx.

References _textures, and TextureReference::write().

void EggFile::scan_textures  ) 
 

Scans the egg file for texture references and updates the _textures list appropriately.

This assumes the egg file was supplied on the command line and thus the _data member is available.

Definition at line 114 of file eggFile.cxx.

void EggFile::update_egg  ) 
 

Once all textures have been placed appropriately, updates the egg file with all the information to reference the new textures.

Definition at line 518 of file eggFile.cxx.

References _default_group, _explicitly_assigned_groups, PaletteGroups::empty(), Namable::get_name(), indent(), is_stale(), and NULL.

void EggFile::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 748 of file eggFile.cxx.

void EggFile::write_description ostream &  out,
int  indent_level = 0
const
 

Writes a one-line description of the egg file and its group assignments to the indicated output stream.

Definition at line 642 of file eggFile.cxx.

References _default_group, _explicitly_assigned_groups, _num_textures, _textures, PaletteGroups::complete_pointers(), TypedWritable::complete_pointers(), DCAST_INTO_R, and NULL.

bool EggFile::write_egg  ) 
 

Writes out the egg file to its _dest_filename.

Returns true if successful, false if there is an error.

Definition at line 614 of file eggFile.cxx.

References _textures, and writer().

void EggFile::write_texture_refs ostream &  out,
int  indent_level = 0
const
 

Writes the list of texture references to the indicated output stream, one per line.

Definition at line 669 of file eggFile.cxx.

References fillin(), params, and parse_params().


Member Data Documentation

PaletteGroups EggFile::_complete_groups [private]
 

Definition at line 109 of file eggFile.h.

Referenced by clear_surprise(), and post_txa_file().

Filename EggFile::_current_directory [private]
 

Definition at line 98 of file eggFile.h.

Referenced by choose_placements(), from_command_line(), and remove_backstage().

EggData* EggFile::_data [private]
 

Definition at line 97 of file eggFile.h.

Referenced by choose_placements(), and has_data().

PaletteGroup* EggFile::_default_group [private]
 

Definition at line 108 of file eggFile.h.

Referenced by clear_surprise(), from_command_line(), update_egg(), and write_description().

Filename EggFile::_dest_filename [private]
 

Definition at line 100 of file eggFile.h.

Referenced by from_command_line(), and remove_backstage().

string EggFile::_egg_comment [private]
 

Definition at line 101 of file eggFile.h.

Referenced by choose_placements(), from_command_line(), and remove_backstage().

PaletteGroups EggFile::_explicitly_assigned_groups [private]
 

Definition at line 107 of file eggFile.h.

Referenced by clear_surprise(), get_textures(), match_txa_groups(), update_egg(), and write_description().

bool EggFile::_first_txa_match [private]
 

Definition at line 106 of file eggFile.h.

Referenced by EggFile(), and get_textures().

bool EggFile::_is_stale [private]
 

Definition at line 111 of file eggFile.h.

Referenced by get_default_group(), and has_data().

bool EggFile::_is_surprise [private]
 

Definition at line 110 of file eggFile.h.

Referenced by get_explicit_groups().

int EggFile::_num_textures [private]
 

Definition at line 128 of file eggFile.h.

Referenced by write_description().

Filename EggFile::_source_filename [private]
 

Definition at line 99 of file eggFile.h.

Referenced by choose_placements(), from_command_line(), and remove_backstage().

Textures EggFile::_textures [private]
 

Definition at line 104 of file eggFile.h.

Referenced by apply_properties_to_source(), is_stale(), mark_stale(), remove_egg(), write_description(), and write_egg().

TypeHandle EggFile::_type_handle [static, private]
 

Reimplemented from Namable.

Definition at line 42 of file eggFile.cxx.

Referenced by init_type().


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