*** empty log message ***

This commit is contained in:
David Rose 2000-12-08 03:45:56 +00:00
parent 7c3ddd7643
commit 8cf6081f66
13 changed files with 133 additions and 21 deletions

View File

@ -15,12 +15,13 @@
eggFile.cxx eggFile.h eggPalettize.cxx eggPalettize.h \
filenameUnifier.cxx filenameUnifier.h \
imageFile.cxx imageFile.h omitReason.cxx omitReason.h \
pal_string_utils.cxx pal_string_utils.h \
paletteGroup.h paletteGroup.cxx \
paletteGroups.h paletteGroups.cxx paletteImage.h paletteImage.cxx \
palettePage.cxx palettePage.h \
palettizer.cxx palettizer.h \
sourceTextureImage.cxx sourceTextureImage.h string_utils.cxx \
string_utils.h textureImage.cxx textureImage.h \
sourceTextureImage.cxx sourceTextureImage.h \
textureImage.cxx textureImage.h \
texturePlacement.cxx texturePlacement.h \
texturePosition.cxx texturePosition.h \
textureProperties.cxx textureProperties.h textureReference.cxx \

View File

@ -92,7 +92,15 @@ scan_textures() {
TextureReference *ref = new TextureReference;
ref->from_egg(this, _data, egg_tex);
_textures.push_back(ref);
if (!ref->has_uvs()) {
// This texture isn't *really* referenced. (Usually this
// happens if the texture is only referenced by "backstage"
// geometry, which we don't care about.)
delete ref;
} else {
_textures.push_back(ref);
}
}
}

View File

