Panda3D
|
This represents a single egg file known to the palettizer. More...
#include "eggFile.h"
Public Member Functions | |
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 | 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 | 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. | |
void | clear_surprise () |
Removes the 'surprise' flag; this file has been successfully matched against a line in the .txa 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. | |
bool | 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. | |
const PaletteGroups & | get_complete_groups () const |
Returns the complete set of PaletteGroups that the egg file is assigned to. | |
PaletteGroup * | 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. | |
const PaletteGroups & | get_explicit_groups () const |
Returns the set of PaletteGroups that the egg file has been explicitly assigned to in the .txa file. | |
const Filename & | get_source_filename () const |
Returns the filename this egg file was read from. | |
void | get_textures (pset< TextureImage * > &result) const |
Fills up the indicated set with the set of textures referenced by this egg file. | |
virtual TypeHandle | get_type () const |
bool | had_data () const |
Returns true if the EggData for this EggFile has ever been loaded in this session. | |
bool | has_data () const |
Returns true if the EggData for this EggFile has been loaded, and not yet released. | |
bool | is_stale () const |
Returns true if the egg file needs to be updated, i.e. | |
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. | |
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. | |
void | pre_txa_file () |
Does some processing prior to scanning the .txa file. | |
bool | read_egg (bool noabs) |
Reads in the egg file from its _source_filename. | |
void | release_egg_data () |
Releases the memory that was loaded by a previous call to read_egg(). | |
void | remove_egg () |
Removes this egg file from all things that reference it, in preparation for removing it from the database. | |
void | scan_textures () |
Scans the egg file for texture references and updates the _textures list appropriately. | |
void | update_egg () |
Once all textures have been placed appropriately, updates the egg file with all the information to reference the new textures. | |
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. | |
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. | |
bool | write_egg () |
Writes out the egg file to its _dest_filename. | |
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. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
static void | register_with_read_factory () |
Registers the current object as something that can be read from a Bam file. | |
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 | |
static TypedWritable * | make_EggFile (const FactoryParams ¶ms) |
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. |
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.
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 TextureReference::apply_properties_to_source().
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 373 of file eggFile.cxx.
References PaletteGroups::begin(), PaletteGroups::clear(), PaletteGroups::empty(), PaletteGroups::end(), TextureReference::get_source(), TextureReference::get_texture(), SourceTextureImage::increment_egg_count(), PaletteGroups::insert(), PaletteGroups::make_complete(), and TextureImage::note_egg_file().
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 437 of file eggFile.cxx.
References PaletteGroups::begin(), PaletteGroups::count(), PaletteGroups::empty(), get_complete_groups(), TexturePlacement::get_group(), TextureImage::get_groups(), TextureImage::get_placement(), TextureReference::get_placement(), TextureReference::get_texture(), PaletteGroups::make_intersection(), and TextureReference::set_placement().
Referenced by Palettizer::read_stale_eggs().
void EggFile::clear_surprise | ( | ) |
Removes the 'surprise' flag; this file has been successfully matched against a line in the .txa file.
Definition at line 320 of file eggFile.cxx.
Referenced by TxaLine::match_egg().
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 836 of file eggFile.cxx.
References PaletteGroups::complete_pointers().
void EggFile::fillin | ( | DatagramIterator & | scan, |
BamReader * | manager | ||
) | [protected, virtual] |
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 885 of file eggFile.cxx.
References PaletteGroups::fillin(), FilenameUnifier::get_bam_filename(), DatagramIterator::get_bool(), DatagramIterator::get_string(), DatagramIterator::get_uint32(), BamReader::read_pointer(), and BamReader::read_pointers().
Referenced by make_EggFile().
bool 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.
Returns true if the egg file is valid, false otherwise.
Definition at line 63 of file eggFile.cxx.
References ExecutionEnvironment::get_cwd(), and Palettizer::get_default_group().
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 309 of file eggFile.cxx.
Referenced by choose_placements(), and TextureImage::note_egg_file().
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 296 of file eggFile.cxx.
Referenced by TextureImage::write_source_pathnames().
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 284 of file eggFile.cxx.
Referenced by TextureImage::write_source_pathnames().
const Filename & EggFile::get_source_filename | ( | ) | const |
Returns the filename this egg file was read from.
Definition at line 100 of file eggFile.cxx.
Referenced by Palettizer::read_stale_eggs().
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 226 of file eggFile.cxx.
Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().
bool EggFile::had_data | ( | ) | const |
Returns true if the EggData for this EggFile has ever been loaded in this session.
Definition at line 498 of file eggFile.cxx.
Referenced by Palettizer::read_stale_eggs(), and Palettizer::write_eggs().
bool EggFile::has_data | ( | ) | const |
Returns true if the EggData for this EggFile has been loaded, and not yet released.
Definition at line 487 of file eggFile.cxx.
Referenced by Palettizer::write_eggs().
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 357 of file eggFile.cxx.
Referenced by Palettizer::read_stale_eggs(), and write_description().
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 332 of file eggFile.cxx.
Referenced by Palettizer::report_pi().
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 867 of file eggFile.cxx.
References fillin().
Referenced by register_with_read_factory().
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 345 of file eggFile.cxx.
Referenced by TextureReference::mark_egg_stale().
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 252 of file eggFile.cxx.
References PaletteGroups::clear(), and PaletteGroups::make_union().
Referenced by TxaLine::match_egg().
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 274 of file eggFile.cxx.
Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().
void EggFile::pre_txa_file | ( | ) |
Does some processing prior to scanning the .txa file.
Definition at line 239 of file eggFile.cxx.
Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().
bool EggFile::read_egg | ( | bool | noabs | ) |
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.
This may also be called after a previous call to release_egg_data(), in order to re-read the same egg file.
Definition at line 549 of file eggFile.cxx.
References DSearchPath::append_directory(), EggTextureCollection::find_used_textures(), Filename::get_basename(), Filename::get_dirname(), FilenameUnifier::make_user_filename(), and EggTextureCollection::uniquify_trefs().
Referenced by Palettizer::read_stale_eggs(), and Palettizer::write_eggs().
void EggFile::register_with_read_factory | ( | ) | [static] |
Registers the current object as something that can be read from a Bam file.
Definition at line 786 of file eggFile.cxx.
References BamReader::get_factory(), and make_EggFile().
void EggFile::release_egg_data | ( | ) |
Releases the memory that was loaded by a previous call to read_egg().
Definition at line 625 of file eggFile.cxx.
References TextureReference::release_egg_data().
Referenced by Palettizer::read_stale_eggs(), and Palettizer::write_eggs().
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 527 of file eggFile.cxx.
References TextureReference::get_placement(), and TexturePlacement::remove_egg().
Referenced by Palettizer::read_stale_eggs(), and Palettizer::remove_egg_file().
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.
References EggTextureCollection::find_used_textures(), TextureReference::from_egg(), TextureReference::from_egg_quick(), TextureReference::has_uvs(), TextureReference::is_equivalent(), and EggTextureCollection::uniquify_trefs().
Referenced by Palettizer::process_all(), Palettizer::process_command_line_eggs(), and Palettizer::read_stale_eggs().
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 510 of file eggFile.cxx.
References TextureReference::update_egg().
Referenced by Palettizer::write_eggs().
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 799 of file eggFile.cxx.
References Datagram::add_bool(), Datagram::add_string(), Datagram::add_uint32(), FilenameUnifier::make_bam_filename(), PaletteGroups::write_datagram(), and BamWriter::write_pointer().
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 668 of file eggFile.cxx.
References PaletteGroups::empty(), and is_stale().
Referenced by Palettizer::report_pi().
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 644 of file eggFile.cxx.
References Filename::make_dir(), and FilenameUnifier::make_user_filename().
Referenced by Palettizer::write_eggs().
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 691 of file eggFile.cxx.
Referenced by Palettizer::report_pi().