Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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 List of all members.

Public Member Functions

 TextureReference ()
 ~TextureReference ()
void from_egg (EggFile *egg_file, EggData *data, EggTexture *egg_tex)
 Sets up the TextureReference using information extracted from an egg file.

EggFileget_egg_file () const
 Returns the EggFile that references this texture.

SourceTextureImageget_source () const
 Returns the SourceTextureImage that this object refers to.

TextureImageget_texture () const
 Returns the TextureImage that this object refers to.

bool has_uvs () const
 Returns true if this TextureReference actually uses the texture on geometry, with UV's and everything, or false otherwise.

const TexCoorddget_min_uv () const
 Returns the minimum UV coordinate in use for the texture by this reference.

const TexCoorddget_max_uv () const
 Returns the maximum UV coordinate in use for the texture by this reference.

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.

void set_placement (TexturePlacement *placement)
 Sets the particular TexturePlacement that is appropriate for this egg file.

void clear_placement ()
 Removes any reference to a TexturePlacement.

TexturePlacementget_placement () const
 Returns the particular TexturePlacement that is appropriate for this egg file.

void mark_egg_stale ()
 Marks the egg file that shares this reference as stale.

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 apply_properties_to_source ()
 Applies the texture properties as read from the egg file to the source image's properties.

void output (ostream &out) const
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.

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.

virtual TypeHandle get_type () const
virtual void finalize ()
virtual TypeHandle force_init_type (void)
int get_type_index () const
bool is_of_type (TypeHandle handle) const
bool is_exact_type (TypeHandle handle) const

Static Public Member Functions

void register_with_read_factory ()
 Registers the current object as something that can be read from a Bam file.

TypeHandle get_class_type ()
void init_type ()

Static Public Attributes

TypedWritable *const Null

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

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.


Private Member Functions

void get_uv_range (EggGroupNode *group, Palettizer::RemapUV remap)
 Checks the geometry in the egg file to see what range of UV's are requested for this particular texture reference.

void update_uv_range (EggGroupNode *group, Palettizer::RemapUV remap)
 Actually applies the UV translates that were assumed in the previous call to get_uv_range().

bool get_geom_uvs (EggPrimitive *geom, TexCoordd &geom_min_uv, TexCoordd &geom_max_uv)
 Determines the minimum and maximum UV range for a particular primitive.

void translate_geom_uvs (EggPrimitive *geom, const TexCoordd &trans) const
 Applies the indicated translation to each UV in the primitive.


Static Private Member Functions

void collect_uv (bool &any_uvs, TexCoordd &min_uv, TexCoordd &max_uv, const TexCoordd &got_min_uv, const TexCoordd &got_max_uv)
 Updates any_uvs, min_uv, and max_uv with the indicated min and max UV's already determined.

LVector2d translate_uv (const TexCoordd &min_uv, const TexCoordd &max_uv)
 Returns the needed adjustment to translate the given bounding box so that its center lies in the unit square (0,0) - (1,1).


Private Attributes

EggFile_egg_file
EggTexture_egg_tex
EggData_egg_data
LMatrix3d _tex_mat
LMatrix3d _inv_tex_mat
SourceTextureImage_source_texture
TexturePlacement_placement
bool _uses_alpha
bool _any_uvs
TexCoordd _min_uv
TexCoordd _max_uv
EggTexture::WrapMode _wrap_u
EggTexture::WrapMode _wrap_v
TextureProperties _properties

Static Private Attributes

TypeHandle _type_handle

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 56 of file textureReference.h.


Constructor & Destructor Documentation

TextureReference::TextureReference  ) 
 

Definition at line 56 of file textureReference.cxx.

References _any_uvs, _max_uv, _min_uv, _placement, _source_texture, _uses_alpha, _wrap_u, _wrap_v, NULL, and EggTexture::WM_unspecified.

TextureReference::~TextureReference  ) 
 

Definition at line 79 of file textureReference.cxx.

References _egg_data, _egg_file, _egg_tex, _inv_tex_mat, _tex_mat, EggTexture::get_transform(), and EggTexture::has_transform().


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 453 of file textureReference.cxx.

Referenced by EggFile::mark_stale().

void TextureReference::clear_placement  ) 
 

Removes any reference to a TexturePlacement.

Definition at line 307 of file textureReference.cxx.

References _egg_tex, EggRenderMode::AM_unspecified, and EggTexture::set_alpha_mode().

void TextureReference::collect_uv bool &  any_uvs,
TexCoordd min_uv,
TexCoordd max_uv,
const TexCoordd got_min_uv,
const TexCoordd got_max_uv
[static, private]
 

