Panda3D
 All Classes Functions Variables Enumerations
palettePage.h
1 // Filename: palettePage.h
2 // Created by: drose (01Dec00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PALETTEPAGE_H
16 #define PALETTEPAGE_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "textureProperties.h"
21 
22 #include "namable.h"
23 #include "typedWritable.h"
24 
25 class PaletteGroup;
26 class PaletteImage;
27 class TexturePlacement;
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : PalettePage
31 // Description : This is a particular collection of textures, within a
32 // PaletteGroup, that all share the same
33 // TextureProperties. The textures on the same page may
34 // therefore all be placed on the same set of
35 // PaletteImages together.
36 ////////////////////////////////////////////////////////////////////
37 class PalettePage : public TypedWritable, public Namable {
38 private:
39  PalettePage();
40 
41 public:
42  PalettePage(PaletteGroup *group, const TextureProperties &properties);
43 
44  PaletteGroup *get_group() const;
45  const TextureProperties &get_properties() const;
46 
47  void assign(TexturePlacement *placement);
48  void place_all();
49  void place(TexturePlacement *placement);
50  void unplace(TexturePlacement *placement);
51 
52  void write_image_info(ostream &out, int indent_level = 0) const;
53  void optimal_resize();
54  void reset_images();
55  void setup_shadow_images();
56  void update_images(bool redo_all);
57 
58 private:
59  PaletteGroup *_group;
60  TextureProperties _properties;
61 
63  Assigned _assigned;
64 
66  Images _images;
67 
68  // The TypedWritable interface follows.
69 public:
70  static void register_with_read_factory();
71  virtual void write_datagram(BamWriter *writer, Datagram &datagram);
72  virtual int complete_pointers(TypedWritable **p_list,
73  BamReader *manager);
74 
75 protected:
76  static TypedWritable *make_PalettePage(const FactoryParams &params);
77  void fillin(DatagramIterator &scan, BamReader *manager);
78 
79 private:
80  // This value is only filled in while reading from the bam file;
81  // don't use it otherwise.
82  int _num_images;
83 
84 public:
85  static TypeHandle get_class_type() {
86  return _type_handle;
87  }
88  static void init_type() {
89  TypedWritable::init_type();
90  Namable::init_type();
91  register_type(_type_handle, "PalettePage",
92  TypedWritable::get_class_type(),
93  Namable::get_class_type());
94  }
95  virtual TypeHandle get_type() const {
96  return get_class_type();
97  }
98 
99 private:
100  static TypeHandle _type_handle;
101 };
102 
103 #endif
104 
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Called after the object is otherwise completely read from a Bam file, this function's job is to store...
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the highest level of grouping for TextureImages.
Definition: paletteGroup.h:47
void place_all()
Assigns all the textures to their final home in a PaletteImage somewhere.
Definition: palettePage.cxx:96
void setup_shadow_images()
Ensures that each PaletteImage's _shadow_image has the correct filename and image types...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
void place(TexturePlacement *placement)
Assigns the particular TexturePlacement to a PaletteImage where it fits.
This is a particular collection of textures, within a PaletteGroup, that all share the same TexturePr...
Definition: palettePage.h:37
PaletteGroup * get_group() const
Returns the group this particular PalettePage belongs to.
Definition: palettePage.cxx:62
void unplace(TexturePlacement *placement)
Removes the TexturePlacement from wherever it has been placed.
A base class for all things which can have a name.
Definition: namable.h:29
void update_images(bool redo_all)
Regenerates each PaletteImage on this page that needs it.
static void register_with_read_factory()
Registers the current object as something that can be read from a Bam file.
virtual void write_datagram(BamWriter *writer, Datagram &datagram)
Fills the indicated datagram up with a binary representation of the current object, in preparation for writing to a Bam file.
void assign(TexturePlacement *placement)
Adds the indicated texture to the list of textures to consider placing on the page.
Definition: palettePage.cxx:84
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
void optimal_resize()
Attempts to resize each PalettteImage down to its smallest possible size.
This corresponds to a particular assignment of a TextureImage with a PaletteGroup, and specifically describes which PaletteImage (if any), and where on the PaletteImage, the TextureImage has been assigned to.
const TextureProperties & get_properties() const
Returns the texture grouping properties that all textures in this page share.
Definition: palettePage.cxx:73
void reset_images()
Throws away all of the current PaletteImages, so that new ones may be created (and the packing made m...
void write_image_info(ostream &out, int indent_level=0) const
Writes a list of the PaletteImages associated with this page, and all of their textures, to the indicated output stream.
This is a single palette image, one of several within a PalettePage, which is in turn one of several ...
Definition: paletteImage.h:36
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
This is the set of characteristics of a texture that, if different from another texture, prevent the two textures from sharing a PaletteImage.