Panda3D

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
Palettizer Class Reference

This is the main engine behind egg-palettize. More...

`#include "palettizer.h"`

Inheritance diagram for Palettizer:

## Public Types
enum | RemapUV { RU_never , RU_group , RU_poly , RU_invalid }

## Public Member Functions
void | add_command_line_egg (EggFile *egg_file)
| Adds the indicated EggFile to the list of eggs that are considered to have been read on the command line.
void | all_params_set ()
| Called after all command line parameters have been set up, this is a hook to do whatever initialization is necessary.
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 (BamReader *manager)
| Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.
void | generate_images (bool redo_all)
| Actually generates the appropriate palette and unplaced texture images into the map directories.
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.
EggFile * | get_egg_file (const std::string &name)
| Returns the EggFile with the given name.
bool | get_noabs () const
| Returns the current setting of the noabs flag.
PaletteGroup * | get_palette_group (const std::string &name)
| Returns the PaletteGroup with the given name.
TextureImage * | get_texture (const std::string &name)
| Returns the TextureImage with the given name.
virtual TypeHandle | get_type () const
bool | is_valid () const
| Returns true if the palette information file was read correctly, or false if there was some error and the palettization can't continue.
void | optimal_resize ()
| Attempts to resize each PalettteImage down to its smallest possible size.
void | process_all (bool force_texture_read, const Filename &state_filename)
| Reprocesses all textures known.
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.
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.
void | read_txa_file (std::istream &txa_file, const std::string &txa_filename)
| Reads in the .txa file and keeps it ready for matching textures and egg files.
bool | remove_egg_file (const std::string &name)
| Removes the named egg file from the database, if it exists.
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 | reset_images ()
| Throws away all of the current PaletteImages, so that new ones may be created (and the packing made more optimal).
void | set_noabs (bool noabs)
| Changes the current setting of the noabs flag.
PaletteGroup * | test_palette_group (const std::string &name) const
| Returns the PaletteGroup 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.
bool | write_eggs ()
| Adjusts the egg files to reference the newly generated textures, and writes them out.
Public Member Functions inherited from TypedWritable
| TypedWritable (const TypedWritable &copy)
virtual ReferenceCount * | as_reference_count ()
| Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type.
vector_uchar | encode_to_bam_stream () const
| Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object.
bool | encode_to_bam_stream (vector_uchar &data, BamWriter *writer=nullptr) const
| Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string.
virtual TypeHandle | force_init_type ()
UpdateSeq | get_bam_modified () const
| Returns the current bam_modified counter.
void | mark_bam_modified ()
| Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams.
void | operator= (const TypedWritable &copy)
virtual bool | require_fully_complete () const
| Some objects require all of their nested pointers to have been completed before the objects themselves can be completed.
virtual void | update_bam_nested (BamWriter *manager)
| Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates.
Public Member Functions inherited from TypedObject
| TypedObject (const TypedObject &copy)=default
TypedObject * | as_typed_object ()
| Returns the object, upcast (if necessary) to a TypedObject pointer.
const TypedObject * | as_typed_object () const
| Returns the object, upcast (if necessary) to a TypedObject pointer.
int | get_best_parent_from_Set (const std::set< int > &) const
int | get_type_index () const
| Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.
bool | is_exact_type (TypeHandle handle) const
| Returns true if the current object is the indicated type exactly.
bool | is_of_type (TypeHandle handle) const
| Returns true if the current object is or derives from the indicated type.
TypedObject & | operator= (const TypedObject &copy)=default
Public Member Functions inherited from MemoryBase
void | operator delete (void *, void *)
void | operator delete (void *ptr)
void | operator delete[] (void *, void *)
void | operator delete[] (void *ptr)
void * | operator new (size_t size)
void * | operator new (size_t size, void *ptr)
void * | operator new[] (size_t size)
void * | operator new[] (size_t size, void *ptr)

## 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.
static RemapUV | string_remap (const std::string &str)
| Returns the RemapUV code corresponding to the indicated string, or RU_invalid if the string is invalid.
Static Public Member Functions inherited from TypedWritable
static bool | decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr)
| Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes.
static TypeHandle | get_class_type ()
static void | init_type ()
Static Public Member Functions inherited from TypedObject
static TypeHandle | get_class_type ()
static void | init_type ()
| This function is declared non-inline to work around a compiler bug in g++ 2.96.

