*** empty log message ***

This commit is contained in:
David Rose 2000-11-14 04:25:47 +00:00
parent 8c7787003f
commit 858b3700c0
15 changed files with 107 additions and 28 deletions

View File

@ -25,7 +25,7 @@
// time when we can't be sure what has or hasn't been // time when we can't be sure what has or hasn't been
// already initialized. // already initialized.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
const DSearchPath & DSearchPath &
get_config_path(const string &config_var_name, DSearchPath *&static_ptr) { get_config_path(const string &config_var_name, DSearchPath *&static_ptr) {
if (static_ptr == (DSearchPath *)NULL) { if (static_ptr == (DSearchPath *)NULL) {
static_ptr = new DSearchPath; static_ptr = new DSearchPath;

View File

@ -28,7 +28,7 @@
// time when we can't be sure what has or hasn't been // time when we can't be sure what has or hasn't been
// already initialized. // already initialized.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
EXPCL_PANDAEXPRESS const DSearchPath & EXPCL_PANDAEXPRESS DSearchPath &
get_config_path(const string &config_var_name, DSearchPath *&static_ptr); get_config_path(const string &config_var_name, DSearchPath *&static_ptr);
#endif #endif

View File

@ -57,19 +57,19 @@ ConfigureFn(config_util) {
//const bool track_memory_usage = config_util.GetBool("track-memory-usage", false); //const bool track_memory_usage = config_util.GetBool("track-memory-usage", false);
const DSearchPath & DSearchPath &
get_model_path() { get_model_path() {
static DSearchPath *model_path = NULL; static DSearchPath *model_path = NULL;
return get_config_path("model-path", model_path); return get_config_path("model-path", model_path);
} }
const DSearchPath & DSearchPath &
get_texture_path() { get_texture_path() {
static DSearchPath *texture_path = NULL; static DSearchPath *texture_path = NULL;
return get_config_path("texture-path", texture_path); return get_config_path("texture-path", texture_path);
} }
const DSearchPath & DSearchPath &
get_sound_path() { get_sound_path() {
static DSearchPath *sound_path = NULL; static DSearchPath *sound_path = NULL;
return get_config_path("sound-path", sound_path); return get_config_path("sound-path", sound_path);

View File

@ -26,8 +26,8 @@ NotifyCategoryDecl(util, EXPCL_PANDA, EXPTP_PANDA);
// computed based on the concatenation of all appearances of the // computed based on the concatenation of all appearances of the
// corresponding variable in the config files. // corresponding variable in the config files.
EXPCL_PANDA const DSearchPath &get_model_path(); EXPCL_PANDA DSearchPath &get_model_path();
EXPCL_PANDA const DSearchPath &get_texture_path(); EXPCL_PANDA DSearchPath &get_texture_path();
EXPCL_PANDA const DSearchPath &get_sound_path(); EXPCL_PANDA DSearchPath &get_sound_path();
#endif /* __CONFIG_UTIL_H__ */ #endif /* __CONFIG_UTIL_H__ */

View File

@ -5,6 +5,7 @@
#include "eggToBam.h" #include "eggToBam.h"
#include <config_util.h>
#include <bamFile.h> #include <bamFile.h>
#include <load_egg_file.h> #include <load_egg_file.h>
@ -21,6 +22,12 @@ EggToBam() :
("This program reads Egg files and outputs Bam files, the binary format " ("This program reads Egg files and outputs Bam files, the binary format "
"suitable for direct loading of animation and models into Panda."); "suitable for direct loading of animation and models into Panda.");
add_option
("tp", "path", 0,
"Add the indicated colon-delimited paths to the texture-path. This "
"option may also be repeated to add multiple paths.",
&EggToBam::dispatch_search_path, NULL, &get_texture_path());
redescribe_option redescribe_option
("cs", ("cs",
"Specify the coordinate system of the resulting " + _format_name + "Specify the coordinate system of the resulting " + _format_name +

View File

@ -135,7 +135,7 @@ import(const Filename &source, void *extra_data,
return (CVSSourceDirectory *)NULL; return (CVSSourceDirectory *)NULL;
} }
if (new_file) { if (new_file) {
create_file(dest); cvs_add(dest);
} }
} }
@ -315,14 +315,14 @@ copy_binary_file(Filename source, Filename dest) {
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: CVSCopy::create_file // Function: CVSCopy::cvs_add
// Access: Protected // Access: Protected
// Description: Invokes CVS to add the indicated filename to the // Description: Invokes CVS to add the indicated filename to the
// repository, if the user so requested. Returns true // repository, if the user so requested. Returns true
// if successful, false if there is an error. // if successful, false if there is an error.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool CVSCopy:: bool CVSCopy::
create_file(const Filename &filename) { cvs_add(const Filename &filename) {
if (_no_cvs) { if (_no_cvs) {
return true; return true;
} }

View File

@ -42,7 +42,7 @@ protected:
bool verify_binary_file(Filename source, Filename dest); bool verify_binary_file(Filename source, Filename dest);
bool copy_binary_file(Filename source, Filename dest); bool copy_binary_file(Filename source, Filename dest);
bool create_file(const Filename &filename); bool cvs_add(const Filename &filename);
private: private:
bool scan_hierarchy(); bool scan_hierarchy();

View File

@ -29,6 +29,11 @@ AttribFile(const Filename &filename) {
_pi_filename.set_extension("pi"); _pi_filename.set_extension("pi");
_txa_fd = -1; _txa_fd = -1;
_pi_dir = _pi_filename;
_pi_dir.set_basename("");
_pi_dir.make_canonical();
_default_group = (PaletteGroup *)NULL; _default_group = (PaletteGroup *)NULL;
_optimal = false; _optimal = false;
@ -142,11 +147,56 @@ write() {
return okflag; return okflag;
} }
////////////////////////////////////////////////////////////////////
// Function: AttribFile::write_pi_filename
// Access: Public
// Description: Returns a new filename that's made relative to the
// .pi file itself, suitable for writing to the .pi file.
////////////////////////////////////////////////////////////////////
Filename AttribFile::
write_pi_filename(Filename filename) const {
filename.make_canonical();
filename.make_relative_to(_pi_dir);
return filename;
}
////////////////////////////////////////////////////////////////////
// Function: AttribFile::read_pi_filename
// Access: Public
// Description: Returns an absolute pathname based on the given
// relative pathname, presumably read from the .pi file
// and relative to the .pi file.
////////////////////////////////////////////////////////////////////
Filename AttribFile::
read_pi_filename(Filename filename) const {
if (!filename.empty()) {
filename.make_absolute(_pi_dir);
}
return filename;
}
////////////////////////////////////////////////////////////////////
// Function: AttribFile::write_egg_filename
// Access: Public
// Description: Returns a new filename that's made relative to the
// rel_directory, suitable for writing out within egg
// files.
////////////////////////////////////////////////////////////////////
Filename AttribFile::
write_egg_filename(Filename filename) const {
filename.make_canonical();
filename.make_relative_to(_rel_dirname);
return filename;
}
void AttribFile:: void AttribFile::
update_params(EggPalettize *prog) { update_params(EggPalettize *prog) {
if (prog->_got_map_dirname) { if (prog->_got_map_dirname) {
_map_dirname = prog->_map_dirname; _map_dirname = prog->_map_dirname;
} }
if (prog->_got_rel_dirname) {
_rel_dirname = prog->_rel_dirname;
}
if (prog->_got_palette_size) { if (prog->_got_palette_size) {
_pal_xsize = prog->_pal_size[0]; _pal_xsize = prog->_pal_size[0];
_pal_ysize = prog->_pal_size[1]; _pal_ysize = prog->_pal_size[1];
@ -160,6 +210,10 @@ update_params(EggPalettize *prog) {
if (prog->_got_aggressively_clean_mapdir) { if (prog->_got_aggressively_clean_mapdir) {
_aggressively_clean_mapdir = prog->_aggressively_clean_mapdir; _aggressively_clean_mapdir = prog->_aggressively_clean_mapdir;
} }
if (!_rel_dirname.empty()) {
_rel_dirname.make_canonical();
}
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -508,8 +562,9 @@ get_eligible_textures(vector<TexturePacking *> &textures) {
SourceEgg *AttribFile:: SourceEgg *AttribFile::
get_egg(Filename name) { get_egg(Filename name) {
string basename = name.get_basename();
Eggs::iterator ei; Eggs::iterator ei;
ei = _eggs.find(name); ei = _eggs.find(basename);
if (ei != _eggs.end()) { if (ei != _eggs.end()) {
return (*ei).second; return (*ei).second;
} }
@ -517,7 +572,7 @@ get_egg(Filename name) {
SourceEgg *egg = new SourceEgg(this); SourceEgg *egg = new SourceEgg(this);
egg->resolve_egg_filename(name); egg->resolve_egg_filename(name);
egg->set_egg_filename(name); egg->set_egg_filename(name);
_eggs[name] = egg; _eggs[basename] = egg;
return egg; return egg;
} }
@ -799,6 +854,7 @@ write_pi(ostream &out) const {
out << "\nparams\n" out << "\nparams\n"
<< " map_directory " << _map_dirname << "\n" << " map_directory " << _map_dirname << "\n"
<< " rel_directory " << write_pi_filename(_rel_dirname) << "\n"
<< " pal_xsize " << _pal_xsize << "\n" << " pal_xsize " << _pal_xsize << "\n"
<< " pal_ysize " << _pal_ysize << "\n" << " pal_ysize " << _pal_ysize << "\n"
<< " default_margin " << _default_margin << "\n" << " default_margin " << _default_margin << "\n"
@ -902,6 +958,8 @@ parse_params(const vector<string> &words, istream &infile,
if (param == "map_directory") { if (param == "map_directory") {
_map_dirname = value; _map_dirname = value;
} else if (param == "rel_directory") {
_rel_dirname = read_pi_filename(value);
} else if (param == "pal_xsize") { } else if (param == "pal_xsize") {
_pal_xsize = atoi(value.c_str()); _pal_xsize = atoi(value.c_str());
} else if (param == "pal_ysize") { } else if (param == "pal_ysize") {
@ -1013,12 +1071,12 @@ parse_pathname(const vector<string> &words, istream &infile,
nout << "Expected texture name and pathname.\n"; nout << "Expected texture name and pathname.\n";
return false; return false;
} }
texture->add_filename(twords[0]); texture->add_filename(read_pi_filename(twords[0]));
} else if (twords.size() == 2) { } else if (twords.size() == 2) {
// Two words on the line means it's a texture name and filename. // Two words on the line means it's a texture name and filename.
texture = get_texture(twords[0]); texture = get_texture(twords[0]);
texture->add_filename(twords[1]); texture->add_filename(read_pi_filename(twords[1]));
} else { } else {
// Anything else is a mistake. // Anything else is a mistake.
@ -1042,7 +1100,7 @@ parse_egg(const vector<string> &words, istream &infile,
return false; return false;
} }
SourceEgg *egg = get_egg(words[1]); SourceEgg *egg = get_egg(read_pi_filename(words[1]));
if (words.size() > 2 && words[2] == "in") { if (words.size() > 2 && words[2] == "in") {
// Get the group names. // Get the group names.
@ -1143,7 +1201,7 @@ parse_palette(const vector<string> &words, istream &infile,
return false; return false;
} }
string filename = words[1]; string filename = read_pi_filename(words[1]);
if (!(words[2] == "in")) { if (!(words[2] == "in")) {
nout << "Expected keyword 'in'\n"; nout << "Expected keyword 'in'\n";
return false; return false;

View File

@ -37,6 +37,10 @@ public:
bool read(bool force_redo_all); bool read(bool force_redo_all);
bool write(); bool write();
Filename write_pi_filename(Filename filename) const;
Filename read_pi_filename(Filename filename) const;
Filename write_egg_filename(Filename filename) const;
void update_params(EggPalettize *prog); void update_params(EggPalettize *prog);
PaletteGroup *get_group(const string &group_name); PaletteGroup *get_group(const string &group_name);
@ -119,6 +123,8 @@ private:
Filename _txa_filename; Filename _txa_filename;
Filename _pi_filename; Filename _pi_filename;
Filename _pi_dir;
PaletteGroup *_default_group; PaletteGroup *_default_group;
public: public:
@ -128,6 +134,7 @@ public:
// palettes, and thus should be stored in the .pi file for future // palettes, and thus should be stored in the .pi file for future
// reference. // reference.
string _map_dirname; string _map_dirname;
Filename _rel_dirname;
int _pal_xsize, _pal_ysize; int _pal_xsize, _pal_ysize;
int _default_margin; int _default_margin;
bool _force_power_2; bool _force_power_2;

View File

@ -69,6 +69,11 @@ EggPalettize() : EggMultiFilter(true) {
"this will be replaced with the \"dir\" string associated with a " "this will be replaced with the \"dir\" string associated with a "
"palette group.", "palette group.",
&EggPalettize::dispatch_string, &_got_map_dirname, &_map_dirname); &EggPalettize::dispatch_string, &_got_map_dirname, &_map_dirname);
add_option
("dr", "dirname", 0,
"The directory to make map filenames relative to when writing egg "
"files. If specified, this should be an initial substring of -dm.",
&EggPalettize::dispatch_filename, &_got_rel_dirname, &_rel_dirname);
add_option add_option
("g", "group", 0, ("g", "group", 0,
"The default palette group that egg files will be assigned to if they " "The default palette group that egg files will be assigned to if they "
@ -181,7 +186,6 @@ handle_args(ProgramBase::Args &args) {
exit(1); exit(1);
} }
Args egg_names; Args egg_names;
Args txa_names; Args txa_names;

View File

@ -40,6 +40,8 @@ public:
// reference. // reference.
string _map_dirname; string _map_dirname;
bool _got_map_dirname; bool _got_map_dirname;
Filename _rel_dirname;
bool _got_rel_dirname;
string _default_groupname; string _default_groupname;
bool _got_default_groupname; bool _got_default_groupname;
string _default_groupdir; string _default_groupdir;

View File

@ -358,7 +358,8 @@ write_pathname(ostream &out) const {
nout << "Warning: texture " << _filename << " does not exist.\n"; nout << "Warning: texture " << _filename << " does not exist.\n";
} }
out << " " << _name << " " << _filename << "\n"; out << " " << _name << " " << _attrib_file->write_pi_filename(_filename)
<< "\n";
// Also write out all the alternate filenames. // Also write out all the alternate filenames.
Filenames::const_iterator fi; Filenames::const_iterator fi;
@ -368,7 +369,7 @@ write_pathname(ostream &out) const {
for (int i = 0; i < (int)_name.length() + 3; i++) { for (int i = 0; i < (int)_name.length() + 3; i++) {
out << ' '; out << ' ';
} }
out << (*fi) << "\n"; out << _attrib_file->write_pi_filename(*fi) << "\n";
} }
} }
} }

View File

@ -357,7 +357,8 @@ finalize_palette() {
void Palette:: void Palette::
write(ostream &out) const { write(ostream &out) const {
out << "palette " << _filename << " in " << _group->get_name() out << "palette " << _attrib_file->write_pi_filename(_filename)
<< " in " << _group->get_name()
<< " size " << _xsize << " " << _ysize << " " << _components << " size " << _xsize << " " << _ysize << " " << _components
<< "\n"; << "\n";
TexPlace::const_iterator ti; TexPlace::const_iterator ti;

View File

@ -289,14 +289,14 @@ update_trefs() {
packing->get_omit() != OR_none) { packing->get_omit() != OR_none) {
// This texture wasn't palettized, so just rename the // This texture wasn't palettized, so just rename the
// reference to the new one. // reference to the new one.
eggtex->set_fullpath(packing->get_new_filename()); eggtex->set_fullpath(_attrib_file->write_egg_filename(packing->get_new_filename()));
} else { } else {
// This texture was palettized, so redirect the tref to point // This texture was palettized, so redirect the tref to point
// within the palette. // within the palette.
Palette *palette = packing->get_palette(); Palette *palette = packing->get_palette();
eggtex->set_fullpath(palette->get_filename()); eggtex->set_fullpath(_attrib_file->write_egg_filename(palette->get_filename()));
// Set the texture attributes to be uniform across all palettes. // Set the texture attributes to be uniform across all palettes.
eggtex->set_minfilter(EggTexture::FT_mipmap_trilinear); eggtex->set_minfilter(EggTexture::FT_mipmap_trilinear);
@ -402,9 +402,8 @@ set_matched_anything(bool matched_anything) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void SourceEgg:: void SourceEgg::
write_pi(ostream &out) const { write_pi(ostream &out) const {
Filename absolute_filename = get_egg_filename(); Filename filename = _attrib_file->write_pi_filename(get_egg_filename());
absolute_filename.make_absolute(); out << "egg " << filename << " in";
out << "egg " << absolute_filename << " in";
PaletteGroups::const_iterator gi; PaletteGroups::const_iterator gi;
for (gi = _groups.begin(); gi != _groups.end(); ++gi) { for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
out << " " << (*gi)->get_name(); out << " " << (*gi)->get_name();

View File

@ -204,7 +204,7 @@ copy_texture(const Filename &source, const Filename &dest,
tex->write_attr_data(attr_filename); tex->write_attr_data(attr_filename);
if (new_file) { if (new_file) {
create_file(attr_filename); add_cvs(attr_filename);
} }
return true; return true;