40 _dependency_level = 0;
41 _dependency_order = 0;
43 _has_margin_override =
false;
63 return !_dirname.empty();
81 _dependency_level = 0;
82 _dependency_order = 0;
111 return _margin_override;
119 _margin_override =
override;
120 _has_margin_override =
true;
128 return _has_margin_override;
139 Placements::const_iterator pi;
140 for (pi = _placements.begin(); pi != _placements.end(); ++pi) {
141 placements.push_back(*pi);
154 PaletteGroups::iterator gi;
155 for (gi = complete.
begin(); gi != complete.
end(); ++gi) {
170 _dependency_level = 0;
171 _dependency_order = 0;
185 if (level > _dependency_level) {
186 _dependency_level = level;
187 PaletteGroups::iterator gi;
188 for (gi = _dependent.
begin(); gi != _dependent.
end(); ++gi) {
205 bool any_changed =
false;
207 PaletteGroups::iterator gi;
208 for (gi = _dependent.
begin(); gi != _dependent.
end(); ++gi) {
254 return _dependency_level;
269 return _dependency_order;
283 return _dirname_order;
329 Pages::iterator pi = _pages.find(properties);
330 if (pi != _pages.end()) {
335 bool inserted = _pages.insert(Pages::value_type(properties, page)).second;
336 nassertr(inserted, page);
349 _placements.insert(placement);
352 TextureSwapInfo::iterator tsi = _textureSwapInfo.find(texture->get_name());
353 if (tsi != _textureSwapInfo.end()) {
354 vector_string swapTextures = (*tsi).second;
356 vector_string::const_iterator wi;
357 wi = swapTextures.begin();
363 const string originalTextureName = (*wi);
371 while (wi != swapTextures.end()) {
372 const string &swapTextureName = (*wi);
375 swapTextureImage->
get_source(swapTextureFilename, originalTextureAlphaFilename, originalTextureAlphaFileChannel);
376 placement->_textureSwaps.push_back(swapTextureImage);
390 nassertv(placement->
get_group() ==
this);
392 Placements::iterator pi;
393 pi = _placements.find(placement);
394 if (pi != _placements.end()) {
395 _placements.erase(pi);
411 Placements::iterator pli;
412 for (pli = _placements.begin(); pli != _placements.end(); ++pli) {
423 for (pai = _pages.begin(); pai != _pages.end(); ++pai) {
436 Placements::iterator pli;
437 for (pli = _placements.begin(); pli != _placements.end(); ++pli) {
461 Pages::const_iterator pai;
462 for (pai = _pages.begin(); pai != _pages.end(); ++pai) {
469 placement_vector.reserve(_placements.size());
470 Placements::const_iterator pli;
471 for (pli = _placements.begin(); pli != _placements.end(); ++pli) {
474 placement_vector.push_back(placement);
477 sort(placement_vector.begin(), placement_vector.end(),
481 for (pvi = placement_vector.begin();
482 pvi != placement_vector.end();
488 <<
" unplaced because ";
491 out <<
"coverage (" << placement->
get_uv_area() <<
")";
495 out <<
"size (" << placement->
get_x_size() <<
" "
512 for (pai = _pages.begin(); pai != _pages.end(); ++pai) {
525 for (pai = _pages.begin(); pai != _pages.end(); ++pai) {
539 for (pai = _pages.begin(); pai != _pages.end(); ++pai) {
551 for (pai = _pages.begin(); pai != _pages.end(); ++pai) {
563 register_factory(get_class_type(), make_PaletteGroup);
582 Placements::const_iterator pli;
583 for (pli = _placements.begin(); pli != _placements.end(); ++pli) {
588 Pages::const_iterator pai;
589 for (pai = _pages.begin(); pai != _pages.end(); ++pai) {
592 datagram.
add_bool(_has_margin_override);
610 for (i = 0; i < _num_placements; i++) {
612 DCAST_INTO_R(placement, p_list[pi++], pi);
613 bool inserted = _placements.insert(placement).second;
614 nassertr(inserted, pi);
621 _load_pages.reserve(_num_pages);
622 for (i = 0; i < _num_pages; i++) {
624 DCAST_INTO_R(page, p_list[pi++], pi);
625 _load_pages.push_back(page);
641 for (pi = _load_pages.begin(); pi != _load_pages.end(); ++pi) {
643 bool inserted = _pages.
663 me->fillin(scan, manager);
677 _dependent.
fillin(scan, manager);
689 if(Palettizer::_read_pi_version >= 19) {
690 _has_margin_override = scan.
get_bool();
700 TextureSwapInfo::iterator tsi = _textureSwapInfo.find(sourceTextureName);
701 if (tsi != _textureSwapInfo.end()) {
702 _textureSwapInfo.erase(tsi);
704 _textureSwapInfo.insert(TextureSwapInfo::value_type(sourceTextureName, swapTextures));
712 return _textureSwapInfo.empty();
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void register_finalize(TypedWritable *whom)
Should be called by an object reading itself from the Bam file to indicate that this particular objec...
void read_pointers(DatagramIterator &scan, int count)
A convenience function to read a contiguous list of pointers.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
A class to retrieve the individual data elements previously stored in a Datagram.
int16_t get_int16()
Extracts a signed 16-bit integer.
uint32_t get_uint32()
Extracts an unsigned 32-bit integer.
bool get_bool()
Extracts a boolean value.
std::string get_string()
Extracts a variable-length string.
int32_t get_int32()
Extracts a signed 32-bit integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the datagram.
void add_int16(int16_t value)
Adds a signed 16-bit integer to the datagram.
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
void add_bool(bool value)
Adds a boolean value to the datagram.
void add_string(const std::string &str)
Adds a variable-length string to the datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
The name of a file, such as a texture file or an Egg file.
std::string get_extension() const
Returns the file extension.
std::string get_dirname() const
Returns the directory part of the filename.
const Filename & get_filename() const
Returns the primary filename of the image file.
const Filename & get_alpha_filename() const
Returns the alpha filename of the image file.
int get_alpha_file_channel() const
Returns the particular channel number of the alpha image file from which the alpha channel should be ...
An STL function object class, this is intended to be used on any ordered collection of pointers to cl...
This is the highest level of grouping for TextureImages.
void reset_dependency_level()
Unconditionally sets the dependency level and order of this group to zero, in preparation for a later...
void update_images(bool redo_all)
Regenerates each PaletteImage on this group that needs it.
void get_placements(pvector< TexturePlacement * > &placements) const
Adds the set of TexturePlacements associated with this group to the indicated vector.
bool is_none_texture_swap() const
Returns textureswap information is set or not, True if it's not set.
bool has_dirname() const
Returns true if the directory name has been explicitly set for this group.
const PaletteGroups & get_groups() const
Returns the set of groups this group depends on.
static void register_with_read_factory()
Registers the current object as something that can be read from a Bam file.
int get_egg_count() const
Returns the number of egg files that share this PaletteGroup.
void increment_egg_count()
Increments by one the number of egg files that are known to reference this PaletteGroup.
void unplace(TexturePlacement *placement)
Removes the texture from its position on a PaletteImage, if it has been so placed.
void set_dirname(const std::string &dirname)
Sets the directory name associated with the palette group.
void update_unknown_textures(const TxaFile &txa_file)
Checks for new information on any textures within the group for which some of the saved information i...
void setup_shadow_images()
Ensures that each PaletteImage's _shadow_image has the correct filename and image types,...
bool is_preferred_over(const PaletteGroup &other) const
Returns true if this group should be preferred for adding textures over the other group,...
void group_with(PaletteGroup *other)
Indicates a dependency of this group on some other group.
int get_dirname_order() const
Returns the dependency order of this group.
int get_margin_override() const
Returns the set of groups this group depends on.
void write_image_info(std::ostream &out, int indent_level=0) const
Writes a list of the PaletteImages associated with this group, and all of their textures,...
virtual void write_datagram(BamWriter *writer, Datagram &datagram)
Fills the indicated datagram up with a binary representation of the current object,...
void add_texture_swap_info(const std::string sourceTextureName, const vector_string &swapTextures)
Store textureswap information from textures.txa.
bool set_dependency_order()
Updates the dependency order of this group.
TexturePlacement * prepare(TextureImage *texture)
Marks the indicated Texture as ready for placing somewhere within this group, and returns a placehold...
void get_complete_placements(pvector< TexturePlacement * > &placements) const
Adds the set of TexturePlacements associated with this group and all dependent groups to the indicate...
void reset_images()
Throws away all of the current PaletteImages, so that new ones may be created (and the packing made m...
void optimal_resize()
Attempts to resize each PalettteImage down to its smallest possible size.
void clear_depends()
Eliminates all the dependency information for this group.
int get_dependency_level() const
Returns the dependency level of this group.
int get_dependency_order() const
Returns the dependency order of this group.
virtual void finalize(BamReader *manager)
This method is called by the BamReader after all pointers everywhere in the world have been completel...
const std::string & get_dirname() const
Returns the directory name associated with the palette group.
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 set_dependency_level(int level)
Sets the dependency level of this group to the indicated level, provided that level is not lower than...
void place_all()
Once all the textures have been assigned to this group, try to place them all onto suitable PaletteIm...
PalettePage * get_page(const TextureProperties &properties)
Returns the page associated with the indicated properties.
void set_margin_override(const int override)
Returns the set of groups this group depends on.
bool has_margin_override() const
Returns the set of groups this group depends on.
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 make_complete(const PaletteGroups &a)
Completes the set with the transitive closure of all dependencies: for each PaletteGroup already in t...
iterator begin() const
Returns an iterator suitable for traversing the set.
void insert(PaletteGroup *group)
Inserts a new group to the set, if it is not already there.
void clear()
Empties the set.
virtual void write_datagram(BamWriter *writer, Datagram &datagram)
Fills the indicated datagram up with a binary representation of the current object,...
iterator end() const
Returns an iterator suitable for traversing the set.
void fillin(DatagramIterator &scan, BamReader *manager)
Reads the binary data from the given datagram iterator, which was written by a previous call to write...
This is a particular collection of textures, within a PaletteGroup, that all share the same TexturePr...
void optimal_resize()
Attempts to resize each PalettteImage down to its smallest possible size.
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.
TextureImage * get_texture(const std::string &name)
Returns the TextureImage with the given name.
This is a texture image reference as it appears in an egg file: the source image of the texture.
This represents a single source texture that is referenced by one or more egg files.
bool got_txa_file() const
Returns true if this TextureImage has been looked up in the .txa file this session,...
void pre_txa_file()
Updates any internal state prior to reading the .txa file.
SourceTextureImage * get_preferred_source()
Determines the preferred source image for examining size and reading pixels, etc.
void post_txa_file()
Once the .txa file has been read and the TextureImage matched against it, considers applying the requ...
SourceTextureImage * get_source(const Filename &filename, const Filename &alpha_filename, int alpha_file_channel)
Returns the SourceTextureImage corresponding to the given filename(s).
This corresponds to a particular assignment of a TextureImage with a PaletteGroup,...
OmitReason get_omit_reason() const
Returns the reason the texture has been omitted from a palette image, or OR_none if it has not.
PaletteGroup * get_group() const
Returns the group that this placement represents.
bool is_size_known() const
Returns true if the texture's size is known, false otherwise.
int get_x_size() const
Returns the size in the X dimension, in pixels, of the texture image as it must appear in the palette...
double get_uv_area() const
Returns the total area of the rectangle occupied by the UV minmax box, in UV coordinates.
const TextureProperties & get_properties() const
Returns the grouping properties of the image.
bool is_placed() const
Returns true if the texture has been placed on a palette image, false otherwise.
TextureImage * get_texture() const
Returns the texture that this placement represents.
bool determine_size()
Attempts to determine the appropriate size of the texture for the given placement.
PalettePage * get_page() const
Returns the particular PalettePage on which the texture has been placed.
int get_y_size() const
Returns the size in the Y dimension, in pixels, of the texture image as it must appear in the palette...
This is the set of characteristics of a texture that, if different from another texture,...
This represents the .txa file (usually textures.txa) that contains the user instructions for resizing...
bool match_texture(TextureImage *texture) const
Searches for a matching line in the .txa file for the given texture and applies its specifications.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
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.
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().
This is our own Panda specialization on the default STL vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.