00001 // Filename: palettePage.h 00002 // Created by: drose (01Dec00) 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 PALETTEPAGE_H 00020 #define PALETTEPAGE_H 00021 00022 #include "pandatoolbase.h" 00023 00024 #include "textureProperties.h" 00025 00026 #include "namable.h" 00027 #include "typedWritable.h" 00028 00029 class PaletteGroup; 00030 class PaletteImage; 00031 class TexturePlacement; 00032 00033 //////////////////////////////////////////////////////////////////// 00034 // Class : PalettePage 00035 // Description : This is a particular collection of textures, within a 00036 // PaletteGroup, that all share the same 00037 // TextureProperties. The textures on the same page may 00038 // therefore all be placed on the same set of 00039 // PaletteImages together. 00040 //////////////////////////////////////////////////////////////////// 00041 class PalettePage : public TypedWritable, public Namable { 00042 private: 00043 PalettePage(); 00044 00045 public: 00046 PalettePage(PaletteGroup *group, const TextureProperties &properties); 00047 00048 PaletteGroup *get_group() const; 00049 const TextureProperties &get_properties() const; 00050 00051 void assign(TexturePlacement *placement); 00052 void place_all(); 00053 void place(TexturePlacement *placement); 00054 void unplace(TexturePlacement *placement); 00055 00056 void write_image_info(ostream &out, int indent_level = 0) const; 00057 void optimal_resize(); 00058 void reset_images(); 00059 void setup_shadow_images(); 00060 void update_images(bool redo_all); 00061 00062 private: 00063 PaletteGroup *_group; 00064 TextureProperties _properties; 00065 00066 typedef pvector<TexturePlacement *> Assigned; 00067 Assigned _assigned; 00068 00069 typedef pvector<PaletteImage *> Images; 00070 Images _images; 00071 00072 // The TypedWritable interface follows. 00073 public: 00074 static void register_with_read_factory(); 00075 virtual void write_datagram(BamWriter *writer, Datagram &datagram); 00076 virtual int complete_pointers(TypedWritable **p_list, 00077 BamReader *manager); 00078 00079 protected: 00080 static TypedWritable *make_PalettePage(const FactoryParams ¶ms); 00081 void fillin(DatagramIterator &scan, BamReader *manager); 00082 00083 private: 00084 // This value is only filled in while reading from the bam file; 00085 // don't use it otherwise. 00086 int _num_images; 00087 00088 public: 00089 static TypeHandle get_class_type() { 00090 return _type_handle; 00091 } 00092 static void init_type() { 00093 TypedWritable::init_type(); 00094 Namable::init_type(); 00095 register_type(_type_handle, "PalettePage", 00096 TypedWritable::get_class_type(), 00097 Namable::get_class_type()); 00098 } 00099 virtual TypeHandle get_type() const { 00100 return get_class_type(); 00101 } 00102 00103 private: 00104 static TypeHandle _type_handle; 00105 }; 00106 00107 #endif 00108