Updates any_uvs, min_uv, and max_uv with the indicated min and max UV's already determined.

Definition at line 791 of file textureReference.cxx.

References fillin(), params, and parse_params().

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 894 of file textureReference.cxx.

void TextureReference::fillin DatagramIterator scan,
BamReader manager
[protected]
 

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 955 of file textureReference.cxx.

Referenced by collect_uv().

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 94 of file textureReference.cxx.

References _inv_tex_mat, and _tex_mat.

TypeHandle TextureReference::get_class_type void   )  [inline, static]
 

Reimplemented from TypedWritable.

Definition at line 126 of file textureReference.h.

EggFile * TextureReference::get_egg_file  )  const
 

Returns the EggFile that references this texture.

Definition at line 157 of file textureReference.cxx.

References _source_texture, SourceTextureImage::get_texture(), nassertr, and NULL.

bool TextureReference::get_geom_uvs EggPrimitive geom,
TexCoordd geom_min_uv,
TexCoordd geom_max_uv
[private]
 

Determines the minimum and maximum UV range for a particular primitive.

Returns true if it has any UV's, false otherwise.

Definition at line 735 of file textureReference.cxx.

References _properties, _tex_mat, and writer().

const TexCoordd & TextureReference::get_max_uv  )  const
 

Returns the maximum UV coordinate in use for the texture by this reference.

Definition at line 236 of file textureReference.cxx.

References _placement, TexturePlacement::add_egg(), NULL, and TexturePlacement::remove_egg().

const TexCoordd & TextureReference::get_min_uv  )  const
 

Returns the minimum UV coordinate in use for the texture by this reference.

Definition at line 220 of file textureReference.cxx.

References _wrap_v, and EggTexture::WrapMode.

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 326 of file textureReference.cxx.

References _egg_tex, _placement, Filename::get_basename(), EggTexture::get_filename(), OR_unknown, EggTexture::set_filename(), and ImageFile::update_egg_tex().

Referenced by EggFile::is_stale().

SourceTextureImage * TextureReference::get_source  )  const
 

Returns the SourceTextureImage that this object refers to.

Definition at line 172 of file textureReference.cxx.

References _any_uvs.

TextureImage * TextureReference::get_texture void   )  const
 

Returns the TextureImage that this object refers to.

Definition at line 185 of file textureReference.cxx.

References _any_uvs, _min_uv, nassertr, and TexCoordd.

Referenced by EggFile::is_stale().

virtual TypeHandle TextureReference::get_type void   )  const [inline, virtual]
 

Reimplemented from TypedWritable.

Definition at line 134 of file textureReference.h.

References output().

void TextureReference::get_uv_range EggGroupNode group,
Palettizer::RemapUV  remap
[private]
 

Checks the geometry in the egg file to see what range of UV's are requested for this particular texture reference.

If pal->_remap_uv is not RU_never, this will also attempt to remap the UV's found so that the midpoint lies in the unit square (0,0) - (1,1), in the hopes of maximizing overlap of UV coordinates between different polygons. However, the hypothetical translations are not actually applied to the egg file at this point (because we might decide not to place the texture in a palette); they will actually be applied when update_uv_range(), below, is called later.

Definition at line 563 of file textureReference.cxx.

References EggGroup::DT_none, and pal.

EggTexture::WrapMode TextureReference::get_wrap_u  )  const
 

Returns the specification for the wrapping in the U direction.

Definition at line 252 of file textureReference.cxx.

References NULL, and set_placement().

EggTexture::WrapMode TextureReference::get_wrap_v  )  const
 

Returns the specification for the wrapping in the V direction.

Definition at line 267 of file textureReference.cxx.

References _placement.

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 205 of file textureReference.cxx.

References _wrap_u, and EggTexture::WrapMode.

void TextureReference::init_type void   )  [inline, static]
 

Reimplemented from TypedWritable.

Definition at line 129 of file textureReference.h.

References _type_handle.

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 932 of file textureReference.cxx.

void TextureReference::mark_egg_stale  ) 
 

Marks the egg file that shares this reference as stale.

Definition at line 341 of file textureReference.cxx.

References _placement.

Referenced by TexturePlacement::add_egg(), TexturePlacement::get_group(), and TexturePlacement::get_properties().

void TextureReference::output ostream &  out  )  const
 

Definition at line 466 of file textureReference.cxx.

References DCAST_INTO_V, EggGroup::DT_none, EggGroup::get_class_type(), EggGroup::get_dart_type(), and EggGroupNode::is_of_type().

Referenced by get_type().

void TextureReference::register_with_read_factory void   )  [static]
 

Registers the current object as something that can be read from a Bam file.

