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

TextureProperties Class Reference

This is the set of characteristics of a texture that, if different from another texture, prevent the two textures from sharing a PaletteImage. More...

#include <textureProperties.h>

Inheritance diagram for TextureProperties:

TypedWritable TypedObject List of all members.

Public Member Functions

 TextureProperties ()
 TextureProperties (const TextureProperties &copy)
void operator= (const TextureProperties &copy)
void clear_basic ()
 Resets only the properties that might be changed by update_properties() to a neutral state.

bool has_num_channels () const
 Returns true if the number of channels is known.

int get_num_channels () const
 Returns the number of channels (1 through 4) associated with the image.

void set_num_channels (int num_channels)
 Sets the number of channels (1 through 4) associated with the image, presumably after reading this information from the image header.

void force_grayscale ()
 Sets the actual number of channels to indicate a grayscale image, presumably after discovering that the image contains no colored pixels.

void force_nonalpha ()
 Sets the actual number of channels to indicate an image with no alpha channel, presumably after discovering that the alpha channel contains no meaningful pixels.

bool uses_alpha () const
 Returns true if the texture uses an alpha channel, false otherwise.

string get_string () const
 Returns a string corresponding to the TextureProperties object.

void update_properties (const TextureProperties &other)
 If the indicate TextureProperties structure is more specific than this one, updates this one.

void fully_define ()
 If any properties remain unspecified, specify them now.

void update_egg_tex (EggTexture *egg_tex) const
 Adjusts the texture properties of the indicated egg reference to match these properties.

bool egg_properties_match (const TextureProperties &other) const
 Returns true if all of the properties that are reflected directly in an egg file match between this TextureProperties object and the other, or false if any of them differ.

bool operator< (const TextureProperties &other) const
bool operator== (const TextureProperties &other) const
bool operator!= (const TextureProperties &other) 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.

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

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

Public Attributes

EggTexture::Format _format
bool _force_format
bool _generic_format
EggTexture::FilterType _minfilter
EggTexture::FilterType _magfilter
int _anisotropic_degree
PNMFileType_color_type
PNMFileType_alpha_type

Static Public Attributes

TypedWritable *const Null

Static Protected Member Functions

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


Static Private Member Functions

string get_format_string (EggTexture::Format format)
 Returns a short string representing the given EggTexture format.

string get_filter_string (EggTexture::FilterType filter_type)
 Returns a short string representing the given EggTexture filter type.

string get_anisotropic_degree_string (int aniso_degree)
 Returns a short string describing the anisotropic degree.

string get_type_string (PNMFileType *color_type, PNMFileType *alpha_type)
 Returns a short string representing whether the color and/or alpha type has been specified or not.

EggTexture::Format union_format (EggTexture::Format a, EggTexture::Format b)
 Returns the EggTexture format which is the more specific of the two.

EggTexture::FilterType union_filter (EggTexture::FilterType a, EggTexture::FilterType b)
 Returns the EggTexture filter type which is the more specific of the two.


Private Attributes

bool _got_num_channels
int _num_channels
int _effective_num_channels

Static Private Attributes

TypeHandle _type_handle

Detailed Description

This is the set of characteristics of a texture that, if different from another texture, prevent the two textures from sharing a PaletteImage.

It includes properties such as mipmapping, number of channels, etc.

Definition at line 48 of file textureProperties.h.


Constructor & Destructor Documentation

TextureProperties::TextureProperties  ) 
 

Definition at line 40 of file textureProperties.cxx.

References _alpha_type, _anisotropic_degree, _color_type, _force_format, _generic_format, _magfilter, _minfilter, EggTexture::FT_unspecified, and NULL.

TextureProperties::TextureProperties const TextureProperties &  copy  ) 
 

Definition at line 62 of file textureProperties.cxx.


Member Function Documentation

void TextureProperties::clear_basic  ) 
 

Resets only the properties that might be changed by update_properties() to a neutral state.

Definition at line 110 of file textureProperties.cxx.

References _got_num_channels.

Referenced by ImageFile::has_num_channels().

int TextureProperties::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 914 of file textureProperties.cxx.

Referenced by TextureReference::translate_geom_uvs().

bool TextureProperties::egg_properties_match const TextureProperties &  other  )  const
 

Returns true if all of the properties that are reflected directly in an egg file match between this TextureProperties object and the other, or false if any of them differ.

Definition at line 571 of file textureProperties.cxx.

References EggTexture::F_rgba, EggTexture::F_rgbm, and EggTexture::F_unspecified.

void TextureProperties::fillin DatagramIterator scan,
BamReader manager
 

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 968 of file textureProperties.cxx.

Referenced by PalettePage::write_datagram().

void TextureProperties::force_grayscale  ) 
 

Sets the actual number of channels to indicate a grayscale image, presumably after discovering that the image contains no colored pixels.

Definition at line 183 of file textureProperties.cxx.

References EggTexture::F_alpha, EggTexture::F_luminance_alpha, EggTexture::F_luminance_alphamask, EggTexture::F_rgba12, EggTexture::F_rgba4, EggTexture::F_rgba5, EggTexture::F_rgba8, and EggTexture::F_rgbm.

