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