Panda3D
|
This is the particular reference of a texture filename by an egg file. More...
#include "textureReference.h"
Public Member Functions | |
void | apply_properties_to_source () |
Applies the texture properties as read from the egg file to the source image's properties. | |
void | clear_placement () |
Removes any reference to a TexturePlacement. | |
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 | from_egg (EggFile *egg_file, EggData *data, EggTexture *egg_tex) |
Sets up the TextureReference using information extracted from an egg file. | |
void | from_egg_quick (const TextureReference &other) |
Sets up the pointers within the TextureReference to the same egg file pointers indicated by the other TextureReference object, without changing any of the other internal data stored here regarding the egg structures. | |
EggFile * | get_egg_file () const |
Returns the EggFile that references this texture. | |
const LTexCoordd & | get_max_uv () const |
Returns the maximum UV coordinate in use for the texture by this reference. | |
const LTexCoordd & | get_min_uv () const |
Returns the minimum UV coordinate in use for the texture by this reference. | |
TexturePlacement * | get_placement () const |
Returns the particular TexturePlacement that is appropriate for this egg file. | |
SourceTextureImage * | get_source () const |
Returns the SourceTextureImage that this object refers to. | |
TextureImage * | get_texture () const |
Returns the TextureImage that this object refers to. | |
const string & | get_tref_name () const |
Returns the name of the EggTexture entry that references this texture. | |
virtual TypeHandle | get_type () const |
EggTexture::WrapMode | get_wrap_u () const |
Returns the specification for the wrapping in the U direction. | |
EggTexture::WrapMode | get_wrap_v () const |
Returns the specification for the wrapping in the V direction. | |
bool | has_uvs () const |
Returns true if this TextureReference actually uses the texture on geometry, with UV's and everything, or false otherwise. | |
bool | is_equivalent (const TextureReference &other) const |
Returns true if all essential properties of this TextureReference are the same as that of the other, or false if any of them differ. | |
void | mark_egg_stale () |
Marks the egg file that shares this reference as stale. | |
bool | operator< (const TextureReference &other) const |
Defines an ordering of TextureReference pointers in alphabetical order by their tref name. | |
void | output (ostream &out) const |
void | rebind_egg_data (EggData *data, EggTexture *egg_tex) |
After an EggData has previously been released via release_egg_data(), this can be called to indicate that the egg file has been reloaded and we should assign the indicated pointers. | |
void | release_egg_data () |
Called to indicate that the EggData previously passed to from_egg() is about to be deallocated, and all of its pointers should be cleared. | |
void | set_placement (TexturePlacement *placement) |
Sets the particular TexturePlacement that is appropriate for this egg file. | |
void | update_egg () |
Updates the egg file with all the relevant information to reference the texture in its new home, wherever that might be. | |
void | write (ostream &out, int indent_level=0) const |
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. | |
Static Public Member Functions | |
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. | |
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_TextureReference (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 is the particular reference of a texture filename by an egg file.
It also includes information about the way in which the egg file uses the texture; e.g. does it repeat.
Definition at line 43 of file textureReference.h.
void TextureReference::apply_properties_to_source | ( | ) |
Applies the texture properties as read from the egg file to the source image's properties.
This updates the source image with the now-known properties indicated with in the tref block of the egg file.
Definition at line 518 of file textureReference.cxx.
References ImageFile::update_properties().
Referenced by EggFile::apply_properties_to_source().
void TextureReference::clear_placement | ( | ) |
Removes any reference to a TexturePlacement.
Definition at line 375 of file textureReference.cxx.
References set_placement().
int TextureReference::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 940 of file textureReference.cxx.
References TextureProperties::complete_pointers().
void TextureReference::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 990 of file textureReference.cxx.
References TextureProperties::fillin(), DatagramIterator::get_bool(), DatagramIterator::get_float64(), DatagramIterator::get_int32(), DatagramIterator::get_string(), LMatrix3d::read_datagram(), and BamReader::read_pointer().
Referenced by make_TextureReference().
void TextureReference::from_egg | ( | EggFile * | egg_file, |
EggData * | data, | ||
EggTexture * | egg_tex | ||
) |
Sets up the TextureReference using information extracted from an egg file.
Definition at line 79 of file textureReference.cxx.
References EggTexture::determine_wrap_u(), EggTexture::determine_wrap_v(), EggTexture::get_alpha_file_channel(), EggTexture::get_alpha_filename(), EggRenderMode::get_alpha_mode(), EggTexture::get_anisotropic_degree(), Filename::get_basename_wo_extension(), EggFilenameNode::get_filename(), ImageFile::get_num_channels(), SourceTextureImage::get_size(), TextureImage::get_source(), Palettizer::get_texture(), EggTransform::get_transform2d(), EggTexture::has_alpha_channel(), EggTexture::has_alpha_filename(), EggTransform::has_transform2d(), LMatrix3d::ident_mat(), LMatrix3d::invert_from(), and ImageFile::update_properties().
Referenced by EggFile::scan_textures().
void TextureReference::from_egg_quick | ( | const TextureReference & | other | ) |
Sets up the pointers within the TextureReference to the same egg file pointers indicated by the other TextureReference object, without changing any of the other internal data stored here regarding the egg structures.
This is intended for use when we have already shown that the two TextureReferences describe equivalent data.
Definition at line 157 of file textureReference.cxx.
Referenced by EggFile::scan_textures().
EggFile * TextureReference::get_egg_file | ( | ) | const |
Returns the EggFile that references this texture.
Definition at line 198 of file textureReference.cxx.
const LTexCoordd & TextureReference::get_max_uv | ( | ) | const |
Returns the maximum UV coordinate in use for the texture by this reference.
Definition at line 278 of file textureReference.cxx.
Referenced by TexturePlacement::determine_size().
const LTexCoordd & TextureReference::get_min_uv | ( | ) | const |
Returns the minimum UV coordinate in use for the texture by this reference.
Definition at line 266 of file textureReference.cxx.
Referenced by TexturePlacement::determine_size().
TexturePlacement * TextureReference::get_placement | ( | ) | const |
Returns the particular TexturePlacement that is appropriate for this egg file.
This will not be filled in until EggFile::choose_placements() has been called.
Definition at line 388 of file textureReference.cxx.
Referenced by EggFile::choose_placements(), and EggFile::remove_egg().
SourceTextureImage * TextureReference::get_source | ( | ) | const |
Returns the SourceTextureImage that this object refers to.
Definition at line 209 of file textureReference.cxx.
Referenced by EggFile::build_cross_links().
TextureImage * TextureReference::get_texture | ( | ) | const |
Returns the TextureImage that this object refers to.
Definition at line 219 of file textureReference.cxx.
References SourceTextureImage::get_texture().
Referenced by EggFile::build_cross_links(), EggFile::choose_placements(), and update_egg().
const string & TextureReference::get_tref_name | ( | ) | const |
Returns the name of the EggTexture entry that references this texture.
Definition at line 231 of file textureReference.cxx.
EggTexture::WrapMode TextureReference::get_wrap_u | ( | ) | const |
Returns the specification for the wrapping in the U direction.
Definition at line 290 of file textureReference.cxx.
Referenced by TexturePlacement::determine_size().
EggTexture::WrapMode TextureReference::get_wrap_v | ( | ) | const |
Returns the specification for the wrapping in the V direction.
Definition at line 301 of file textureReference.cxx.
Referenced by TexturePlacement::determine_size().
bool TextureReference::has_uvs | ( | ) | const |
Returns true if this TextureReference actually uses the texture on geometry, with UV's and everything, or false otherwise.
Strictly speaking, this should always return true.
Definition at line 255 of file textureReference.cxx.
Referenced by TexturePlacement::determine_size(), and EggFile::scan_textures().
static void TextureReference::init_type | ( | ) | [inline, static] |
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Making it inline seems to cause problems in the optimizer.
Reimplemented from TypedWritable.
Definition at line 127 of file textureReference.h.
bool TextureReference::is_equivalent | ( | const TextureReference & | other | ) | const |
Returns true if all essential properties of this TextureReference are the same as that of the other, or false if any of them differ.
This is useful when reading a new egg file and comparing its references to its previously-defined references.
Definition at line 315 of file textureReference.cxx.
References LMatrix3d::almost_equal(), LVecBase2d::almost_equal(), and TextureProperties::egg_properties_match().
Referenced by EggFile::scan_textures().
TypedWritable * TextureReference::make_TextureReference | ( | 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 972 of file textureReference.cxx.
References fillin().
Referenced by register_with_read_factory().
void TextureReference::mark_egg_stale | ( | ) |
Marks the egg file that shares this reference as stale.
Definition at line 399 of file textureReference.cxx.
References EggFile::mark_stale().
Referenced by TexturePlacement::add_egg(), TexturePlacement::mark_eggs_stale(), and TexturePlacement::remove_egg().
bool TextureReference::operator< | ( | const TextureReference & | other | ) | const |
Defines an ordering of TextureReference pointers in alphabetical order by their tref name.
Definition at line 242 of file textureReference.cxx.
void TextureReference::rebind_egg_data | ( | EggData * | data, |
EggTexture * | egg_tex | ||
) |
After an EggData has previously been released via release_egg_data(), this can be called to indicate that the egg file has been reloaded and we should assign the indicated pointers.
Definition at line 186 of file textureReference.cxx.
void TextureReference::register_with_read_factory | ( | ) | [static] |
Registers the current object as something that can be read from a Bam file.
Definition at line 891 of file textureReference.cxx.
References BamReader::get_factory(), and make_TextureReference().
void TextureReference::release_egg_data | ( | ) |
Called to indicate that the EggData previously passed to from_egg() is about to be deallocated, and all of its pointers should be cleared.
Definition at line 172 of file textureReference.cxx.
Referenced by EggFile::release_egg_data().
void TextureReference::set_placement | ( | TexturePlacement * | placement | ) |
Sets the particular TexturePlacement that is appropriate for this egg file.
This is called by EggFile::choose_placements().
Definition at line 355 of file textureReference.cxx.
References TexturePlacement::add_egg(), and TexturePlacement::remove_egg().
Referenced by EggFile::choose_placements(), and clear_placement().
void TextureReference::update_egg | ( | ) |
Updates the egg file with all the relevant information to reference the texture in its new home, wherever that might be.
Definition at line 413 of file textureReference.cxx.
References TexturePlacement::compute_tex_matrix(), TextureImage::get_alpha_mode(), Filename::get_basename(), TexturePlacement::get_dest(), EggFilenameNode::get_filename(), TexturePlacement::get_image(), ImageFile::get_num_channels(), TexturePlacement::get_omit_reason(), get_texture(), TextureImage::get_txa_wrap_u(), TextureImage::get_txa_wrap_v(), EggTexture::has_alpha_channel(), ImageFile::has_num_channels(), EggRenderMode::set_alpha_mode(), EggTransform::set_transform2d(), and ImageFile::update_egg_tex().
Referenced by EggFile::update_egg().
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 904 of file textureReference.cxx.
References Datagram::add_bool(), Datagram::add_float64(), Datagram::add_int32(), Datagram::add_string(), TextureProperties::write_datagram(), LMatrix3d::write_datagram(), and BamWriter::write_pointer().