Panda3D
 All Classes Functions Variables Enumerations
eggFile.h
00001 // Filename: eggFile.h
00002 // Created by:  drose (28Nov00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef EGGFILE_H
00016 #define EGGFILE_H
00017 
00018 #include "pandatoolbase.h"
00019 
00020 #include "paletteGroups.h"
00021 #include "textureReference.h"
00022 #include "eggData.h"
00023 #include "filename.h"
00024 #include "namable.h"
00025 #include "typedWritable.h"
00026 #include "pointerTo.h"
00027 #include "pset.h"
00028 
00029 class TextureImage;
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //       Class : EggFile
00033 // Description : This represents a single egg file known to the
00034 //               palettizer.  It may reference a number of textures,
00035 //               and may also be assigned to a number of groups.  All
00036 //               of its textures will try to assign themselves to one
00037 //               of its groups.
00038 ////////////////////////////////////////////////////////////////////
00039 class EggFile : public TypedWritable, public Namable {
00040 public:
00041   EggFile();
00042 
00043   bool from_command_line(EggData *data,
00044                          const Filename &source_filename,
00045                          const Filename &dest_filename,
00046                          const string &egg_comment);
00047 
00048   const Filename &get_source_filename() const;
00049 
00050   void scan_textures();
00051   void get_textures(pset<TextureImage *> &result) const;
00052 
00053   void pre_txa_file();
00054   void match_txa_groups(const PaletteGroups &groups);
00055   void post_txa_file();
00056 
00057   const PaletteGroups &get_explicit_groups() const;
00058   PaletteGroup *get_default_group() const;
00059   const PaletteGroups &get_complete_groups() const;
00060   void clear_surprise();
00061   bool is_surprise() const;
00062 
00063   void mark_stale();
00064   bool is_stale() const;
00065 
00066   void build_cross_links();
00067   void apply_properties_to_source();
00068   void choose_placements();
00069 
00070   bool has_data() const;
00071   bool had_data() const;
00072 
00073   void update_egg();
00074   void remove_egg();
00075   bool read_egg(bool noabs);
00076   void release_egg_data();
00077   bool write_egg();
00078 
00079   void write_description(ostream &out, int indent_level = 0) const;
00080   void write_texture_refs(ostream &out, int indent_level = 0) const;
00081 
00082 private:
00083   void remove_backstage(EggGroupNode *node);
00084   void rescan_textures();
00085 
00086 private:
00087   PT(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 _noabs;
00097   bool _first_txa_match;
00098   PaletteGroups _explicitly_assigned_groups;
00099   PaletteGroup *_default_group;
00100   PaletteGroups _complete_groups;
00101   bool _is_surprise;
00102   bool _is_stale;
00103   bool _had_data;
00104 
00105 
00106   // The TypedWritable interface follows.
00107 public:
00108   static void register_with_read_factory();
00109   virtual void write_datagram(BamWriter *writer, Datagram &datagram);
00110   virtual int complete_pointers(TypedWritable **p_list,
00111                                 BamReader *manager);
00112 
00113 protected:
00114   static TypedWritable *make_EggFile(const FactoryParams &params);
00115   void fillin(DatagramIterator &scan, BamReader *manager);
00116 
00117 private:
00118   // This value is only filled in while reading from the bam file;
00119   // don't use it otherwise.
00120   int _num_textures;
00121 
00122 public:
00123   static TypeHandle get_class_type() {
00124     return _type_handle;
00125   }
00126   static void init_type() {
00127     TypedWritable::init_type();
00128     Namable::init_type();
00129     register_type(_type_handle, "EggFile",
00130                   TypedWritable::get_class_type(),
00131                   Namable::get_class_type());
00132   }
00133   virtual TypeHandle get_type() const {
00134     return get_class_type();
00135   }
00136 
00137 private:
00138   static TypeHandle _type_handle;
00139 };
00140 
00141 #endif
00142 
 All Classes Functions Variables Enumerations