## Public Attributes
bool | _aggressively_clean_mapdir
PNMFileType * | _alpha_type
LColord | _background
PNMFileType * | _color_type
double | _coverage_threshold
EggRenderMode::AlphaMode | _cutout_mode
double | _cutout_ratio
std::string | _default_groupdir
std::string | _default_groupname
bool | _force_power_2
std::string | _generated_image_pattern
bool | _is_valid
std::string | _map_dirname
int | _margin
bool | _noabs
bool | _omit_everything
bool | _omit_solitary
int | _pal_x_size
int | _pal_y_size
Filename | _rel_dirname
RemapUV | _remap_char_uv
RemapUV | _remap_uv
double | _round_fuzz
double | _round_unit
bool | _round_uvs
PNMFileType * | _shadow_alpha_type
PNMFileType * | _shadow_color_type
Filename | _shadow_dirname
TxaFile | _txa_file
Public Attributes inherited from TypedObject
| get_type

## Static Public Attributes
static int | _min_pi_version = 8
static int | _pi_version = 20
static int | _read_pi_version = 0
Static Public Attributes inherited from TypedWritable
static TypedWritable *const | Null = nullptr

## Friends
class | TxaLine

## Detailed Description

This is the main engine behind egg-palettize.

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 39 of file palettizer.h.

## Member Enumeration Documentation

## ◆ RemapUV

enum Palettizer::RemapUV

Definition at line 78 of file palettizer.h.

## Constructor & Destructor Documentation

## ◆ Palettizer()

Palettizer::Palettizer | ( |  | ) |

Definition at line 107 of file palettizer.cxx.

## Member Function Documentation

## ◆ add_command_line_egg()

void Palettizer::add_command_line_egg | ( | EggFile * | egg_file | ) |

Adds the indicated EggFile to the list of eggs that are considered to have been read on the command line.

These will be processed by process_command_line_eggs().

Definition at line 783 of file palettizer.cxx.

## ◆ all_params_set()

void Palettizer::all_params_set | ( |  | ) |

Called after all command line parameters have been set up, this is a hook to do whatever initialization is necessary.

Definition at line 405 of file palettizer.cxx.

References PaletteGroup::setup_shadow_images().

## ◆ complete_pointers()

int Palettizer::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 983 of file palettizer.cxx.

References TypedWritable::complete_pointers(), and downcase().

## ◆ finalize()

void Palettizer::finalize | ( | BamReader * | manager | ) |
| virtual

Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.

Reimplemented from TypedWritable.

Definition at line 1044 of file palettizer.cxx.

References downcase(), and TextureImage::is_used().

## ◆ generate_images()

void Palettizer::generate_images | ( | bool | redo_all | ) |

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 632 of file palettizer.cxx.

References TextureImage::copy_unplaced(), and PaletteGroup::update_images().

## ◆ get_class_type()

static TypeHandle Palettizer::get_class_type | ( |  | ) |
| inline static

Definition at line 166 of file palettizer.h.

## ◆ get_default_group()

PaletteGroup * Palettizer::get_default_group | ( |  | ) |

Returns the default group to which an egg file should be assigned if it is not mentioned in the .txa file.

Definition at line 823 of file palettizer.cxx.

References get_palette_group(), PaletteGroup::has_dirname(), and PaletteGroup::set_dirname().

## ◆ get_egg_file()

EggFile * Palettizer::get_egg_file | ( | const std::string & | name | ) |

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 748 of file palettizer.cxx.

## ◆ get_noabs()

bool Palettizer::get_noabs | ( |  | ) | const

Returns the current setting of the noabs flag.

See set_noabs().

Definition at line 142 of file palettizer.cxx.

## ◆ get_palette_group()

PaletteGroup * Palettizer::get_palette_group | ( | const std::string & | name | ) |

Returns the PaletteGroup with the given name.

If there is no PaletteGroup with the indicated name, creates one.

Definition at line 792 of file palettizer.cxx.

Referenced by get_default_group().

## ◆ get_texture()

TextureImage * Palettizer::get_texture | ( | const std::string & | name | ) |

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 837 of file palettizer.cxx.

References downcase().

## ◆ get_type()

virtual TypeHandle Palettizer::get_type | ( |  | ) | const
| inline virtual

Reimplemented from TypedWritable.

Definition at line 174 of file palettizer.h.

## ◆ init_type()

static void Palettizer::init_type | ( |  | ) |
| inline static

Definition at line 169 of file palettizer.h.

## ◆ is_valid()

bool Palettizer::is_valid | ( |  | ) | const

Returns true if the palette information file was read correctly, or false if there was some error and the palettization can't continue.

Definition at line 166 of file palettizer.cxx.

## ◆ optimal_resize()

void Palettizer::optimal_resize | ( |  | ) |

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

Definition at line 605 of file palettizer.cxx.

References PaletteGroup::optimal_resize().

## ◆ process_all()

void Palettizer::process_all | ( | bool | force_texture_read,
|  | const Filename & | state_filename )

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 513 of file palettizer.cxx.

