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

pandatool/src/egg-palettize/eggFile.h

Go to the documentation of this file.
00001 // Filename: eggFile.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 EGGFILE_H
00020 #define EGGFILE_H
00021 
00022 #include "pandatoolbase.h"
00023 
00024 #include "paletteGroups.h"
00025 #include "textureReference.h"
00026 
00027 #include "filename.h"
00028 #include "namable.h"
00029 #include "typedWritable.h"
00030 
00031 #include "pset.h"
00032 
00033 class EggData;
00034 class TextureImage;
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //       Class : EggFile
00038 // Description : This represents a single egg file known to the
00039 //               palettizer.  It may reference a number of textures,
00040 //               and may also be assigned to a number of groups.  All
00041 //               of its textures will try to assign themselves to one
00042 //               of its groups.
00043 ////////////////////////////////////////////////////////////////////
00044 class EggFile : public TypedWritable, public Namable {
00045 public:
00046   EggFile();
00047 
00048   void from_command_line(EggData *data,
00049                          const Filename &source_filename,
00050                          const Filename &dest_filename,
00051                          const string &egg_comment);
00052 
00053   void scan_textures();
00054   void get_textures(pset<TextureImage *> &result) const;
00055 
00056   void pre_txa_file();
00057   void match_txa_groups(const PaletteGroups &groups);
00058   void post_txa_file();
00059 
00060   const PaletteGroups &get_explicit_groups() const;
00061   PaletteGroup *get_default_group() const;
00062   const PaletteGroups &get_complete_groups() const;
00063   void clear_surprise();
00064   bool is_surprise() const;
00065 
00066   void mark_stale();
00067   bool is_stale() const;
00068 
00069   void build_cross_links();
00070   void apply_properties_to_source();
00071   void choose_placements();
00072 
00073   bool has_data() const;
00074 
00075   void update_egg();
00076   void remove_egg();
00077   bool read_egg();
00078   bool write_egg();
00079 
00080   void write_description(ostream &out, int indent_level = 0) const;
00081   void write_texture_refs(ostream &out, int indent_level = 0) const;
00082 
00083 private:
00084   void remove_backstage(EggGroupNode *node);
00085 
00086 private:
00087   EggData *_data;
00088   Filename _current_directory;
00089   Filename _source_filename;
00090   Filename _dest_filename;
00091   string _egg_comment;
00092 
00093   typedef pvector<TextureReference *> Textures;
00094   Textures _textures;
00095 
00096   bool _first_txa_match;
00097   PaletteGroups _explicitly_assigned_groups;
00098   PaletteGroup *_default_group;
00099   PaletteGroups _complete_groups;
00100   bool _is_surprise;
00101   bool _is_stale;
00102 
00103 
00104   // The TypedWritable interface follows.
00105 public:
00106   static void register_with_read_factory();
00107   virtual void write_datagram(BamWriter *writer, Datagram &datagram);
00108   virtual int complete_pointers(TypedWritable **p_list,
00109                                 BamReader *manager);
00110 
00111 protected:
00112   static TypedWritable *make_EggFile(const FactoryParams &params);
00113   void fillin(DatagramIterator &scan, BamReader *manager);
00114 
00115 private:
00116   // This value is only filled in while reading from the bam file;
00117   // don't use it otherwise.
00118   int _num_textures;
00119 
00120 public:
00121   static TypeHandle get_class_type() {
00122     return _type_handle;
00123   }
00124   static void init_type() {
00125     TypedWritable::init_type();
00126     Namable::init_type();
00127     register_type(_type_handle, "EggFile",
00128                   TypedWritable::get_class_type(),
00129                   Namable::get_class_type());
00130   }
00131   virtual TypeHandle get_type() const {
00132     return get_class_type();
00133   }
00134 
00135 private:
00136   static TypeHandle _type_handle;
00137 };
00138 
00139 #endif
00140 

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