Panda3D
Public Member Functions | Static Public Member Functions | Static Public Attributes | 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.
virtual ReferenceCountas_reference_count ()
 Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type.
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer.
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer.
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.
string encode_to_bam_stream () const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string.
bool encode_to_bam_stream (string &data, BamWriter *writer=NULL) const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string.
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.
virtual TypeHandle force_init_type ()
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.
UpdateSeq get_bam_modified () const
 Returns the current bam_modified counter.
int get_best_parent_from_Set (const std::set< int > &) const
EggFileget_egg_file () const
 Returns the EggFile that references this texture.
const TexCoorddget_max_uv () const
 Returns the maximum UV coordinate in use for the texture by this reference.
const TexCoorddget_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
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.
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.
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.
void mark_bam_modified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams.
void mark_egg_stale ()
 Marks the egg file that shares this reference as stale.
void operator delete (void *ptr)
void operator delete (void *ptr, void *)
void operator delete[] (void *ptr)
void operator delete[] (void *, void *)
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)
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.
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.
void set_placement (TexturePlacement *placement)
 Sets the particular TexturePlacement that is appropriate for this egg file.
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.
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 bool decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, const string &data, BamReader *reader=NULL)
 Reads the string created by a previous call to encode_to_bam_stream(), and extracts the single object on that string.
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.

Static Public Attributes

static TypedWritable *const Null = (TypedWritable*)0L

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

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

ReferenceCount * TypedWritable::as_reference_count ( ) [virtual, inherited]

Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type.

Reimplemented in PandaNode, and TypedWritableReferenceCount.

Definition at line 155 of file typedWritable.cxx.

Referenced by BamReader::change_pointer(), BamReader::register_change_this(), and BamReader::resolve().

TypedObject * TypedObject::as_typed_object ( ) [inline, inherited]

Returns the object, upcast (if necessary) to a TypedObject pointer.

Definition at line 99 of file typedObject.I.

const TypedObject * TypedObject::as_typed_object ( ) const [inline, inherited]

Returns the object, upcast (if necessary) to a TypedObject pointer.

Definition at line 110 of file typedObject.I.

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

bool TypedWritable::decode_raw_from_bam_stream ( TypedWritable *&  ptr,
ReferenceCount *&  ref_ptr,
const string &  data,
BamReader reader = NULL 
) [static, inherited]

Reads the string created by a previous call to encode_to_bam_stream(), and extracts the single object on that string.

Returns true on success, false on on error.

This variant sets the TypedWritable and ReferenceCount pointers separately; both are pointers to the same object. The reference count is not incremented; it is the caller's responsibility to manage the reference count.

Note that this method cannot be used to retrieve objects that do not inherit from ReferenceCount, because these objects cannot persist beyond the lifetime of the BamReader that reads them. To retrieve these objects from a bam stream, you must construct a BamReader directly.

If you happen to know that the particular object in question inherits from TypedWritableReferenceCount or PandaNode, consider calling the variant of decode_from_bam_stream() defined for those methods, which presents a simpler interface.

Definition at line 353 of file typedWritable.cxx.

References BamReader::init(), DatagramInputFile::open(), DatagramInputFile::read_header(), BamReader::read_object(), ReferenceCount::ref(), BamReader::resolve(), BamReader::set_source(), and ReferenceCount::unref().

string TypedWritable::encode_to_bam_stream ( ) const [inline, inherited]

Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string.

Returns empty string on failure.

This is a convenience method particularly useful for cases when you are only serializing a single object. If you have many objects to process, it is more efficient to use the same BamWriter to serialize all of them together.

Definition at line 86 of file typedWritable.I.

bool TypedWritable::encode_to_bam_stream ( string &  data,
BamWriter writer = NULL 
) const [inherited]

Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string.

Returns true on success, false on failure.

This is a convenience method particularly useful for cases when you are only serializing a single object. If you have many objects to process, it is more efficient to use the same BamWriter to serialize all of them together.

Definition at line 283 of file typedWritable.cxx.

References BamWriter::init(), DatagramOutputFile::open(), BamWriter::set_target(), DatagramOutputFile::write_header(), and BamWriter::write_object().

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 TypedWritable::finalize ( BamReader manager) [virtual, inherited]

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 in PartBundle, Geom, GeomPrimitive, GeomVertexArrayData, GeomVertexArrayFormat, GeomVertexData, InternalName, GeomNode, LightAttrib, RenderAttrib, RenderEffect, RenderEffects, RenderState, PaletteGroup, and Palettizer.

Definition at line 145 of file typedWritable.cxx.

Referenced by BamReader::finalize_now().

void TextureReference::from_egg ( EggFile egg_file,
EggData data,
EggTexture egg_tex 
)
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().

UpdateSeq TypedWritable::get_bam_modified ( ) const [inline, inherited]

Returns the current bam_modified counter.

This counter is normally incremented automatically whenever the object is modified.

Definition at line 66 of file typedWritable.I.

