Panda3D
Loading...
Searching...
No Matches
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
24class PaletteGroup;
25class PaletteImage;
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 */
33class PalettePage : public TypedWritable, public Namable {
34private:
36
37public:
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();
52 void update_images(bool redo_all);
53
54private:
55 PaletteGroup *_group;
56 TextureProperties _properties;
57
59 Assigned _assigned;
60
62 Images _images;
63
64 // The TypedWritable interface follows.
65public:
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
71protected:
72 static TypedWritable *make_PalettePage(const FactoryParams &params);
73 void fillin(DatagramIterator &scan, BamReader *manager);
74
75private:
76 // This value is only filled in while reading from the bam file; don't use
77 // it otherwise.
78 int _num_images;
79
80public:
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
95private:
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...
A base class for all things which can have a name.
Definition namable.h:26
This is the highest level of grouping for TextureImages.
This is a single palette image, one of several within a PalettePage, which is in turn one of several ...
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.
void place_all()
Assigns all the textures to their final home in a PaletteImage somewhere.
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.
PaletteGroup * get_group() const
Returns the group this particular PalettePage belongs to.
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.
This is our own Panda specialization on the default STL vector.
Definition pvector.h:42
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(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.