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