#include <palettizer.h>
Inheritance diagram for Palettizer:
Public Types | |
enum | RemapUV { RU_never, RU_group, RU_poly, RU_invalid } |
Public Member Functions | |
Palettizer () | |
void | report_pi () const |
Output a verbose description of all the palettization information to standard output, for the user's perusal. | |
void | report_statistics () const |
Output a report of the palettization effectiveness, texture memory utilization, and so on. | |
void | read_txa_file (const Filename &txa_filename) |
Reads in the .txa file and keeps it ready for matching textures and egg files. | |
void | all_params_set () |
Called after all command line parameters have been set up, this is a hook to do whatever initialization is necessary. | |
void | process_command_line_eggs (bool force_texture_read, const Filename &state_filename) |
Processes all the textures named in the _command_line_eggs, placing them on the appropriate palettes or whatever needs to be done with them. | |
void | process_all (bool force_texture_read, const Filename &state_filename) |
Reprocesses all textures known. | |
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 | generate_images (bool redo_all) |
Actually generates the appropriate palette and unplaced texture images into the map directories. | |
bool | read_stale_eggs (bool redo_all) |
Reads in any egg file that is known to be stale, even if it was not listed on the command line, so that it may be updated and written out when write_eggs() is called. | |
bool | write_eggs () |
Adjusts the egg files to reference the newly generated textures, and writes them out. | |
EggFile * | get_egg_file (const string &name) |
Returns the EggFile with the given name. | |
bool | remove_egg_file (const string &name) |
Removes the named egg file from the database, if it exists. | |
PaletteGroup * | get_palette_group (const string &name) |
Returns the PaletteGroup with the given name. | |
PaletteGroup * | test_palette_group (const string &name) const |
Returns the PaletteGroup with the given name. | |
PaletteGroup * | get_default_group () |
Returns the default group to which an egg file should be assigned if it is not mentioned in the .txa file. | |
TextureImage * | get_texture (const string &name) |
Returns the TextureImage with the given name. | |
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 |
Static Public Member Functions | |
RemapUV | string_remap (const string &str) |
Returns the RemapUV code corresponding to the indicated string, or RU_invalid if the string is invalid. | |
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 () |
Public Attributes | |
TxaFile | _txa_file |
string | _default_groupname |
string | _default_groupdir |
string | _map_dirname |
Filename | _shadow_dirname |
Filename | _rel_dirname |
int | _pal_x_size |
int | _pal_y_size |
int | _margin |
bool | _omit_solitary |
double | _coverage_threshold |
bool | _force_power_2 |
bool | _aggressively_clean_mapdir |
bool | _round_uvs |
double | _round_unit |
double | _round_fuzz |
RemapUV | _remap_uv |
RemapUV | _remap_char_uv |
PNMFileType * | _color_type |
PNMFileType * | _alpha_type |
PNMFileType * | _shadow_color_type |
PNMFileType * | _shadow_alpha_type |
Static Public Attributes | |
int | _pi_version = 10 |
int | _min_pi_version = 8 |
int | _read_pi_version = 0 |
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 | |
TypedWritable * | make_Palettizer (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. | |
Private Types | |
typedef pvector< TexturePlacement * > | Placements |
typedef pmap< string, EggFile * > | EggFiles |
typedef pvector< EggFile * > | CommandLineEggs |
typedef pset< TextureImage * > | CommandLineTextures |
typedef pmap< string, PaletteGroup * > | Groups |
typedef pmap< string, TextureImage * > | Textures |
Private Member Functions | |
void | compute_statistics (ostream &out, int indent_level, const Placements &placements) const |
Determines how much memory, etc. | |
Static Private Member Functions | |
const char * | yesno (bool flag) |
A silly function to return "yes" or "no" based on a bool flag for nicely formatted output. | |
Private Attributes | |
EggFiles | _egg_files |
CommandLineEggs | _command_line_eggs |
CommandLineTextures | _command_line_textures |
Groups | _groups |
Textures | _textures |
int | _num_egg_files |
int | _num_groups |
int | _num_textures |
Static Private Attributes | |
TypeHandle | _type_handle |
Friends | |
class | EggPalettize |
class | TxaLine |
It contains all of the program parameters, from the command line or saved from a previous session, and serves as the driving force in the actual palettizing process.
Definition at line 57 of file palettizer.h.
|
Definition at line 134 of file palettizer.h. |
|
Definition at line 137 of file palettizer.h. |
|
Definition at line 131 of file palettizer.h. |
|
Definition at line 140 of file palettizer.h. |
|
Definition at line 127 of file palettizer.h. |
|
Definition at line 143 of file palettizer.h. |
|
Definition at line 90 of file palettizer.h. Referenced by get_palette_group(). |
|
Definition at line 105 of file palettizer.cxx. References NULL. |
|
Called after all command line parameters have been set up, this is a hook to do whatever initialization is necessary.
Definition at line 383 of file palettizer.cxx. References _command_line_eggs, and _txa_file. |
|
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 1067 of file palettizer.cxx. |
|
Determines how much memory, etc. is required by the indicated set of texture placements, and reports this to the indicated output stream. Definition at line 961 of file palettizer.cxx. References _egg_files. |
|
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 1154 of file palettizer.cxx. Referenced by register_with_read_factory(). |
|
Actually generates the appropriate palette and unplaced texture images into the map directories. If redo_all is true, this forces a regeneration of each image file. Definition at line 657 of file palettizer.cxx. References _egg_files. |
|
Reimplemented from TypedWritable. Definition at line 166 of file palettizer.h. |
|
Returns the default group to which an egg file should be assigned if it is not mentioned in the .txa file.
Definition at line 867 of file palettizer.cxx. |
|
Returns the EggFile with the given name. If there is no EggFile with the indicated name, creates one. This is the key name used to sort the egg files, which is typically the basename of the filename. Definition at line 772 of file palettizer.cxx. References _default_groupdir, _default_groupname, get_palette_group(), PaletteGroup::has_dirname(), and PaletteGroup::set_dirname(). |
|
Returns the PaletteGroup with the given name. If there is no PaletteGroup with the indicated name, creates one. Definition at line 822 of file palettizer.cxx. References RemapUV, RU_group, RU_invalid, RU_never, and RU_poly. Referenced by get_egg_file(). |
|
Returns the TextureImage with the given name. If there is no TextureImage with the indicated name, creates one. This is the key name used to sort the textures, which is typically the basename of the primary filename. Definition at line 892 of file palettizer.cxx. References _egg_files, and writer(). |
|
Reimplemented from TypedWritable. Definition at line 174 of file palettizer.h. References pal. |
|
Reimplemented from TypedWritable. Definition at line 169 of file palettizer.h. References _type_handle. |
|
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 1131 of file palettizer.cxx. |
|
Attempts to resize each PalettteImage down to its smallest possible size.
Definition at line 613 of file palettizer.cxx. |
|
Reprocesses all textures known. If force_texture_read is true, it forces each texture image file to be read (and thus legitimately checked for grayscaleness etc.) before placing. Definition at line 514 of file palettizer.cxx. |
|
Processes all the textures named in the _command_line_eggs, placing them on the appropriate palettes or whatever needs to be done with them. If force_texture_read is true, it forces each texture image file to be read (and thus legitimately checked for grayscaleness etc.) before placing. Definition at line 413 of file palettizer.cxx. References TextureImage::read_source_image(). |
|
Reads in any egg file that is known to be stale, even if it was not listed on the command line, so that it may be updated and written out when write_eggs() is called. If redo_all is true, this even reads egg files that were not flagged as stale. Returns true if successful, or false if there was some error. Definition at line 694 of file palettizer.cxx. References _egg_files, and Namable::set_name(). |
|
Reads in the .txa file and keeps it ready for matching textures and egg files.
Definition at line 323 of file palettizer.cxx. References nout. |
|
Registers the current object as something that can be read from a Bam file.
Definition at line 985 of file palettizer.cxx. References fillin(), params, and parse_params(). |
|
Removes the named egg file from the database, if it exists. Returns true if the egg file was found, false if it was not. Definition at line 797 of file palettizer.cxx. References _textures. |
|
Output a verbose description of all the palettization information to standard output, for the user's perusal.
Definition at line 139 of file palettizer.cxx. References _coverage_threshold, _map_dirname, _margin, _pal_x_size, _pal_y_size, _round_fuzz, and _round_unit. |
|
Output a report of the palettization effectiveness, texture memory utilization, and so on.
Definition at line 261 of file palettizer.cxx. |
|
Throws away all of the current PaletteImages, so that new ones may be created (and the packing made more optimal).
Definition at line 634 of file palettizer.cxx. References _egg_files. |
|
Returns the RemapUV code corresponding to the indicated string, or RU_invalid if the string is invalid.
Definition at line 933 of file palettizer.cxx. References _alpha_type, _color_type, _num_egg_files, _shadow_alpha_type, _shadow_color_type, TypedWritable::complete_pointers(), DCAST_INTO_R, and NULL. Referenced by TxaFile::parse_shadowtype_line(). |
|
Returns the PaletteGroup with the given name. If there is no PaletteGroup with the indicated name, returns NULL. Definition at line 847 of file palettizer.cxx. References TextureMemoryCounter::add_placement(), and TextureMemoryCounter::report(). |
|
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 1003 of file palettizer.cxx. References _aggressively_clean_mapdir, _coverage_threshold, _force_power_2, _map_dirname, _margin, _omit_solitary, _pal_x_size, _pal_y_size, _read_pi_version, _rel_dirname, _remap_char_uv, _remap_uv, _round_fuzz, _round_unit, _round_uvs, _shadow_dirname, TypedWritable::fillin(), FilenameUnifier::get_bam_filename(), DatagramIterator::get_bool(), DatagramIterator::get_float64(), DatagramIterator::get_int32(), DatagramIterator::get_string(), BamReader::read_pointer(), BamReader::read_pointers(), and FilenameUnifier::set_rel_dirname(). |
|
Adjusts the egg files to reference the newly generated textures, and writes them out. Returns true if successful, or false if there was some error. Definition at line 740 of file palettizer.cxx. |
|
A silly function to return "yes" or "no" based on a bool flag for nicely formatted output.
Definition at line 916 of file palettizer.cxx. References writer(). |
|
Definition at line 181 of file palettizer.h. |
|
Definition at line 182 of file palettizer.h. |
|
Definition at line 116 of file palettizer.h. Referenced by write_datagram(). |
|
Definition at line 122 of file palettizer.h. Referenced by string_remap(). |
|
Definition at line 121 of file palettizer.h. Referenced by string_remap(). |
|
Definition at line 135 of file palettizer.h. Referenced by all_params_set(). |
|
Definition at line 138 of file palettizer.h. |
|
Definition at line 114 of file palettizer.h. Referenced by report_pi(), and write_datagram(). |
|
Definition at line 103 of file palettizer.h. Referenced by get_egg_file(). |
|
Definition at line 102 of file palettizer.h. Referenced by get_egg_file(). |
|
Definition at line 132 of file palettizer.h. Referenced by compute_statistics(), generate_images(), get_texture(), read_stale_eggs(), and reset_images(). |
|
Definition at line 115 of file palettizer.h. Referenced by write_datagram(). |
|
Definition at line 141 of file palettizer.h. |
|
Definition at line 108 of file palettizer.h. Referenced by ImageFile::get_properties(), report_pi(), and write_datagram(). |
|
Definition at line 112 of file palettizer.h. Referenced by report_pi(), and write_datagram(). |
|
Definition at line 52 of file palettizer.cxx. |
|
Definition at line 161 of file palettizer.h. Referenced by string_remap(). |
|
Definition at line 162 of file palettizer.h. |
|
Definition at line 163 of file palettizer.h. |
|
Definition at line 113 of file palettizer.h. Referenced by write_datagram(). |
|
Definition at line 111 of file palettizer.h. Referenced by report_pi(), and write_datagram(). |
|
Definition at line 111 of file palettizer.h. Referenced by report_pi(), and write_datagram(). |
|
Definition at line 47 of file palettizer.cxx. |
|
Definition at line 55 of file palettizer.cxx. Referenced by EggFile::remove_backstage(), TextureProperties::union_filter(), ImageFile::unlink(), and write_datagram(). |
|
Definition at line 110 of file palettizer.h. Referenced by write_datagram(). |
|
Definition at line 120 of file palettizer.h. Referenced by TxaFile::parse_shadowtype_line(), and write_datagram(). |
|
Definition at line 120 of file palettizer.h. Referenced by TxaFile::parse_shadowtype_line(), and write_datagram(). |
|
Definition at line 119 of file palettizer.h. Referenced by TexturePlacement::determine_size(), report_pi(), and write_datagram(). |
|
Definition at line 118 of file palettizer.h. Referenced by TexturePlacement::determine_size(), report_pi(), and write_datagram(). |
|
Definition at line 117 of file palettizer.h. Referenced by write_datagram(). |
|
Definition at line 124 of file palettizer.h. Referenced by TxaFile::parse_coverage_line(), and string_remap(). |
|
Definition at line 123 of file palettizer.h. Referenced by TxaFile::parse_coverage_line(), and string_remap(). |
|
Definition at line 109 of file palettizer.h. Referenced by write_datagram(). |
|
Definition at line 144 of file palettizer.h. Referenced by remove_egg_file(). |
|
Definition at line 101 of file palettizer.h. Referenced by all_params_set(). |
|
Reimplemented from TypedWritable. Definition at line 57 of file palettizer.cxx. Referenced by init_type(). |