@ -6,7 +6,7 @@
#include "eggPalettize.h"
#include "palettizer.h"
#include "eggFile.h"
#include "string_utils.h"
#include "pal_string_utils.h"
#include "filenameUnifier.h"
#include <eggData.h>
@ -252,8 +252,17 @@ describe_input_file() {
"to groups; instead, it is more useful to assign the egg files "
"they appear on to groups; see below.\n\n");
show_text(" cont", 10,
"Normally, a texture file (or egg file) scans the lines in the "
"attributes file from the top, and stops on the first line that "
"matches its name. If the keyword 'cont' is included on the "
"line, however, the texture will apply the properties given "
"on the line, and then continue scanning. This trick may be "
"used to specify general parameters for all files while still "
"allowing the texture to match a more specific line below.\n\n");
nout <<
"The attributes file may also assign certain egg files into various "
"The attributes file may also assign egg files to various "
"named palette groups. The syntax is similar to the above:\n\n"
" car-blue.egg : main\n"
@ -263,7 +272,7 @@ describe_input_file() {
"Any number of egg files may be named on one line, and the group of "
"egg files may be simultaneously assigned to one or more groups. "
"The groups are defined using the :group command (see below). "
"The valid set of groups are defined using the :group command (see below). "
"Each texture that is referenced by a given egg file will be palettized "
"into at least one of the groups assigned to the egg file.\n\n"
@ -304,6 +313,31 @@ describe_input_file() {
"also be overridden for a particular texture using the 'coverage' "
"keyword on the texture line.\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 "
"copied into the install directory. This may be overridden for "
"a particular texture by specifying the image type on the "
"texture line.\n\n"
"If two image type names separate by a comma are given, it means "
"to generate a second file of the second type for the alpha "
"channel, for images that require an alpha channel. This allows "
"support for image file formats that do not support alpha "
"(for instance, JPEG).\n\n");
show_text(" :shadowtype type[,alpha_type]", 10,
"When generating palette images, egg-palettize sometimes has to "
"read and write the same palette image repeatedly. If the "
"palette image is stored in a lossy file format (like JPEG, see "
":imagetype), this can eventually lead to degradation of the "
"palette images. As a workaround, egg-palettize can store "
"its working copies of the palette images in lossless shadow "
"images. Specify this to enable this feature; give it the "
"name of a lossless image file format. The shadow images will "
"be written to the directory specified by -ds on the command "
"line.\n\n");
show_text(" :group groupname [dir dirname] [with group1 group2 ...]", 10,
"This defines a palette group, a logical division of textures. "
"Each texture is assigned to one or more palette groups before "
@ -369,6 +403,9 @@ run() {
// Read the Palettizer object from the Bam file written
// previously. This will recover all of the state saved from the
// past session.
nout << "Reading " << FilenameUnifier::make_user_filename(state_filename)
<< "\n";
if (!state_file.open_read(state_filename)) {
nout << FilenameUnifier::make_user_filename(state_filename)
<< " exists, but cannot be read. Perhaps you should remove it so a new one can be created.\n";

View File

@ -11,6 +11,8 @@ Filename FilenameUnifier::_txa_filename;
Filename FilenameUnifier::_txa_dir;
Filename FilenameUnifier::_rel_dirname;
FilenameUnifier::CanonicalFilenames FilenameUnifier::_canonical_filenames;
////////////////////////////////////////////////////////////////////
// Function: FilenameUnifier::set_txa_filename
// Access: Public, Static
@ -28,7 +30,7 @@ set_txa_filename(const Filename &txa_filename) {
if (_txa_dir.empty()) {
_txa_dir = ".";
}
_txa_dir.make_canonical();
make_canonical(_txa_dir);
}
////////////////////////////////////////////////////////////////////
@ -47,7 +49,7 @@ void FilenameUnifier::
set_rel_dirname(const Filename &rel_dirname) {
_rel_dirname = rel_dirname;
if (!_rel_dirname.empty()) {
_rel_dirname.make_canonical();
make_canonical(_rel_dirname);
}
}
@ -59,7 +61,7 @@ set_rel_dirname(const Filename &rel_dirname) {
////////////////////////////////////////////////////////////////////
Filename FilenameUnifier::
make_bam_filename(Filename filename) {
filename.make_canonical();
make_canonical(filename);
filename.make_relative_to(_txa_dir);
return filename;
}
@ -89,7 +91,7 @@ get_bam_filename(Filename filename) {
Filename FilenameUnifier::
make_egg_filename(Filename filename) {
if (!filename.empty()) {
filename.make_canonical();
make_canonical(filename);
filename.make_relative_to(_rel_dirname);
}
return filename;
@ -105,8 +107,36 @@ make_egg_filename(Filename filename) {
Filename FilenameUnifier::
make_user_filename(Filename filename) {
if (!filename.empty()) {
filename.make_canonical();
make_canonical(filename);
filename.make_relative_to(ExecutionEnvironment::get_cwd());
}
return filename;
}
////////////////////////////////////////////////////////////////////
// Function: FilenameUnifier::make_canonical
// Access: Private, Static
// Description: Does the same thing as Filename::make_canonical()--it
// converts the filename to its canonical form--but
// caches the operation so that repeated calls to
// filenames in the same directory will tend to be
// faster.
////////////////////////////////////////////////////////////////////
void FilenameUnifier::
make_canonical(Filename &filename) {
if (filename.empty()) {
return;
}
string dirname = filename.get_dirname();
CanonicalFilenames::iterator fi;
fi = _canonical_filenames.find(dirname);
if (fi != _canonical_filenames.end()) {
filename.set_dirname((*fi).second);
return;
}
filename.make_canonical();
_canonical_filenames.insert(CanonicalFilenames::value_type(dirname, filename.get_dirname()));
}

View File

@ -10,6 +10,8 @@
#include <filename.h>
#include <map>
////////////////////////////////////////////////////////////////////
// Class : FilenameUnifier
// Description : This static class does the job of converting
@ -31,9 +33,14 @@ public:
static Filename make_user_filename(Filename filename);
private:
static void make_canonical(Filename &filename);
static Filename _txa_filename;
static Filename _txa_dir;
static Filename _rel_dirname;
typedef map<string, string> CanonicalFilenames;
static CanonicalFilenames _canonical_filenames;
};
#endif

View File

@ -1,9 +1,9 @@
// Filename: string_utils.cxx
// Filename: pal_string_utils.cxx
// Created by: drose (30Nov00)
//
////////////////////////////////////////////////////////////////////
#include "string_utils.h"
#include "pal_string_utils.h"
#include <pnmFileType.h>
#include <pnmFileTypeRegistry.h>

View File

@ -1,10 +1,10 @@
// Filename: string_utils.h
// Filename: pal_string_utils.h
// Created by: drose (30Nov00)
//
////////////////////////////////////////////////////////////////////
#ifndef STRING_UTILS_H
#define STRING_UTILS_H
#ifndef PAL_STRING_UTILS_H
#define PAL_STRING_UTILS_H
#include <pandatoolbase.h>
#include <vector_string.h>

View File

@ -601,6 +601,7 @@ get_image() {
if (pal->_shadow_color_type != (PNMFileType *)NULL) {
if (_shadow_image.read(_image)) {
_got_image = true;
return;
}
} else {
if (read(_image)) {

View File

@ -6,7 +6,7 @@
#include "palettizer.h"
#include "eggFile.h"
#include "textureImage.h"
#include "string_utils.h"
#include "pal_string_utils.h"
#include "paletteGroup.h"
#include "filenameUnifier.h"

View File

@ -374,6 +374,12 @@ get_margin() const {
////////////////////////////////////////////////////////////////////
bool TextureImage::
is_surprise() const {
if (_placement.empty()) {
// A texture that is not actually placed anywhere is not
// considered a surprise.
return false;
}
return _is_surprise;
}

View File

@ -16,12 +16,14 @@
#include <eggTexture.h>
#include <eggData.h>
#include <eggGroupNode.h>
#include <eggGroup.h>
#include <eggNurbsSurface.h>
#include <eggVertexPool.h>
#include <datagram.h>
#include <datagramIterator.h>
#include <bamReader.h>
#include <bamWriter.h>
#include <string_utils.h>
#include <math.h>
@ -394,11 +396,21 @@ write(ostream &out, int indent_level) const {
////////////////////////////////////////////////////////////////////
void TextureReference::
get_uv_range(EggGroupNode *group) {
EggGroupNode::iterator ci;
if (group->is_of_type(EggGroup::get_class_type())) {
EggGroup *egg_group;
DCAST_INTO_V(egg_group, group);
if (egg_group->has_objecttype() &&
cmp_nocase_uh(egg_group->get_objecttype(), "backstage") == 0) {
// If we reach a <Group> node with the "backstage" flag set,
// ignore it and everything under it.
return;
}
}
bool group_any_uvs = false;
TexCoordd group_min_uv, group_max_uv;
EggGroupNode::iterator ci;
for (ci = group->begin(); ci != group->end(); ci++) {
EggNode *child = (*ci);
if (child->is_of_type(EggNurbsSurface::get_class_type())) {
@ -473,11 +485,21 @@ get_uv_range(EggGroupNode *group) {
////////////////////////////////////////////////////////////////////
void TextureReference::
update_uv_range(EggGroupNode *group) {
EggGroupNode::iterator ci;
if (group->is_of_type(EggGroup::get_class_type())) {
EggGroup *egg_group;
DCAST_INTO_V(egg_group, group);
if (egg_group->has_objecttype() &&
cmp_nocase_uh(egg_group->get_objecttype(), "backstage") == 0) {
// If we reach a <Group> node with the "backstage" flag set,
// ignore it and everything under it.
return;
}
}
bool group_any_uvs = false;
TexCoordd group_min_uv, group_max_uv;
EggGroupNode::iterator ci;
for (ci = group->begin(); ci != group->end(); ci++) {
EggNode *child = (*ci);
if (child->is_of_type(EggNurbsSurface::get_class_type())) {

View File

@ -4,7 +4,7 @@
////////////////////////////////////////////////////////////////////
#include "txaFile.h"
#include "string_utils.h"
#include "pal_string_utils.h"
#include "palettizer.h"
#include "paletteGroup.h"
#include "textureImage.h"

View File

@ -4,7 +4,7 @@
////////////////////////////////////////////////////////////////////
#include "txaLine.h"
#include "string_utils.h"
#include "pal_string_utils.h"
#include "eggFile.h"
#include "palettizer.h"
#include "textureImage.h"