Referenced by BamWriter::consider_update(), and BamWriter::write_pointer().

EggFile * TextureReference::get_egg_file ( ) const

Returns the EggFile that references this texture.

Definition at line 198 of file textureReference.cxx.

const TexCoordd & 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 TexCoordd & 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.

int TypedObject::get_type_index ( ) const [inline, inherited]

Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

This is equivalent to get_type().get_index().

Definition at line 52 of file typedObject.I.

References TypeHandle::get_index().

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

bool TypedObject::is_exact_type ( TypeHandle  handle) const [inline, inherited]
bool TypedObject::is_of_type ( TypeHandle  handle) const [inline, inherited]

Returns true if the current object is or derives from the indicated type.

Definition at line 63 of file typedObject.I.

References TypeHandle::is_derived_from().

Referenced by EggSliderData::add_back_pointer(), EggJointData::add_back_pointer(), CIntervalManager::add_c_interval(), XFileNode::add_child(), CollisionTraverser::add_collider(), CollisionHandlerPhysical::add_collider(), EggXfmSAnim::add_data(), CharacterJointBundle::add_node(), NonlinearImager::add_screen(), EggGroupNode::apply_first_attribute(), EggGroupNode::apply_last_attribute(), DeferredNodeProperty::apply_to_node(), RecorderController::begin_playback(), NodePath::clear_clip_plane(), EggGroupNode::clear_connected_shading(), NodePath::clear_light(), EggBase::convert_paths(), NodePath::decode_from_bam_stream(), VrpnClient::disconnect_device(), PhysicsManager::do_physics(), GraphicsStateGuardian::fetch_specified_part(), EggRenderState::fill_state(), AnimBundleNode::find_anim_bundle(), EggGroupNode::find_coordsys_entry(), XFile::find_data_object(), Character::find_joint(), EggGroupNode::find_materials(), Character::find_slider(), XFile::find_template(), EggGroupNode::find_textures(), EggMaterialCollection::find_used_materials(), EggTextureCollection::find_used_textures(), EggGroupNode::force_filenames(), EggJointData::force_initial_rest_frame(), WindowFramework::get_aspect_2d(), EggPoolUniquifier::get_category(), EggGroupUniquifier::get_category(), EggGroupNode::get_connected_shading(), PandaFramework::get_mouse(), FactoryParams::get_param_of_type(), EggGroupNode::has_absolute_pathnames(), NodePath::has_clip_plane(), NodePath::has_clip_plane_off(), NodePath::has_light(), PandaFramework::hide_collision_solids(), x11GraphicsWindow::open_window(), eglGraphicsWindow::open_window(), EggNode::parse_egg(), CharacterMaker::part_to_node(), EggGroupNode::post_apply_flat_attribute(), EggBinner::prepare_node(), PortalClipper::prepare_portal(), NodePath::project_texture(), EggMatrixTablePointer::quantize_channels(), ParametricCurveCollection::r_add_curves(), SceneGraphReducer::r_collect_vertex_data(), EggGroupNode::r_load_externals(), EggGroupNode::rebuild_vertex_pools(), EggGroupNode::recompute_polygon_normals(), EggGroupNode::remove_invalid_primitives(), EggGroupNode::remove_unused_vertices(), EggLoader::reparent_decals(), EggMaterialCollection::replace_materials(), EggTextureCollection::replace_textures(), EggGroupNode::resolve_filenames(), EggGroupNode::reverse_vertex_ordering(), NodePath::set_clip_plane(), NodePath::set_clip_plane_off(), NodePath::set_light(), ProjectionScreen::set_projector(), NonlinearImager::set_source_camera(), EggXfmSAnim::set_value(), NonlinearImager::set_viewer_camera(), PandaFramework::show_collision_solids(), BamCache::store(), XFileToEggConverter::strip_nodes(), EggGroupNode::strip_normals(), DataGraphTraverser::traverse(), DataGraphTraverser::traverse_below(), EggGroupNode::triangulate_polygons(), EggGroupNode::unify_attributes(), EggNameUniquifier::uniquify(), NodeCullCallbackData::upcall(), PhysicsCollisionHandler::validate_target(), EggXfmSAnim::write(), EggGroup::write(), EggToDXFLayer::write_3d_face(), and EggToDXFLayer::write_entities().

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 TypedWritable::mark_bam_modified ( ) [inline, inherited]
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().

bool TypedWritable::require_fully_complete ( ) const [virtual, inherited]

Some objects require all of their nested pointers to have been completed before the objects themselves can be completed.

If this is the case, override this method to return true, and be careful with circular references (which would make the object unreadable from a bam file).

Reimplemented in GeomVertexData, ClipPlaneAttrib, and RenderEffects.

Definition at line 118 of file typedWritable.cxx.

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 TypedWritable::update_bam_nested ( BamWriter manager) [virtual, inherited]

Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates.

Reimplemented in CFDoCullCommand, and PandaNode.

Definition at line 77 of file typedWritable.cxx.

void TextureReference::update_egg ( )
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