References TextureImage::assign_groups(), TextureImage::clear_source_basic_properties(), TextureImage::determine_placement_size(), EggFile::get_textures(), TextureImage::is_newer_than(), TextureImage::mark_texture_named(), PaletteGroup::place_all(), EggFile::post_txa_file(), TextureImage::post_txa_file(), EggFile::pre_txa_file(), TextureImage::pre_txa_file(), TextureImage::read_source_image(), TextureImage::release_source_image(), EggFile::scan_textures(), and PaletteGroup::update_unknown_textures().

## ◆ process_command_line_eggs()

void Palettizer::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.

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 422 of file palettizer.cxx.

References TextureImage::assign_groups(), TextureImage::determine_placement_size(), EggFile::get_textures(), TextureImage::is_newer_than(), TextureImage::mark_texture_named(), PaletteGroup::place_all(), EggFile::post_txa_file(), TextureImage::post_txa_file(), EggFile::pre_txa_file(), TextureImage::pre_txa_file(), TextureImage::read_header(), TextureImage::read_source_image(), EggFile::scan_textures(), and PaletteGroup::update_unknown_textures().

## ◆ read_stale_eggs()

bool Palettizer::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.

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 655 of file palettizer.cxx.

References EggFile::choose_placements(), Filename::exists(), EggFile::get_source_filename(), EggFile::had_data(), EggFile::is_stale(), FilenameUnifier::make_user_filename(), EggFile::read_egg(), EggFile::release_egg_data(), EggFile::remove_egg(), EggFile::scan_textures(), and Filename::unlink().

## ◆ read_txa_file()

void Palettizer::read_txa_file | ( | std::istream & | txa_file,
|  | const std::string & | txa_filename )

Reads in the .txa file and keeps it ready for matching textures and egg files.

Definition at line 352 of file palettizer.cxx.

References PaletteGroup::clear_depends(), PaletteGroup::reset_dependency_level(), PaletteGroup::set_dependency_level(), PaletteGroup::set_dependency_order(), and PaletteGroup::set_dirname().

## ◆ register_with_read_factory()

void Palettizer::register_with_read_factory | ( |  | ) |
| static

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

Definition at line 912 of file palettizer.cxx.

References BamReader::get_factory().

Referenced by init_palettizer().

## ◆ remove_egg_file()

bool Palettizer::remove_egg_file | ( | const std::string & | name | ) |

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 765 of file palettizer.cxx.

References EggFile::remove_egg().

## ◆ report_pi()

void Palettizer::report_pi | ( |  | ) | const

Output a verbose description of all the palettization information to standard output, for the user's perusal.

Definition at line 175 of file palettizer.cxx.

References PaletteGroup::get_groups(), EggFile::is_surprise(), TextureImage::is_surprise(), TextureImage::is_used(), FilenameUnifier::make_user_filename(), EggFile::write_description(), PaletteGroup::write_image_info(), TextureImage::write_scale_info(), TextureImage::write_source_pathnames(), and EggFile::write_texture_refs().

## ◆ report_statistics()

void Palettizer::report_statistics | ( |  | ) | const

Output a report of the palettization effectiveness, texture memory utilization, and so on.

Definition at line 296 of file palettizer.cxx.

References PaletteGroup::get_complete_placements(), PaletteGroup::get_groups(), PaletteGroup::get_placements(), PaletteGroups::make_complete(), and PaletteGroups::size().

## ◆ reset_images()

void Palettizer::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 618 of file palettizer.cxx.

References PaletteGroup::reset_images().

## ◆ set_noabs()

void Palettizer::set_noabs | ( | bool | noabs | ) |

Changes the current setting of the noabs flag.

If this flag is true, then it is an error to process an egg file that contains absolute pathname references. This flag is intended to help detect egg files that are incorrectly built within a model tree (which should use entirely relative pathnames).

This flag must be set before any egg files are processed.

Definition at line 157 of file palettizer.cxx.

## ◆ string_remap()

Palettizer::RemapUV Palettizer::string_remap | ( | const std::string & | str | ) |
| static

Returns the RemapUV code corresponding to the indicated string, or RU_invalid if the string is invalid.

Definition at line 875 of file palettizer.cxx.

## ◆ test_palette_group()

PaletteGroup * Palettizer::test_palette_group | ( | const std::string & | name | ) | const

Returns the PaletteGroup with the given name.

If there is no PaletteGroup with the indicated name, returns NULL.

Definition at line 809 of file palettizer.cxx.

## ◆ write_datagram()

void Palettizer::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 922 of file palettizer.cxx.

