15 #include "palettePage.h"
16 #include "texturePlacement.h"
17 #include "textureImage.h"
18 #include "paletteImage.h"
19 #include "paletteGroup.h"
23 #include "datagramIterator.h"
24 #include "bamReader.h"
25 #include "bamWriter.h"
49 Namable(properties.get_string()),
51 _properties(properties)
85 _assigned.push_back(placement);
101 Assigned::const_iterator ai;
102 for (ai = _assigned.begin(); ai != _assigned.end(); ++ai) {
113 for (ii = _images.begin(); ii != _images.end(); ++ii) {
131 for (ii = _images.begin(); ii != _images.end(); ++ii) {
133 if (image->
place(placement)) {
140 _images.push_back(image);
142 bool placed = image->
place(placement);
170 Images::const_iterator ii;
171 for (ii = _images.begin(); ii != _images.end(); ++ii) {
174 indent(out, indent_level);
191 for (ii = _images.begin(); ii != _images.end(); ++ii) {
207 for (ii = _images.begin(); ii != _images.end(); ++ii) {
227 for (ii = _images.begin(); ii != _images.end(); ++ii) {
242 for (ii = _images.begin(); ii != _images.end(); ++ii) {
257 register_factory(get_class_type(), make_PalettePage);
278 Images::const_iterator ii;
279 for (ii = _images.begin(); ii != _images.end(); ++ii) {
298 DCAST_INTO_R(_group, p_list[pi], pi);
305 _images.reserve(_num_images);
306 for (i = 0; i < _num_images; i++) {
308 DCAST_INTO_R(image, p_list[pi++], pi);
309 _images.push_back(image);
329 parse_params(params, scan, manager);
330 me->fillin(scan, manager);
347 _properties.
fillin(scan, manager);
void add_string(const string &str)
Adds a variable-length string to the datagram.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
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...
bool is_placed() const
Returns true if the texture has been placed on a palette image, false otherwise.
Base class for objects that can be written to and read from Bam files.
This is the highest level of grouping for TextureImages.
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 place_all()
Assigns all the textures to their final home in a PaletteImage somewhere.
void write_placements(ostream &out, int indent_level=0) const
Writes a list of the textures that have been placed on this image to the indicated output stream...
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 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 ...
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...
void output_filename(ostream &out) const
Writes the filename (or pair of filenames) to the indicated output stream.
PN_uint32 get_uint32()
Extracts an unsigned 32-bit integer.
string get_string()
Extracts a variable-length string.
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PaletteGroup * get_group() const
Returns the group this particular PalettePage belongs to.
bool place(TexturePlacement *placement)
Attempts to place the indicated texture on the image.
void unplace(TexturePlacement *placement)
Removes the TexturePlacement from wherever it has been placed.
void optimal_resize()
Attempts to resize the palette image to as small as it can go.
A base class for all things which can have a name.
void check_solitary()
To be called after all textures have been placed on the image, this checks to see if there is only on...
bool is_empty() const
Returns true if there are no textures, or only one "solitary" texture, placed on the image...
OmitReason get_omit_reason() const
Returns the reason the texture has been omitted from a palette image, or OR_none if it has not...
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
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.
void reset_image()
Unpacks each texture that has been placed on this image, resetting the image to empty.
void read_pointers(DatagramIterator &scan, int count)
A convenience function to read a contiguous list of pointers.
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.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
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.
PalettePage * get_page() const
Returns the particular PalettePage on which the texture has been placed.
const TextureProperties & get_properties() const
Returns the texture grouping properties that all textures in this page share.
void fillin(DatagramIterator &scan, BamReader *manager)
Reads the binary data from the given datagram iterator, which was written by a previous call to write...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
void reset_images()
Throws away all of the current PaletteImages, so that new ones may be created (and the packing made m...
PaletteImage * get_image() const
Returns the particular PaletteImage on which the texture has been placed.
void add_uint32(PN_uint32 value)
Adds an unsigned 32-bit integer to the datagram.
void setup_shadow_image()
Ensures the _shadow_image has the correct filename and image types, based on what was supplied on the...
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 ...
void unplace(TexturePlacement *placement)
Removes the texture from the image.
A class to retrieve the individual data elements previously stored in a Datagram. ...
void update_image(bool redo_all)
If the palette has changed since it was last written out, updates the image and writes out a new one...
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
void read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
This is the set of characteristics of a texture that, if different from another texture, prevent the two textures from sharing a PaletteImage.