Definition at line 835 of file textureReference.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 284 of file textureReference.cxx.

Referenced by get_wrap_u().

void TextureReference::translate_geom_uvs EggPrimitive geom,
const TexCoordd trans
const [private]
 

Applies the indicated translation to each UV in the primitive.

Definition at line 762 of file textureReference.cxx.

References _egg_file, _placement, _properties, _source_texture, TextureProperties::complete_pointers(), TypedWritable::complete_pointers(), DCAST_INTO_R, and NULL.

LVector2d TextureReference::translate_uv const TexCoordd min_uv,
const TexCoordd max_uv
[static, private]
 

Returns the needed adjustment to translate the given bounding box so that its center lies in the unit square (0,0) - (1,1).

Definition at line 819 of file textureReference.cxx.

References _any_uvs, _max_uv, _min_uv, _properties, _uses_alpha, _wrap_u, and _wrap_v.

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 360 of file textureReference.cxx.

References _egg_tex, _placement, and pal.

void TextureReference::update_uv_range EggGroupNode group,
Palettizer::RemapUV  remap
[private]
 

Actually applies the UV translates that were assumed in the previous call to get_uv_range().

Definition at line 656 of file textureReference.cxx.

References EggPrimitive::begin(), EggVertex::copy_grefs_from(), EggVertexPool::create_unique_vertex(), EggPrimitive::end(), EggVertex::get_pool(), EggVertex::get_uv(), EggVertex::gref_size(), EggVertex::has_uv(), EggPrimitive::iterator, EggPrimitive::replace(), and EggVertex::set_uv().

void TextureReference::write ostream &  out,
int  indent_level = 0
const
 

Definition at line 478 of file textureReference.cxx.

References pal.

Referenced by EggFile::remove_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 853 of file textureReference.cxx.


Member Data Documentation

bool TextureReference::_any_uvs [private]
 

Definition at line 108 of file textureReference.h.

Referenced by get_source(), get_texture(), TextureReference(), and translate_uv().

EggData* TextureReference::_egg_data [private]
 

Definition at line 100 of file textureReference.h.

Referenced by ~TextureReference().

EggFile* TextureReference::_egg_file [private]
 

Definition at line 98 of file textureReference.h.

Referenced by translate_geom_uvs(), and ~TextureReference().

EggTexture* TextureReference::_egg_tex [private]
 

Definition at line 99 of file textureReference.h.

Referenced by clear_placement(), get_placement(), update_egg(), and ~TextureReference().

LMatrix3d TextureReference::_inv_tex_mat [private]
 

Definition at line 102 of file textureReference.h.

Referenced by from_egg(), and ~TextureReference().

TexCoordd TextureReference::_max_uv [private]
 

Definition at line 109 of file textureReference.h.

Referenced by TextureReference(), and translate_uv().

TexCoordd TextureReference::_min_uv [private]
 

Definition at line 109 of file textureReference.h.

Referenced by get_texture(), TextureReference(), and translate_uv().

TexturePlacement* TextureReference::_placement [private]
 

Definition at line 104 of file textureReference.h.

Referenced by get_max_uv(), get_placement(), get_wrap_v(), mark_egg_stale(), TextureReference(), translate_geom_uvs(), and update_egg().

TextureProperties TextureReference::_properties [private]
 

Definition at line 112 of file textureReference.h.

Referenced by get_geom_uvs(), translate_geom_uvs(), and translate_uv().

SourceTextureImage* TextureReference::_source_texture [private]
 

Definition at line 103 of file textureReference.h.

Referenced by get_egg_file(), TextureReference(), and translate_geom_uvs().

LMatrix3d TextureReference::_tex_mat [private]
 

Definition at line 102 of file textureReference.h.

Referenced by from_egg(), get_geom_uvs(), and ~TextureReference().

TypeHandle TextureReference::_type_handle [static, private]
 

Reimplemented from TypedWritable.

Definition at line 46 of file textureReference.cxx.

Referenced by init_type().

bool TextureReference::_uses_alpha [private]
 

Definition at line 106 of file textureReference.h.

Referenced by TextureReference(), and translate_uv().

EggTexture::WrapMode TextureReference::_wrap_u [private]
 

Definition at line 110 of file textureReference.h.

Referenced by has_uvs(), TextureReference(), and translate_uv().

EggTexture::WrapMode TextureReference::_wrap_v [private]
 

Definition at line 110 of file textureReference.h.

Referenced by get_min_uv(), TextureReference(), and translate_uv().


The documentation for this class was generated from the following files:
Generated on Fri May 2 03:28:07 2003 for Panda-Tool by doxygen1.3