void TextureProperties::force_nonalpha  ) 
 

Sets the actual number of channels to indicate an image with no alpha channel, presumably after discovering that the alpha channel contains no meaningful pixels.

Definition at line 204 of file textureProperties.cxx.

References _anisotropic_degree, _effective_num_channels, _format, _magfilter, _minfilter, get_anisotropic_degree_string(), get_filter_string(), get_format_string(), and ostringstream::str().

void TextureProperties::fully_define  ) 
 

If any properties remain unspecified, specify them now.

Also reconcile conflicting information.

Definition at line 320 of file textureProperties.cxx.

References _format, EggTexture::F_rgb, EggTexture::F_rgb12, EggTexture::F_rgb332, EggTexture::F_rgb5, EggTexture::F_rgb8, EggTexture::F_rgba, EggTexture::F_rgba12, EggTexture::F_rgba4, EggTexture::F_rgba5, and EggTexture::F_rgba8.

string TextureProperties::get_anisotropic_degree_string int  aniso_degree  )  [static, private]
 

Returns a short string describing the anisotropic degree.

Definition at line 761 of file textureProperties.cxx.

References get_class_type(), BamReader::get_factory(), and make_TextureProperties().

Referenced by force_nonalpha().

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

Reimplemented from TypedWritable.

Definition at line 113 of file textureProperties.h.

Referenced by get_anisotropic_degree_string().

string TextureProperties::get_filter_string EggTexture::FilterType  filter_type  )  [static, private]
 

Returns a short string representing the given EggTexture filter type.

Definition at line 725 of file textureProperties.cxx.

References EggTexture::F_alpha.

Referenced by force_nonalpha().

string TextureProperties::get_format_string EggTexture::Format  format  )  [static, private]
 

Returns a short string representing the given EggTexture format.

Definition at line 651 of file textureProperties.cxx.

References EggTexture::FT_linear, EggTexture::FT_linear_mipmap_linear, EggTexture::FT_linear_mipmap_nearest, EggTexture::FT_nearest_mipmap_linear, and EggTexture::FT_nearest_mipmap_nearest.

Referenced by force_nonalpha().

int TextureProperties::get_num_channels  )  const
 

Returns the number of channels (1 through 4) associated with the image.

It is an error to call this unless has_num_channels() returns true.

Definition at line 146 of file textureProperties.cxx.

References _effective_num_channels, _got_num_channels, _num_channels, and nassertv.

Referenced by TextureImage::copy_unplaced().

string TextureProperties::get_string  )  const
 

Returns a string corresponding to the TextureProperties object.

Each unique set of TextureProperties will generate a unique string. This is used to generate unique palette image filenames.

Definition at line 256 of file textureProperties.cxx.

References _force_format, _got_num_channels, _num_channels, EggTexture::F_rgb, EggTexture::F_rgb12, EggTexture::F_rgb332, EggTexture::F_rgb5, EggTexture::F_rgb8, EggTexture::F_rgba, EggTexture::F_rgba12, EggTexture::F_rgba4, EggTexture::F_rgba5, EggTexture::F_rgba8, EggTexture::F_rgbm, and EggTexture::F_unspecified.

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

Reimplemented from TypedWritable.

Definition at line 121 of file textureProperties.h.

string TextureProperties::get_type_string PNMFileType color_type,
PNMFileType alpha_type
[static, private]
 

Returns a short string representing whether the color and/or alpha type has been specified or not.

Definition at line 780 of file textureProperties.cxx.

References writer().

bool TextureProperties::has_num_channels  )  const
 

Returns true if the number of channels is known.

Definition at line 129 of file textureProperties.cxx.

References _effective_num_channels, _got_num_channels, and _num_channels.

Referenced by TextureImage::copy_unplaced(), and ImageFile::get_x_size().

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

Reimplemented from TypedWritable.

Definition at line 116 of file textureProperties.h.

References _type_handle.

TypedWritable * TextureProperties::make_TextureProperties 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 945 of file textureProperties.cxx.

Referenced by get_anisotropic_degree_string().

bool TextureProperties::operator!= const TextureProperties &  other  )  const
 

Definition at line 636 of file textureProperties.cxx.

bool TextureProperties::operator< const TextureProperties &  other  )  const
 

Definition at line 586 of file textureProperties.cxx.

References EggTexture::F_luminance_alpha, EggTexture::F_luminance_alphamask, EggTexture::F_rgb, EggTexture::F_rgb12, EggTexture::F_rgb332, EggTexture::F_rgb5, EggTexture::F_rgb8, EggTexture::F_rgba12, EggTexture::F_rgba4, EggTexture::F_rgba5, and EggTexture::F_rgba8.

void TextureProperties::operator= const TextureProperties &  copy  ) 
 

Definition at line 85 of file textureProperties.cxx.

References _effective_num_channels, _format, and _num_channels.

bool TextureProperties::operator== const TextureProperties &  other  )  const
 

Definition at line 618 of file textureProperties.cxx.

References EggTexture::F_alpha, EggTexture::F_blue, EggTexture::F_green, EggTexture::F_luminance, and EggTexture::F_red.

void TextureProperties::register_with_read_factory void   )  [static]
 

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

Definition at line 864 of file textureProperties.cxx.

void TextureProperties::set_num_channels int  num_channels  ) 
 

Sets the number of channels (1 through 4) associated with the image, presumably after reading this information from the image header.

Definition at line 164 of file textureProperties.cxx.

References _effective_num_channels, _got_num_channels, _num_channels, and nassertv.

Referenced by TextureImage::mark_eggs_stale().

EggTexture::FilterType TextureProperties::union_filter EggTexture::FilterType  a,
EggTexture::FilterType  b
[static, private]
 

Returns the EggTexture filter type which is the more specific of the two.

Definition at line 845 of file textureProperties.cxx.

References _anisotropic_degree, _effective_num_channels, _force_format, _format, _generic_format, _got_num_channels, _magfilter, _minfilter, _num_channels, Palettizer::_read_pi_version, TypedWritable::fillin(), DatagramIterator::get_bool(), and DatagramIterator::get_int32().

EggTexture::Format TextureProperties::union_format EggTexture::Format  a,
EggTexture::Format  b
[static, private]
 

Returns the EggTexture format which is the more specific of the two.

Definition at line 801 of file textureProperties.cxx.

References _alpha_type, _color_type, TypedWritable::complete_pointers(), DCAST_INTO_R, and NULL.

void TextureProperties::update_egg_tex EggTexture egg_tex  )  const
 

Adjusts the texture properties of the indicated egg reference to match these properties.

Definition at line 549 of file textureProperties.cxx.

References _alpha_type, _anisotropic_degree, _color_type, _format, _magfilter, _minfilter, and NULL.

void TextureProperties::update_properties const TextureProperties &  other  ) 
 

If the indicate TextureProperties structure is more specific than this one, updates this one.

Definition at line 284 of file textureProperties.cxx.

References _num_channels, EggTexture::F_alpha, EggTexture::F_blue, EggTexture::F_green, EggTexture::F_luminance, EggTexture::F_luminance_alpha, EggTexture::F_luminance_alphamask, and EggTexture::F_red.

bool TextureProperties::uses_alpha  )  const
 

Returns true if the texture uses an alpha channel, false otherwise.

Definition at line 221 of file textureProperties.cxx.

Referenced by ImageFile::set_filename().

void TextureProperties::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 882 of file textureProperties.cxx.


Member Data Documentation

PNMFileType* TextureProperties::_alpha_type
 

Definition at line 80 of file textureProperties.h.

Referenced by ImageFile::exists(), ImageFile::set_filename(), TextureProperties(), union_format(), and update_egg_tex().

int TextureProperties::_anisotropic_degree
 

Definition at line 78 of file textureProperties.h.

Referenced by force_nonalpha(), TextureProperties(), union_filter(), and update_egg_tex().

PNMFileType* TextureProperties::_color_type
 

Definition at line 79 of file textureProperties.h.

Referenced by ImageFile::exists(), TextureProperties(), union_format(), update_egg_tex(), and ImageFile::update_properties().

int TextureProperties::_effective_num_channels [private]
 

Definition at line 97 of file textureProperties.h.

Referenced by force_nonalpha(), get_num_channels(), has_num_channels(), operator=(), set_num_channels(), and union_filter().

bool TextureProperties::_force_format
 

Definition at line 75 of file textureProperties.h.

Referenced by get_string(), TextureProperties(), and union_filter().

EggTexture::Format TextureProperties::_format
 

Definition at line 74 of file textureProperties.h.

Referenced by TextureMemoryCounter::add_texture(), force_nonalpha(), fully_define(), operator=(), union_filter(), and update_egg_tex().

bool TextureProperties::_generic_format
 

Definition at line 76 of file textureProperties.h.

Referenced by TextureProperties(), and union_filter().

bool TextureProperties::_got_num_channels [private]
 

Definition at line 95 of file textureProperties.h.

Referenced by clear_basic(), get_num_channels(), get_string(), has_num_channels(), set_num_channels(), and union_filter().

EggTexture::FilterType TextureProperties::_magfilter
 

Definition at line 77 of file textureProperties.h.

Referenced by force_nonalpha(), TextureProperties(), union_filter(), and update_egg_tex().

EggTexture::FilterType TextureProperties::_minfilter
 

Definition at line 77 of file textureProperties.h.

Referenced by force_nonalpha(), TextureProperties(), union_filter(), and update_egg_tex().

int TextureProperties::_num_channels [private]
 

Definition at line 96 of file textureProperties.h.

Referenced by get_num_channels(), get_string(), has_num_channels(), operator=(), set_num_channels(), union_filter(), and update_properties().

TypeHandle TextureProperties::_type_handle [static, private]
 

Reimplemented from TypedWritable.

Definition at line 30 of file textureProperties.cxx.

Referenced by init_type().


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