28 set_program_brief(
"copy MultiGen .flt files into a CVS source hierarchy");
29 set_program_description
30 (
"fltcopy copies one or more MultiGen .flt files into a "
31 "CVS source hierarchy. "
32 "Rather than copying the named files immediately into the current "
33 "directory, it first scans the entire source hierarchy, identifying all "
34 "the already-existing files. If the named file to copy matches the "
35 "name of an already-existing file in the current directory or elsewhere "
36 "in the hierarchy, that file is overwritten. Other .flt files, as "
37 "well as texture files, that are externally referenced by the "
38 "named .flt file(s) are similarly copied.");
41 add_runline(
"[opts] file.flt [file.flt ... ]");
43 add_path_replace_options();
51 SourceFiles::iterator fi;
52 for (fi = _source_files.begin(); fi != _source_files.end(); ++fi) {
71 ExtraData *ed = (ExtraData *)extra_data;
74 return copy_flt_file(source, dest, dir);
77 return copy_texture(source, dest, dir, ed->_texture, new_file);
80 nout <<
"Internal error: invalid type " << (int)ed->_type <<
"\n";
94 header->set_auto_attr_update(FltHeader::AU_none);
96 FltError result = header->read_flt(source);
97 if (result != FE_ok) {
98 nout <<
"Cannot read " << source <<
": " << result <<
"\n";
102 header->check_version();
107 scan_flt(header, refs, textures);
109 Refs::const_iterator ri;
110 for (ri = refs.begin(); ri != refs.end(); ++ri) {
114 if (!ref_filename.
exists()) {
115 nout <<
"*** Warning: external reference " << ref_filename
116 <<
" does not exist.\n";
122 import(ref_filename, &ed, _model_dir);
136 header->clear_textures();
138 Textures::const_iterator ti;
139 for (ti = textures.begin(); ti != textures.end(); ++ti) {
143 if (!texture_filename.
exists()) {
144 nout <<
"*** Warning: texture " << texture_filename
145 <<
" does not exist.\n";
148 ed._type = FT_texture;
152 import(texture_filename, &ed, _map_dir);
160 header->add_texture(tex);
165 result = header->write_flt(dest);
166 if (result != FE_ok) {
167 nout <<
"Cannot write " << dest <<
"\n";
180 if (!copy_binary_file(source, dest)) {
186 if (!attr_filename.
exists()) {
193 cvs_add(attr_filename);
205 if (record->
is_of_type(FltFace::get_class_type())) {
207 DCAST_INTO_V(face, record);
212 }
else if (record->
is_of_type(FltExternalReference::get_class_type())) {
214 DCAST_INTO_V(ref, record);
220 int num_subfaces = record->get_num_subfaces();
221 for (i = 0; i < num_subfaces; i++) {
222 scan_flt(record->get_subface(i), refs, textures);
225 int num_children = record->get_num_children();
226 for (i = 0; i < num_children; i++) {
227 scan_flt(record->get_child(i), refs, textures);
232 int main(
int argc,
char *argv[]) {
This represents one particular directory in the hierarchy of source directory files.
Filename get_rel_from(const CVSSourceDirectory *other) const
Returns the relative path to this file as seen from the indicated source directory.
bool is_valid() const
Returns true if this FilePath represents a valid file, or false if it represents an error return.
The name of a file, such as a texture file or an Egg file.
std::string get_fullpath() const
Returns the entire filename: directory, basename, extension.
bool exists() const
Returns true if the filename exists on the disk, false otherwise.
A program to copy Multigen .flt files into the cvs tree.
An external reference to another flt file (possibly to a specific bead within the flt file).
Filename get_ref_filename() const
Returns the name of the referenced file.
void set_ref_filename(const Filename &filename)
Changes the name of the referenced file.
bool has_texture() const
Returns true if the face has a texture applied, false otherwise.
FltTexture * get_texture() const
Returns the texture applied to this face, or NULL if no texture was applied.
The base class for all kinds of records in a MultiGen OpenFlight file.
Represents a single texture in the texture palette.
FltError write_attr_data() const
Writes the texture's .attr file.
void set_texture_filename(const Filename &filename)
Changes the name of the texture image file.
Filename get_texture_filename() const
Returns the name of the texture image file.
virtual void parse_command_line(int argc, char **argv)
Dispatches on each of the options on the command line, and passes the remaining parameters to handle_...
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
This is our own Panda specialization on the default STL set.
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.