This corresponds to a particular assignment of a TextureImage with a PaletteGroup, and specifically describes which PaletteImage (if any), and where on the PaletteImage, the TextureImage has been assigned to. More...
#include "texturePlacement.h"
Public Types | |
typedef pvector< TextureImage * > | TextureSwaps |
Public Member Functions | |
TexturePlacement (TextureImage *texture, PaletteGroup *group) | |
void | add_egg (TextureReference *reference) |
Records the fact that a particular egg file is using this particular TexturePlacement. More... | |
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. More... | |
void | compute_tex_matrix (LMatrix3d &transform) |
Stores in the indicated matrix the appropriate texture matrix transform for the new placement of the texture. More... | |
bool | determine_size () |
Attempts to determine the appropriate size of the texture for the given placement. More... | |
void | fill_image (PNMImage &image) |
Fills in the rectangle of the palette image represented by the texture placement with the image pixels. More... | |
void | fill_swapped_image (PNMImage &image, int index) |
Fills in the rectangle of the swapped palette image represented by the texture placement with the image pixels. More... | |
void | flag_error_image (PNMImage &image) |
Sets the rectangle of the palette image represented by the texture placement to red, to represent a missing texture. More... | |
void | force_replace () |
Removes the texture from its particular PaletteImage, but does not remove it from the PaletteGroup. More... | |
DestTextureImage * | get_dest () const |
Returns the DestTextureImage that corresponds to this texture as it was copied to the install directory. More... | |
PaletteGroup * | get_group () const |
Returns the group that this placement represents. More... | |
PaletteImage * | get_image () const |
Returns the particular PaletteImage on which the texture has been placed. More... | |
const std::string & | get_name () const |
Returns the name of the texture that this placement represents. More... | |
OmitReason | get_omit_reason () const |
Returns the reason the texture has been omitted from a palette image, or OR_none if it has not. More... | |
PalettePage * | get_page () const |
Returns the particular PalettePage on which the texture has been placed. More... | |
double | get_placed_uv_area () const |
Returns the total area of the rectangle occupied by the UV minmax box, as it has been placed. More... | |
int | get_placed_x () const |
Returns the X pixel at which the texture has been placed within its PaletteImage. More... | |
int | get_placed_x_size () const |
Returns the size in the X dimension, in pixels, of the texture image as it has been placed within the palette. More... | |
int | get_placed_y () const |
Returns the Y pixel at which the texture has been placed within its PaletteImage. More... | |
int | get_placed_y_size () const |
Returns the size in the Y dimension, in pixels, of the texture image as it has been placed within the palette. More... | |
const TextureProperties & | get_properties () const |
Returns the grouping properties of the image. More... | |
TextureImage * | get_texture () const |
Returns the texture that this placement represents. More... | |
virtual TypeHandle | get_type () const |
double | get_uv_area () const |
Returns the total area of the rectangle occupied by the UV minmax box, in UV coordinates. More... | |
int | get_x_size () const |
Returns the size in the X dimension, in pixels, of the texture image as it must appear in the palette. More... | |
int | get_y_size () const |
Returns the size in the Y dimension, in pixels, of the texture image as it must appear in the palette. More... | |
bool | intersects (int x, int y, int x_size, int y_size) |
Returns true if the particular position this texture has been assigned to overlaps the rectangle whose top left corner is at x, y and whose size is given by x_size, y_size, or false otherwise. More... | |
bool | is_filled () const |
Returns true if the texture has been filled (i.e. More... | |
bool | is_placed () const |
Returns true if the texture has been placed on a palette image, false otherwise. More... | |
bool | is_size_known () const |
Returns true if the texture's size is known, false otherwise. More... | |
void | mark_eggs_stale () |
Marks all the egg files that reference this placement stale. More... | |
void | mark_unfilled () |
Marks the texture as unfilled, so that it will need to be copied into the palette image again. More... | |
void | not_solitary () |
Indicates that the texture, formerly indicated as solitary, is now no longer. More... | |
void | omit_solitary () |
Sets the omit reason (returned by get_omit()) to OR_solitary, indicating that the palettized version of the texture should not be used because it is the only texture on a PaletteImage. More... | |
void | place_at (PaletteImage *image, int x, int y) |
Assigns the texture to a particular position within the indicated PaletteImage. More... | |
void | remove_egg (TextureReference *reference) |
Notes that a particular egg file is no longer using this particular TexturePlacement. More... | |
void | set_dest (DestTextureImage *dest) |
Sets the DestTextureImage that corresponds to this texture as it was copied to the install directory. More... | |
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. More... | |
void | write_placed (std::ostream &out, int indent_level=0) |
Writes the placement position information on a line by itself. More... | |
Public Member Functions inherited from TypedWritable | |
TypedWritable (const TypedWritable ©) | |
virtual ReferenceCount * | as_reference_count () |
Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. More... | |
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. More... | |
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. More... | |
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. More... | |
virtual TypeHandle | force_init_type () |
UpdateSeq | get_bam_modified () const |
Returns the current bam_modified counter. More... | |
void | mark_bam_modified () |
Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More... | |
void | operator= (const TypedWritable ©) |
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. More... | |
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. More... | |
Public Member Functions inherited from TypedObject | |
TypedObject (const TypedObject ©)=default | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_typed_object () const |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
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. More... | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. More... | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. More... | |
TypedObject & | operator= (const TypedObject ©)=default |
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. More... | |
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. More... | |
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. More... | |
Public Attributes | |
TextureSwaps | _textureSwaps |
Public Attributes inherited from TypedObject | |
get_type | |
Additional Inherited Members | |
Static Public Attributes inherited from TypedWritable | |
static TypedWritable *const | Null = nullptr |
This corresponds to a particular assignment of a TextureImage with a PaletteGroup, and specifically describes which PaletteImage (if any), and where on the PaletteImage, the TextureImage has been assigned to.
Definition at line 41 of file texturePlacement.h.
void TexturePlacement::add_egg | ( | TextureReference * | reference | ) |
Records the fact that a particular egg file is using this particular TexturePlacement.
Definition at line 128 of file texturePlacement.cxx.
References TextureReference::mark_egg_stale().
Referenced by TextureReference::set_placement().
|
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 1034 of file texturePlacement.cxx.
References TypedWritable::complete_pointers().
void TexturePlacement::compute_tex_matrix | ( | LMatrix3d & | transform | ) |
Stores in the indicated matrix the appropriate texture matrix transform for the new placement of the texture.
Definition at line 608 of file texturePlacement.cxx.
bool TexturePlacement::determine_size | ( | ) |
Attempts to determine the appropriate size of the texture for the given placement.
This is based on the UV range of the egg files that reference the texture. Returns true on success, or false if the texture size cannot be determined (e.g. the texture file is unknown).
After this returns true, get_x_size() and get_y_size() may safely be called.
Definition at line 196 of file texturePlacement.cxx.
References force_replace(), and ImageFile::is_size_known().
Referenced by PaletteGroup::update_unknown_textures().
void TexturePlacement::fill_image | ( | PNMImage & | image | ) |
Fills in the rectangle of the palette image represented by the texture placement with the image pixels.
Definition at line 694 of file texturePlacement.cxx.
void TexturePlacement::fill_swapped_image | ( | PNMImage & | image, |
int | index | ||
) |
Fills in the rectangle of the swapped palette image represented by the texture placement with the image pixels.
Definition at line 823 of file texturePlacement.cxx.
void TexturePlacement::flag_error_image | ( | PNMImage & | image | ) |
Sets the rectangle of the palette image represented by the texture placement to red, to represent a missing texture.
Definition at line 918 of file texturePlacement.cxx.
void TexturePlacement::force_replace | ( | ) |
Removes the texture from its particular PaletteImage, but does not remove it from the PaletteGroup.
It will be re-placed when the PaletteGroup::place_all() is called.
Definition at line 545 of file texturePlacement.cxx.
References PaletteImage::unplace().
Referenced by determine_size().
DestTextureImage * TexturePlacement::get_dest | ( | ) | const |
Returns the DestTextureImage that corresponds to this texture as it was copied to the install directory.
Definition at line 182 of file texturePlacement.cxx.
PaletteGroup * TexturePlacement::get_group | ( | ) | const |
Returns the group that this placement represents.
Definition at line 119 of file texturePlacement.cxx.
Referenced by EggFile::choose_placements().
PaletteImage * TexturePlacement::get_image | ( | ) | const |
Returns the particular PaletteImage on which the texture has been placed.
Definition at line 456 of file texturePlacement.cxx.
const std::string & TexturePlacement::get_name | ( | ) | const |
Returns the name of the texture that this placement represents.
Definition at line 95 of file texturePlacement.cxx.
Referenced by SortPlacementBySize::operator()().
OmitReason TexturePlacement::get_omit_reason | ( | ) | const |
Returns the reason the texture has been omitted from a palette image, or OR_none if it has not.
Definition at line 401 of file texturePlacement.cxx.
Referenced by PaletteGroup::place_all(), TextureReference::update_egg(), and PaletteGroup::write_image_info().
PalettePage * TexturePlacement::get_page | ( | ) | const |
Returns the particular PalettePage on which the texture has been placed.
Definition at line 465 of file texturePlacement.cxx.
double TexturePlacement::get_placed_uv_area | ( | ) | const |
Returns the total area of the rectangle occupied by the UV minmax box, as it has been placed.
See also get_uv_area().
Definition at line 515 of file texturePlacement.cxx.
Referenced by write_placed().
int TexturePlacement::get_placed_x | ( | ) | const |
Returns the X pixel at which the texture has been placed within its PaletteImage.
It is an error to call this unless is_placed() returns true.
Definition at line 475 of file texturePlacement.cxx.
Referenced by write_placed().
int TexturePlacement::get_placed_x_size | ( | ) | const |
Returns the size in the X dimension, in pixels, of the texture image as it has been placed within the palette.
Definition at line 495 of file texturePlacement.cxx.
Referenced by write_placed().
int TexturePlacement::get_placed_y | ( | ) | const |
Returns the Y pixel at which the texture has been placed within its PaletteImage.
It is an error to call this unless is_placed() returns true.
Definition at line 485 of file texturePlacement.cxx.
Referenced by write_placed().
int TexturePlacement::get_placed_y_size | ( | ) | const |
Returns the size in the Y dimension, in pixels, of the texture image as it has been placed within the palette.
Definition at line 505 of file texturePlacement.cxx.
Referenced by write_placed().
const TextureProperties & TexturePlacement::get_properties | ( | ) | const |
Returns the grouping properties of the image.
Definition at line 111 of file texturePlacement.cxx.
References ImageFile::get_properties().
TextureImage * TexturePlacement::get_texture | ( | ) | const |
Returns the texture that this placement represents.
Definition at line 103 of file texturePlacement.cxx.
Referenced by TextureMemoryCounter::add_placement(), PaletteGroup::update_unknown_textures(), and write_placed().
double TexturePlacement::get_uv_area | ( | ) | const |
Returns the total area of the rectangle occupied by the UV minmax box, in UV coordinates.
1.0 is the entire texture; values greater than 1 imply the texture repeats.
Definition at line 433 of file texturePlacement.cxx.
int TexturePlacement::get_x_size | ( | ) | const |
Returns the size in the X dimension, in pixels, of the texture image as it must appear in the palette.
This accounts for any growing or shrinking of the texture due to the UV coordinate range.
Definition at line 411 of file texturePlacement.cxx.
Referenced by SortPlacementBySize::operator()().
int TexturePlacement::get_y_size | ( | ) | const |
Returns the size in the Y dimension, in pixels, of the texture image as it must appear in the palette.
This accounts for any growing or shrinking of the texture due to the UV coordinate range.
Definition at line 422 of file texturePlacement.cxx.
Referenced by SortPlacementBySize::operator()().
bool TexturePlacement::intersects | ( | int | x, |
int | y, | ||
int | x_size, | ||
int | y_size | ||
) |
Returns true if the particular position this texture has been assigned to overlaps the rectangle whose top left corner is at x, y and whose size is given by x_size, y_size, or false otherwise.
Definition at line 590 of file texturePlacement.cxx.
bool TexturePlacement::is_filled | ( | ) | const |
Returns true if the texture has been filled (i.e.
fill_image() has been called) since it was placed.
Definition at line 676 of file texturePlacement.cxx.
bool TexturePlacement::is_placed | ( | ) | const |
Returns true if the texture has been placed on a palette image, false otherwise.
This will generally be true if get_omit_reason() returns OR_none or OR_solitary and false otherwise.
Definition at line 448 of file texturePlacement.cxx.
Referenced by write_placed().
bool TexturePlacement::is_size_known | ( | ) | const |
Returns true if the texture's size is known, false otherwise.
Usually this can only be false after determine_size() has been called there is something wrong with the texture (in which case the placement will automatically omit itself from the palette anyway).
Definition at line 392 of file texturePlacement.cxx.
Referenced by PaletteGroup::update_unknown_textures().
void TexturePlacement::mark_eggs_stale | ( | ) |
Marks all the egg files that reference this placement stale.
Presumably this is called after moving the texture around in the palette or something.
Definition at line 159 of file texturePlacement.cxx.
References TextureReference::mark_egg_stale().
void TexturePlacement::mark_unfilled | ( | ) |
Marks the texture as unfilled, so that it will need to be copied into the palette image again.
Definition at line 685 of file texturePlacement.cxx.
void TexturePlacement::not_solitary | ( | ) |
Indicates that the texture, formerly indicated as solitary, is now no longer.
Definition at line 576 of file texturePlacement.cxx.
void TexturePlacement::omit_solitary | ( | ) |
Sets the omit reason (returned by get_omit()) to OR_solitary, indicating that the palettized version of the texture should not be used because it is the only texture on a PaletteImage.
However, the texture is still considered placed, and is_placed() will return true.
Definition at line 563 of file texturePlacement.cxx.
void TexturePlacement::place_at | ( | PaletteImage * | image, |
int | x, | ||
int | y | ||
) |
Assigns the texture to a particular position within the indicated PaletteImage.
It is an error to call this if the texture has already been placed elsewhere.
Definition at line 527 of file texturePlacement.cxx.
|
static |
Registers the current object as something that can be read from a Bam file.
Definition at line 988 of file texturePlacement.cxx.
References BamReader::get_factory().
Referenced by init_palettizer().
void TexturePlacement::remove_egg | ( | TextureReference * | reference | ) |
Notes that a particular egg file is no longer using this particular TexturePlacement.
Definition at line 145 of file texturePlacement.cxx.
References TextureReference::mark_egg_stale().
Referenced by EggFile::remove_egg(), and TextureReference::set_placement().
void TexturePlacement::set_dest | ( | DestTextureImage * | dest | ) |
Sets the DestTextureImage that corresponds to this texture as it was copied to the install directory.
Definition at line 173 of file texturePlacement.cxx.
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 998 of file texturePlacement.cxx.
References Datagram::add_bool(), Datagram::add_int32(), TypedWritable::write_datagram(), TexturePosition::write_datagram(), and BamWriter::write_pointer().
void TexturePlacement::write_placed | ( | std::ostream & | out, |
int | indent_level = 0 |
||
) |
Writes the placement position information on a line by itself.
Definition at line 646 of file texturePlacement.cxx.
References get_placed_uv_area(), get_placed_x(), get_placed_x_size(), get_placed_y(), get_placed_y_size(), get_texture(), indent(), and is_placed().