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

pandatool/src/egg-palettize/paletteGroup.h

Go to the documentation of this file.
00001 // Filename: paletteGroup.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 PALETTEGROUP_H
00020 #define PALETTEGROUP_H
00021 
00022 #include "pandatoolbase.h"
00023 
00024 #include "paletteGroups.h"
00025 #include "textureProperties.h"
00026 
00027 #include "namable.h"
00028 #include "typedWritable.h"
00029 
00030 #include "pset.h"
00031 #include "pvector.h"
00032 
00033 class EggFile;
00034 class TexturePlacement;
00035 class PalettePage;
00036 class TextureImage;
00037 class TxaFile;
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //       Class : PaletteGroup
00041 // Description : This is the highest level of grouping for
00042 //               TextureImages.  Textures are assigned to one or
00043 //               several PaletteGroups based on the information in the
00044 //               .txa file; each PaletteGroup is conceptually a
00045 //               collection of textures that are to be moved around
00046 //               (into texture memory, downloaded, etc.) in one big
00047 //               chunk.  It is the set of all textures that may be
00048 //               displayed together at any given time.
00049 ////////////////////////////////////////////////////////////////////
00050 class PaletteGroup : public TypedWritable, public Namable {
00051 public:
00052   PaletteGroup();
00053 
00054   void set_dirname(const string &dirname);
00055   bool has_dirname() const;
00056   const string &get_dirname() const;
00057 
00058   void clear_depends();
00059   void group_with(PaletteGroup *other);
00060   const PaletteGroups &get_groups() const;
00061 
00062   void get_placements(pvector<TexturePlacement *> &placements) const;
00063   void get_complete_placements(pvector<TexturePlacement *> &placements) const;
00064 
00065   void reset_dependency_level();
00066   void set_dependency_level(int level);
00067   bool set_dependency_order();
00068   int get_dependency_level() const;
00069   int get_dependency_order() const;
00070   int get_dirname_order() const;
00071 
00072   bool is_preferred_over(const PaletteGroup &other) const;
00073 
00074   void increment_egg_count();
00075   int get_egg_count() const;
00076 
00077   PalettePage *get_page(const TextureProperties &properties);
00078 
00079   TexturePlacement *prepare(TextureImage *texture);
00080 
00081   void unplace(TexturePlacement *placement);
00082 
00083   void place_all();
00084   void update_unknown_textures(const TxaFile &txa_file);
00085 
00086   void write_image_info(ostream &out, int indent_level = 0) const;
00087   void optimal_resize();
00088   void reset_images();
00089   void setup_shadow_images();
00090   void update_images(bool redo_all);
00091 
00092 private:
00093   string _dirname;
00094   int _egg_count;
00095   PaletteGroups _dependent;
00096   int _dependency_level;
00097   int _dependency_order;
00098   int _dirname_order;
00099 
00100   typedef pset<TexturePlacement *> Placements;
00101   Placements _placements;
00102 
00103   typedef pmap<TextureProperties, PalettePage *> Pages;
00104   Pages _pages;
00105 
00106 
00107   // The TypedWritable interface follows.
00108 public:
00109   static void register_with_read_factory();
00110   virtual void write_datagram(BamWriter *writer, Datagram &datagram);
00111   virtual int complete_pointers(TypedWritable **p_list,
00112                                 BamReader *manager);
00113   virtual void finalize();
00114 
00115 protected:
00116   static TypedWritable *make_PaletteGroup(const FactoryParams &params);
00117   void fillin(DatagramIterator &scan, BamReader *manager);
00118 
00119 private:
00120   // These values are only filled in while reading from the bam file;
00121   // don't use them otherwise.
00122   int _num_placements;
00123   int _num_pages;
00124   pvector<PalettePage *> _load_pages;
00125 
00126 public:
00127   static TypeHandle get_class_type() {
00128     return _type_handle;
00129   }
00130   static void init_type() {
00131     TypedWritable::init_type();
00132     Namable::init_type();
00133     register_type(_type_handle, "PaletteGroup",
00134                   TypedWritable::get_class_type(),
00135                   Namable::get_class_type());
00136   }
00137   virtual TypeHandle get_type() const {
00138     return get_class_type();
00139   }
00140 
00141 private:
00142   static TypeHandle _type_handle;
00143 
00144   friend class PaletteGroups;
00145 };
00146 
00147 #endif
00148 

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