References Datagram::add_bool(), Datagram::add_float64(), Datagram::add_int32(), Datagram::add_string(), Datagram::add_uint8(), FilenameUnifier::make_bam_filename(), TypedWritable::write_datagram(), and BamWriter::write_pointer().

## ◆ write_eggs()

bool Palettizer::write_eggs | ( |  | ) |

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 713 of file palettizer.cxx.

References EggFile::had_data(), EggFile::has_data(), EggFile::read_egg(), EggFile::release_egg_data(), EggFile::update_egg(), and EggFile::write_egg().

## Friends And Related Symbol Documentation

## ◆ TxaLine

friend class TxaLine
| friend

Definition at line 181 of file palettizer.h.

## Member Data Documentation

## ◆ _aggressively_clean_mapdir

bool Palettizer::_aggressively_clean_mapdir

Definition at line 110 of file palettizer.h.

## ◆ _alpha_type

PNMFileType* Palettizer::_alpha_type

Definition at line 116 of file palettizer.h.

## ◆ _background

LColord Palettizer::_background

Definition at line 104 of file palettizer.h.

## ◆ _color_type

PNMFileType* Palettizer::_color_type

Definition at line 115 of file palettizer.h.

## ◆ _coverage_threshold

double Palettizer::_coverage_threshold

Definition at line 108 of file palettizer.h.

## ◆ _cutout_mode

EggRenderMode::AlphaMode Palettizer::_cutout_mode

Definition at line 119 of file palettizer.h.

## ◆ _cutout_ratio

double Palettizer::_cutout_ratio

Definition at line 120 of file palettizer.h.

## ◆ _default_groupdir

std::string Palettizer::_default_groupdir

Definition at line 93 of file palettizer.h.

## ◆ _default_groupname

std::string Palettizer::_default_groupname

Definition at line 92 of file palettizer.h.

## ◆ _force_power_2

bool Palettizer::_force_power_2

Definition at line 109 of file palettizer.h.

## ◆ _generated_image_pattern

std::string Palettizer::_generated_image_pattern

Definition at line 99 of file palettizer.h.

## ◆ _is_valid

bool Palettizer::_is_valid

Definition at line 87 of file palettizer.h.

## ◆ _map_dirname

std::string Palettizer::_map_dirname

Definition at line 100 of file palettizer.h.

## ◆ _margin

int Palettizer::_margin

Definition at line 105 of file palettizer.h.

## ◆ _min_pi_version

int Palettizer::_min_pi_version = 8
| static

Definition at line 75 of file palettizer.h.

## ◆ _noabs

bool Palettizer::_noabs

Definition at line 94 of file palettizer.h.

## ◆ _omit_everything

bool Palettizer::_omit_everything

Definition at line 107 of file palettizer.h.

## ◆ _omit_solitary

bool Palettizer::_omit_solitary

Definition at line 106 of file palettizer.h.

## ◆ _pal_x_size

int Palettizer::_pal_x_size

Definition at line 103 of file palettizer.h.

## ◆ _pal_y_size

int Palettizer::_pal_y_size

Definition at line 103 of file palettizer.h.

## ◆ _pi_version

int Palettizer::_pi_version = 20
| static

Definition at line 74 of file palettizer.h.

## ◆ _read_pi_version

int Palettizer::_read_pi_version = 0
| static

Definition at line 76 of file palettizer.h.

## ◆ _rel_dirname

Filename Palettizer::_rel_dirname

Definition at line 102 of file palettizer.h.

## ◆ _remap_char_uv

RemapUV Palettizer::_remap_char_uv

Definition at line 114 of file palettizer.h.

## ◆ _remap_uv

RemapUV Palettizer::_remap_uv

Definition at line 114 of file palettizer.h.

## ◆ _round_fuzz

double Palettizer::_round_fuzz

Definition at line 113 of file palettizer.h.

## ◆ _round_unit

double Palettizer::_round_unit

Definition at line 112 of file palettizer.h.

## ◆ _round_uvs

bool Palettizer::_round_uvs

Definition at line 111 of file palettizer.h.

## ◆ _shadow_alpha_type

PNMFileType* Palettizer::_shadow_alpha_type

Definition at line 118 of file palettizer.h.

## ◆ _shadow_color_type

PNMFileType* Palettizer::_shadow_color_type

Definition at line 117 of file palettizer.h.

## ◆ _shadow_dirname

Filename Palettizer::_shadow_dirname

Definition at line 101 of file palettizer.h.

## ◆ _txa_file

TxaFile Palettizer::_txa_file

Definition at line 91 of file palettizer.h.

The documentation for this class was generated from the following files:

- pandatool/src/palettizer/palettizer.h
- pandatool/src/palettizer/palettizer.cxx