Panda3D
|
This represents a single source texture that is referenced by one or more egg files. More...
#include "textureImage.h"
Public Member Functions | |
void | assign_groups () |
Assigns the texture to all of the PaletteGroups the various egg files that use it need. | |
void | clear_source_basic_properties () |
Calls clear_basic_properties() on each source texture image used by this texture, to reset the properties in preparation for re-applying them from the set of all known egg files. | |
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. | |
void | copy_unplaced (bool redo_all) |
Copies the texture to whichever destination directories are appropriate for the groups in which it has been unplaced. | |
void | determine_placement_size () |
Calls determine_size() on each TexturePlacement for the texture, to ensure that each TexturePlacement is still requesting the best possible size for the texture. | |
void | force_replace () |
Removes the texture from any PaletteImages it is assigned to, but does not remove it from the groups. | |
EggRenderMode::AlphaMode | get_alpha_mode () const |
Returns the alpha mode that should be used to render objects with this texture, as specified by the user or as determined from examining the texture's alpha channel. | |
double | get_coverage_threshold () const |
Returns the appropriate coverage threshold for this texture. | |
const PaletteGroups & | get_groups () const |
Once assign_groups() has been called, this returns the actual set of groups the TextureImage has been assigned to. | |
int | get_margin () const |
Returns the appropriate margin for this texture. | |
bool | get_omit () const |
Returns true if the user specifically requested to omit this texture via the "omit" keyword in the .txa file, or false otherwise. | |
TexturePlacement * | get_placement (PaletteGroup *group) const |
Gets the TexturePlacement object which represents the assignment of this texture to the indicated group. | |
SourceTextureImage * | get_preferred_source () |
Determines the preferred source image for examining size and reading pixels, etc. | |
SourceTextureImage * | get_source (const Filename &filename, const Filename &alpha_filename, int alpha_file_channel) |
Returns the SourceTextureImage corresponding to the given filename(s). | |
EggTexture::WrapMode | get_txa_wrap_u () const |
Returns the wrap mode specified in the u direction in the txa file, or WM_unspecified. | |
EggTexture::WrapMode | get_txa_wrap_v () const |
Returns the wrap mode specified in the v direction in the txa file, or WM_unspecified. | |
virtual TypeHandle | get_type () const |
bool | got_txa_file () const |
Returns true if this TextureImage has been looked up in the .txa file this session, false otherwise. | |
bool | is_newer_than (const Filename &reference_filename) |
Returns true if the source image is newer than the indicated file, false otherwise. | |
bool | is_surprise () const |
Returns true if this particular texture is a 'surprise', i.e. | |
bool | is_texture_named () const |
Returns true if this particular texture has been named by the user for procession this session, for instance by listing an egg file on the command line that references it. | |
bool | is_used () const |
Returns true if this particular texture has been placed somewhere, anywhere, or false if it is not used. | |
void | mark_eggs_stale () |
Marks all the egg files that reference this texture stale. | |
void | mark_texture_named () |
Indicates that this particular texture has been named by the user for processing this session, normally by listing an egg file on the command line that references it. | |
void | note_egg_file (EggFile *egg_file) |
Records that a particular egg file references this texture. | |
void | post_txa_file () |
Once the .txa file has been read and the TextureImage matched against it, considers applying the requested size change. | |
void | pre_txa_file () |
Updates any internal state prior to reading the .txa file. | |
void | read_header () |
Causes the header part of the image to be reread, usually to confirm that its image properties (size, number of channels, etc.) haven't changed. | |
const PNMImage & | read_source_image () |
Reads in the original image, if it has not already been read, and returns it. | |
void | release_source_image () |
Frees the memory that was allocated by a previous call to read_source_image(). | |
void | set_source_image (const PNMImage &image) |
Accepts the indicated source image as if it had been read from disk. | |
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_scale_info (ostream &out, int indent_level=0) |
Writes the information about the texture's size and placement. | |
void | write_source_pathnames (ostream &out, int indent_level=0) const |
Writes the list of source pathnames that might contribute to this texture 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_TextureImage (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. | |
Friends | |
class | TxaLine |
This represents a single source texture that is referenced by one or more egg files.
It may be assigned to multiple PaletteGroups, and thus placed on multiple PaletteImages (up to one per PaletteGroup).
Since a TextureImage may be referenced by multiple egg files that are each assigned to a different set of groups, it tries to maximize sharing between egg files and minimize the number of different PaletteGroups it is assigned to.
Definition at line 51 of file textureImage.h.
void TextureImage::assign_groups | ( | ) |
Assigns the texture to all of the PaletteGroups the various egg files that use it need.
Attempts to choose the minimum set of PaletteGroups that satisfies all of the egg files.
Definition at line 83 of file textureImage.cxx.
References PaletteGroups::begin(), PaletteGroups::empty(), PaletteGroups::end(), PaletteGroups::insert(), PaletteGroup::is_preferred_over(), PaletteGroups::make_intersection(), PaletteGroups::make_union(), and PaletteGroups::remove_null().
Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().
Calls clear_basic_properties() on each source texture image used by this texture, to reset the properties in preparation for re-applying them from the set of all known egg files.
Definition at line 703 of file textureImage.cxx.
References ImageFile::clear_basic_properties().
Referenced by Palettizer::process_all().
int TextureImage::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 ImageFile.
Definition at line 1428 of file textureImage.cxx.
References PaletteGroups::complete_pointers(), ImageFile::get_alpha_file_channel(), ImageFile::get_alpha_filename(), and ImageFile::get_filename().
void TextureImage::copy_unplaced | ( | bool | redo_all | ) |
Copies the texture to whichever destination directories are appropriate for the groups in which it has been unplaced.
Also removes the old filenames for previous sessions where it was unplaced, but is no longer.
If redo_all is true, this recopies the texture whether it needed to or not.
Definition at line 724 of file textureImage.cxx.
References ImageFile::get_filename(), TexturePlacement::get_omit_reason(), FilenameUnifier::make_canonical(), and TexturePlacement::set_dest().
Referenced by Palettizer::generate_images().
Calls determine_size() on each TexturePlacement for the texture, to ensure that each TexturePlacement is still requesting the best possible size for the texture.
Definition at line 460 of file textureImage.cxx.
References TexturePlacement::determine_size().
Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().
void TextureImage::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 ImageFile.
Definition at line 1496 of file textureImage.cxx.
References PaletteGroups::fillin(), DatagramIterator::get_bool(), DatagramIterator::get_float64(), DatagramIterator::get_int16(), DatagramIterator::get_string(), DatagramIterator::get_uint32(), DatagramIterator::get_uint8(), and BamReader::read_pointers().
Referenced by make_TextureImage().
void TextureImage::force_replace | ( | ) |
Removes the texture from any PaletteImages it is assigned to, but does not remove it from the groups.
It will be re-placed within each group when PaletteGroup::place_all() is called.
Definition at line 236 of file textureImage.cxx.
Referenced by post_txa_file().
EggRenderMode::AlphaMode TextureImage::get_alpha_mode | ( | ) | const |
Returns the alpha mode that should be used to render objects with this texture, as specified by the user or as determined from examining the texture's alpha channel.
Definition at line 547 of file textureImage.cxx.
Referenced by TextureReference::update_egg().
double TextureImage::get_coverage_threshold | ( | ) | const |
Returns the appropriate coverage threshold for this texture.
This is either the Palettizer::_coverage_threshold parameter, given globally via -r, or a particular value for this texture as supplied by the "coverage" keyword in the .txa file.
Definition at line 491 of file textureImage.cxx.
Referenced by TexturePlacement::determine_size().
const PaletteGroups & TextureImage::get_groups | ( | ) | const |
Once assign_groups() has been called, this returns the actual set of groups the TextureImage has been assigned to.
Definition at line 204 of file textureImage.cxx.
Referenced by EggFile::choose_placements().
int TextureImage::get_margin | ( | ) | const |
Returns the appropriate margin for this texture.
This is either the Palettizer::_margin parameter, or a particular value for this texture as supplied by the "margin" keyword in the .txa file.
Definition at line 504 of file textureImage.cxx.
bool TextureImage::get_omit | ( | ) | const |
Returns true if the user specifically requested to omit this texture via the "omit" keyword in the .txa file, or false otherwise.
Definition at line 476 of file textureImage.cxx.
Referenced by TexturePlacement::determine_size().
TexturePlacement * TextureImage::get_placement | ( | PaletteGroup * | group | ) | const |
Gets the TexturePlacement object which represents the assignment of this texture to the indicated group.
If the texture has not been assigned to the indicated group, returns NULL.
Definition at line 217 of file textureImage.cxx.
Referenced by EggFile::choose_placements().
Determines the preferred source image for examining size and reading pixels, etc.
This is the largest and most recent of all the available source images.
Definition at line 614 of file textureImage.cxx.
References ImageFile::exists(), SourceTextureImage::get_egg_count(), ImageFile::get_filename(), SourceTextureImage::get_size(), ImageFile::get_x_size(), and ImageFile::get_y_size().
Referenced by DestTextureImage::copy_if_stale(), is_newer_than(), TxaLine::match_texture(), post_txa_file(), pre_txa_file(), PaletteGroup::prepare(), read_header(), read_source_image(), PaletteImage::update_image(), and write_scale_info().
SourceTextureImage * TextureImage::get_source | ( | const Filename & | filename, |
const Filename & | alpha_filename, | ||
int | alpha_file_channel | ||
) |
Returns the SourceTextureImage corresponding to the given filename(s).
If the given filename has never been used as a SourceTexture for this particular texture, creates a new SourceTextureImage and returns that.
Definition at line 584 of file textureImage.cxx.
Referenced by TextureReference::from_egg(), and PaletteGroup::prepare().
EggTexture::WrapMode TextureImage::get_txa_wrap_u | ( | ) | const |
Returns the wrap mode specified in the u direction in the txa file, or WM_unspecified.
Definition at line 558 of file textureImage.cxx.
Referenced by TexturePlacement::determine_size(), and TextureReference::update_egg().
EggTexture::WrapMode TextureImage::get_txa_wrap_v | ( | ) | const |
Returns the wrap mode specified in the v direction in the txa file, or WM_unspecified.
Definition at line 569 of file textureImage.cxx.
Referenced by TexturePlacement::determine_size(), and TextureReference::update_egg().
bool TextureImage::got_txa_file | ( | ) | const |
Returns true if this TextureImage has been looked up in the .txa file this session, false otherwise.
Definition at line 447 of file textureImage.cxx.
Referenced by PaletteGroup::update_unknown_textures().
bool TextureImage::is_newer_than | ( | const Filename & | reference_filename | ) |
Returns true if the source image is newer than the indicated file, false otherwise.
If the image has already been read, this always returns false.
Definition at line 859 of file textureImage.cxx.
References ImageFile::get_filename(), and get_preferred_source().
Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().
bool TextureImage::is_surprise | ( | ) | const |
Returns true if this particular texture 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 516 of file textureImage.cxx.
Referenced by Palettizer::report_pi().
bool TextureImage::is_texture_named | ( | ) | const |
Returns true if this particular texture has been named by the user for procession this session, for instance by listing an egg file on the command line that references it.
Definition at line 282 of file textureImage.cxx.
Referenced by PaletteImage::update_image().
bool TextureImage::is_used | ( | ) | const |
Returns true if this particular texture has been placed somewhere, anywhere, or false if it is not used.
Definition at line 534 of file textureImage.cxx.
Referenced by Palettizer::finalize(), and Palettizer::report_pi().
TypedWritable * TextureImage::make_TextureImage | ( | 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 1478 of file textureImage.cxx.
References fillin().
Referenced by register_with_read_factory().
void TextureImage::mark_eggs_stale | ( | ) |
Marks all the egg files that reference this texture stale.
Should be called only when the texture properties change in some catastrophic way that will require every egg file referencing it to be regenerated, even if it is not palettized.
Definition at line 253 of file textureImage.cxx.
Referenced by post_txa_file().
void TextureImage::mark_texture_named | ( | ) |
Indicates that this particular texture has been named by the user for processing this session, normally by listing an egg file on the command line that references it.
Definition at line 269 of file textureImage.cxx.
Referenced by Palettizer::process_all(), and Palettizer::process_command_line_eggs().
void TextureImage::note_egg_file | ( | EggFile * | egg_file | ) |
Records that a particular egg file references this texture.
This is essential to know when deciding how to assign the TextureImage to the various PaletteGroups.
Definition at line 69 of file textureImage.cxx.
References PaletteGroups::empty(), and EggFile::get_complete_groups().
Referenced by EggFile::build_cross_links().
void TextureImage::post_txa_file | ( | ) |
Once the .txa file has been read and the TextureImage matched against it, considers applying the requested size change.
Updates the TextureImage's size with the size the texture ought to be, if this can be determined.
Definition at line 321 of file textureImage.cxx.
References TextureProperties::egg_properties_match(), force_replace(), TextureProperties::fully_define(), TextureProperties::get_num_channels(), ImageFile::get_num_channels(), get_preferred_source(), SourceTextureImage::get_size(), ImageFile::get_x_size(), ImageFile::get_y_size(), TextureProperties::has_num_channels(), mark_eggs_stale(), TexturePlacement::mark_unfilled(), and TextureProperties::set_num_channels().
Referenced by Palettizer::process_all(), Palettizer::process_command_line_eggs(), and PaletteGroup::update_unknown_textures().
void TextureImage::pre_txa_file | ( | ) |
Updates any internal state prior to reading the .txa file.
Definition at line 293 of file textureImage.cxx.
References get_preferred_source(), ImageFile::get_properties(), and TextureRequest::pre_txa_file().
Referenced by Palettizer::process_all(), Palettizer::process_command_line_eggs(), and PaletteGroup::update_unknown_textures().
void TextureImage::read_header | ( | ) |
Causes the header part of the image to be reread, usually to confirm that its image properties (size, number of channels, etc.) haven't changed.
Definition at line 842 of file textureImage.cxx.
References get_preferred_source(), and SourceTextureImage::read_header().
Referenced by Palettizer::process_command_line_eggs().
const PNMImage & TextureImage::read_source_image | ( | ) |
Reads in the original image, if it has not already been read, and returns it.
Definition at line 788 of file textureImage.cxx.
References get_preferred_source(), and ImageFile::read().
Referenced by DestTextureImage::copy(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), Palettizer::process_all(), and Palettizer::process_command_line_eggs().
void TextureImage::register_with_read_factory | ( | ) | [static] |
Registers the current object as something that can be read from a Bam file.
Definition at line 1356 of file textureImage.cxx.
References BamReader::get_factory(), and make_TextureImage().
void TextureImage::release_source_image | ( | ) |
Frees the memory that was allocated by a previous call to read_source_image().
The next time read_source_image() is called, it will have to read the disk again.
Definition at line 811 of file textureImage.cxx.
References PNMImage::clear().
Referenced by DestTextureImage::copy(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), and Palettizer::process_all().
void TextureImage::set_source_image | ( | const PNMImage & | image | ) |
Accepts the indicated source image as if it had been read from disk.
This image is copied into the structure, and will be returned by future calls to read_source_image().
Definition at line 827 of file textureImage.cxx.
void TextureImage::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 ImageFile.
Definition at line 1369 of file textureImage.cxx.
References Datagram::add_bool(), Datagram::add_float64(), Datagram::add_int16(), Datagram::add_string(), Datagram::add_uint32(), Datagram::add_uint8(), PaletteGroups::write_datagram(), and BamWriter::write_pointer().
void TextureImage::write_scale_info | ( | ostream & | out, |
int | indent_level = 0 |
||
) |
Writes the information about the texture's size and placement.
Definition at line 955 of file textureImage.cxx.
References TexturePlacement::get_dest(), ImageFile::get_filename(), TexturePlacement::get_image(), ImageFile::get_num_channels(), TexturePlacement::get_omit_reason(), get_preferred_source(), ImageFile::get_x_size(), ImageFile::get_y_size(), ImageFile::is_size_known(), and FilenameUnifier::make_user_filename().
Referenced by Palettizer::report_pi().
void TextureImage::write_source_pathnames | ( | ostream & | out, |
int | indent_level = 0 |
||
) | const |
Writes the list of source pathnames that might contribute to this texture to the indicated output stream, one per line.
Definition at line 879 of file textureImage.cxx.
References PaletteGroups::empty(), EggFile::get_default_group(), SourceTextureImage::get_egg_count(), EggFile::get_explicit_groups(), TextureProperties::get_num_channels(), ImageFile::get_properties(), ImageFile::get_x_size(), ImageFile::get_y_size(), TextureProperties::has_num_channels(), ImageFile::is_size_known(), and ImageFile::output_filename().
Referenced by Palettizer::report_pi().