From 07d379e231f992f3e79380e6f69d29a9d91c72f5 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 8 Dec 2000 04:48:32 +0000 Subject: [PATCH] *** empty log message *** --- .../src/egg-palettize/destTextureImage.cxx | 3 +- pandatool/src/egg-palettize/eggPalettize.cxx | 52 ++++++++++++++++++- pandatool/src/egg-palettize/imageFile.cxx | 12 ++--- pandatool/src/egg-palettize/imageFile.h | 2 +- 4 files changed, 59 insertions(+), 10 deletions(-) diff --git a/pandatool/src/egg-palettize/destTextureImage.cxx b/pandatool/src/egg-palettize/destTextureImage.cxx index 05660dd7ce..33df92624d 100644 --- a/pandatool/src/egg-palettize/destTextureImage.cxx +++ b/pandatool/src/egg-palettize/destTextureImage.cxx @@ -49,8 +49,7 @@ DestTextureImage(TexturePlacement *placement) { //////////////////////////////////////////////////////////////////// void DestTextureImage:: copy(TextureImage *texture) { - PNMImage image = texture->get_dest_image(); - write(image); + write(texture->get_dest_image()); } //////////////////////////////////////////////////////////////////// diff --git a/pandatool/src/egg-palettize/eggPalettize.cxx b/pandatool/src/egg-palettize/eggPalettize.cxx index b1876d38ea..407efa0511 100644 --- a/pandatool/src/egg-palettize/eggPalettize.cxx +++ b/pandatool/src/egg-palettize/eggPalettize.cxx @@ -313,6 +313,55 @@ describe_input_file() { "also be overridden for a particular texture using the 'coverage' " "keyword on the texture line.\n\n"); + show_text(" :round fraction fuzz", 10, + "When the coverage area is computed, it may optionally be " + "rounded up to the next sizeable unit before placing the " + "texture within the palette. This helps reduce constant " + "repalettization caused by slight differences in coverage " + "between egg files. For instance, say file a.egg references a " + "texture with a coverage of 0.91, and then later file b.egg " + "is discovered to reference the same texture with a coverage of " + "0.92. If the texture was already palettized with the original " + "coverage of 0.91, it must now be moved in the palette.\n\n" + + "Rounding the coverage area up to some fixed unit reduces this " + "problem. For instance, if you specified a value 0.5 for " + "fraction in the above command, it would round both of these " + "values up to the next half-unit, or 1.0.\n\n" + + "The second number is a fuzz factor, and should be a small " + "number; if the coverage area is just slightly larger than " + "the last unit (within the fuzz factor), it is rounded down " + "instead of up. This is intended to prevent UV coordinates " + "that are just slightly out of the range [0, 1] (which happens " + "fairly often) from forcing the palettization area all the " + "way up to the next stop.\n\n" + + "The default if this is unspecified is 0.1 0.01. That is, " + "round up to the next tenth, unless within a hundredth of the " + "last tenth. To disable rounding, specify ':round no'.\n\n"); + + show_text(" :remap (never | group | poly)", 10, + "Sometimes two different parts of an egg file may reference " + "different regions of a repeating texture. For instance, " + "group A may reference UV coordinate values ranging from (0,5) " + "to (1,6), for a coverage of 1.0, while group B references " + "values ranging from (0,2) to (1,4), for a coverage of 2.0. " + "The maximum coverage used is only 2.0, and thus the texture " + "only needs to appear in the palette once, but the total range " + "of UV's is from (0,2) to (1,6), causing an apparent coverage " + "of 4.0.\n\n" + + "It's possible for egg-palettize to reduce this kind of mistake " + "by remapping both groups of UV's so that they overlap. This " + "parameter specifies how this operation should be done. If " + "the option is 'never', remapping will not be performed; if " + "'group', entire groups will be remapped as a unit, of 'poly', " + "individual polygons within a group may be remapped. This last " + "option provides the greatest minimization of UV coverage, " + "but possibly at the expense of triangle strips in the resulting " + "model (since some vertices can no longer be shared).\n\n"); + show_text(" :imagetype type[,alpha_type]", 10, "This specifies the default type of image file that should be " "generated for each palette image and for each unplaced texture " @@ -357,9 +406,10 @@ describe_input_file() { "assigned to one of this group's dependent groups, it will " "be considered to be assigned to this group.\n\n"); + nout << "Comments may appear freely throughout the file, and are set off by a " - "hash mark (#).\n"; + "hash mark (#).\n\n"; } diff --git a/pandatool/src/egg-palettize/imageFile.cxx b/pandatool/src/egg-palettize/imageFile.cxx index ca60b39869..4d552f15d3 100644 --- a/pandatool/src/egg-palettize/imageFile.cxx +++ b/pandatool/src/egg-palettize/imageFile.cxx @@ -285,12 +285,10 @@ read(PNMImage &image) const { // Access: Public // Description: Writes out the image in the indicated PNMImage to the // _filename and/or _alpha_filename. Returns true on -// success, false on failure. Warning: this may change -// the PNMImage. In particular, it may remove the alpha -// channel. +// success, false on failure. //////////////////////////////////////////////////////////////////// bool ImageFile:: -write(PNMImage &image) const { +write(const PNMImage &image) const { nassertr(!_filename.empty(), false); if (!image.has_alpha() || @@ -317,13 +315,15 @@ write(PNMImage &image) const { } } - image.remove_alpha(); + PNMImage image_copy(image); + image_copy.remove_alpha(); nout << "Writing " << FilenameUnifier::make_user_filename(_filename) << "\n"; _filename.make_dir(); - if (!image.write(_filename, _properties._color_type)) { + if (!image_copy.write(_filename, _properties._color_type)) { nout << "Unable to write.\n"; return false; } + nout << "Writing " << FilenameUnifier::make_user_filename(_alpha_filename) << "\n"; _alpha_filename.make_dir(); if (!alpha_image.write(_alpha_filename, _properties._alpha_type)) { diff --git a/pandatool/src/egg-palettize/imageFile.h b/pandatool/src/egg-palettize/imageFile.h index 8277ec4ece..9821c4fb69 100644 --- a/pandatool/src/egg-palettize/imageFile.h +++ b/pandatool/src/egg-palettize/imageFile.h @@ -46,7 +46,7 @@ public: bool exists() const; bool read(PNMImage &image) const; - bool write(PNMImage &image) const; + bool write(const PNMImage &image) const; void unlink(); void update_egg_tex(EggTexture *egg_tex) const;