Panda3D
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions
TextureReference Class Reference

This is the particular reference of a texture filename by an egg file. More...

#include "textureReference.h"

Inheritance diagram for TextureReference:
TypedWritable TypedObject MemoryBase

List of all members.

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.
EggFileget_egg_file () const
 Returns the EggFile that references this texture.
const LTexCoorddget_max_uv () const
 Returns the maximum UV coordinate in use for the texture by this reference.
const LTexCoorddget_min_uv () const
 Returns the minimum UV coordinate in use for the texture by this reference.
TexturePlacementget_placement () const
 Returns the particular TexturePlacement that is appropriate for this egg file.
SourceTextureImageget_source () const
 Returns the SourceTextureImage that this object refers to.
TextureImageget_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 TypedWritablemake_TextureReference (const FactoryParams &params)
 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.

Detailed Description

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.


Member Function Documentation

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().

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 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().

Returns the EggFile that references this texture.

Definition at line 198 of file textureReference.cxx.

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().

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().

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().

Returns the SourceTextureImage that this object refers to.

Definition at line 209 of file textureReference.cxx.

Referenced by EggFile::build_cross_links().

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 LVecBase2d::almost_equal(), LMatrix3d::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().

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.

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().

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().

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::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 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().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations