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

pandatool/src/egg-palettize/textureProperties.h

Go to the documentation of this file.
00001 // Filename: textureProperties.h
00002 // Created by:  drose (28Nov00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef TEXTUREPROPERTIES_H
00020 #define TEXTUREPROPERTIES_H
00021 
00022 #include "pandatoolbase.h"
00023 
00024 #include "eggTexture.h"
00025 #include "typedWritable.h"
00026 
00027 class PNMFileType;
00028 class FactoryParams;
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //       Class : TextureProperties
00032 // Description : This is the set of characteristics of a texture that,
00033 //               if different from another texture, prevent the two
00034 //               textures from sharing a PaletteImage.  It includes
00035 //               properties such as mipmapping, number of channels,
00036 //               etc.
00037 ////////////////////////////////////////////////////////////////////
00038 class TextureProperties : public TypedWritable {
00039 public:
00040   TextureProperties();
00041   TextureProperties(const TextureProperties &copy);
00042   void operator = (const TextureProperties &copy);
00043 
00044   void clear_basic();
00045 
00046   bool has_num_channels() const;
00047   int get_num_channels() const;
00048   void set_num_channels(int num_channels);
00049   void force_grayscale();
00050   void force_nonalpha();
00051   bool uses_alpha() const;
00052 
00053   string get_string() const;
00054   void update_properties(const TextureProperties &other);
00055   void fully_define();
00056 
00057   void update_egg_tex(EggTexture *egg_tex) const;
00058   bool egg_properties_match(const TextureProperties &other) const;
00059 
00060   bool operator < (const TextureProperties &other) const;
00061   bool operator == (const TextureProperties &other) const;
00062   bool operator != (const TextureProperties &other) const;
00063 
00064   EggTexture::Format _format;
00065   bool _force_format;  // true when format has been explicitly specified
00066   bool _generic_format; // true if 'generic' keyword, meaning rgba8 -> rgba.
00067   EggTexture::FilterType _minfilter, _magfilter;
00068   int _anisotropic_degree;
00069   PNMFileType *_color_type;
00070   PNMFileType *_alpha_type;
00071 
00072 private:
00073   static string get_format_string(EggTexture::Format format);
00074   static string get_filter_string(EggTexture::FilterType filter_type);
00075   static string get_anisotropic_degree_string(int aniso_degree);
00076   static string get_type_string(PNMFileType *color_type,
00077                                 PNMFileType *alpha_type);
00078 
00079   static EggTexture::Format union_format(EggTexture::Format a,
00080                                          EggTexture::Format b);
00081 
00082   static EggTexture::FilterType union_filter(EggTexture::FilterType a,
00083                                              EggTexture::FilterType b);
00084 
00085   bool _got_num_channels;
00086   int _num_channels;
00087   int _effective_num_channels;
00088 
00089   // The TypedWritable interface follows.
00090 public:
00091   static void register_with_read_factory();
00092   virtual void write_datagram(BamWriter *writer, Datagram &datagram);
00093   virtual int complete_pointers(TypedWritable **p_list,
00094                                 BamReader *manager);
00095 
00096 protected:
00097   static TypedWritable *make_TextureProperties(const FactoryParams &params);
00098 
00099 public:
00100   void fillin(DatagramIterator &scan, BamReader *manager);
00101 
00102 public:
00103   static TypeHandle get_class_type() {
00104     return _type_handle;
00105   }
00106   static void init_type() {
00107     TypedWritable::init_type();
00108     register_type(_type_handle, "TextureProperties",
00109                   TypedWritable::get_class_type());
00110   }
00111   virtual TypeHandle get_type() const {
00112     return get_class_type();
00113   }
00114 
00115 private:
00116   static TypeHandle _type_handle;
00117 };
00118 
00119 #endif
00120 

Generated on Fri May 2 03:18:29 2003 for Panda-Tool by doxygen1.3