31 add_runline(
"[opts] input.egg");
35 "Specify the coordinate system to operate in. This may be " 36 " one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default " 37 "is the coordinate system of the input egg file.");
41 "Force complete loading: load up the egg file along with all of its " 42 "external references.",
43 &EggReader::dispatch_none, &_force_complete);
47 "Don't allow the input egg file to have absolute pathnames. " 48 "If it does, abort with an error. This option is designed to help " 49 "detect errors when populating or building a standalone model tree, " 50 "which should be self-contained and include only relative pathnames.",
51 &EggReader::dispatch_none, &_noabs);
56 _got_tex_dirname =
false;
57 _got_tex_extension =
false;
73 "Copy textures to the indicated directory. The copy is performed " 74 "only if the destination file does not exist or is older than the " 76 &EggReader::dispatch_filename, &_got_tex_dirname, &_tex_dirname);
80 "Rename textures to have the indicated extension. This also " 81 "automatically copies them to the new filename (possibly in a " 82 "different directory if -td is also specified), and may implicitly " 83 "convert to a different image format according to the extension.",
84 &EggReader::dispatch_string, &_got_tex_extension, &_tex_extension);
88 "Explicitly specifies the image format to convert textures to " 89 "when copying them via -td or -te. Normally, this is unnecessary as " 90 "the image format can be determined by the extension, but sometimes " 91 "the extension is insufficient to unambiguously specify an image " 93 &EggReader::dispatch_image_type,
nullptr, &_tex_type);
105 _delod = default_delod;
107 if (default_delod < 0) {
109 (
"delod",
"dist", 40,
110 "Eliminate LOD's by choosing the level that would be appropriate for " 111 "a camera at the indicated fixed distance from each LOD. " 112 "Use -delod -1 to keep all the LOD's as they are, which is " 114 &EggReader::dispatch_double,
nullptr, &_delod);
118 (
"delod",
"dist", 40,
119 "Eliminate LOD's by choosing the level that would be appropriate for " 120 "a camera at the indicated fixed distance from each LOD. " 121 "Use -delod -1 to keep all the LOD's as they are. The default value " 122 "is " + format_string(default_delod) +
".",
123 &EggReader::dispatch_double,
nullptr, &_delod);
158 nout <<
"You must specify the egg file(s) to read on the command line.\n";
168 Args::const_iterator ai;
169 for (ai = args.begin(); ai != args.end(); ++ai) {
173 if (filename !=
"-") {
174 if (!file_data.
read(filename)) {
181 if (!file_data.
read(std::cin)) {
188 <<
" includes absolute pathnames!\n";
195 if (_force_complete) {
205 _data->merge(file_data);
220 post_command_line() {
221 return EggSingleBase::post_command_line();
230 do_reader_options() {
233 if (_got_tex_dirname || _got_tex_extension) {
234 if (!copy_textures()) {
257 EggTextureCollection::const_iterator ti;
258 for (ti = textures.begin(); ti != textures.end(); ++ti) {
261 if (!orig_filename.
exists()) {
264 nout <<
"Cannot find " << orig_filename <<
"\n";
270 Filename new_filename = orig_filename;
271 if (_got_tex_dirname) {
274 if (_got_tex_extension) {
278 if (orig_filename != new_filename) {
279 tex->set_filename(new_filename);
286 nout <<
"Reading " << orig_filename <<
"\n";
288 if (!image.
read(orig_filename)) {
289 nout <<
" unable to read!\n";
292 nout <<
"Writing " << new_filename <<
"\n";
293 if (!image.
write(new_filename, _tex_type)) {
294 nout <<
" unable to write!\n";
312 if (node->
is_of_type(EggGroup::get_class_type())) {
314 if (group->has_lod()) {
316 if (cond.
is_of_type(EggSwitchConditionDistance::get_class_type())) {
319 if (_delod >= dist->_switch_out && _delod < dist->_switch_in) {
321 nout <<
"Preserving LOD " << node->get_name()
322 <<
" (" << dist->_switch_out <<
" to " << dist->_switch_in
327 nout <<
"Eliminating LOD " << node->get_name()
328 <<
" (" << dist->_switch_out <<
" to " << dist->_switch_in
337 if (node->
is_of_type(EggGroupNode::get_class_type())) {
339 EggGroupNode::iterator ci;
341 while (ci != group->end()) {
345 if (!do_delod(child)) {
346 group->remove_child(child);
std::string get_dirname() const
Returns the directory part of the filename.
const Filename & get_filename() const
Returns a nonmodifiable reference to the filename.
void set_extension(const std::string &s)
Replaces the file extension.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_delod_options(double default_delod=-1.0)
Adds -delod as a valid option for this program.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_texture_options()
Adds -td, -te, etc.
A base class for nodes in the hierarchy that are not leaf nodes.
Defines a texture map that may be applied to geometry.
bool write(const Filename &filename, PNMFileType *type=nullptr) const
Writes the image to the indicated filename.
virtual EggReader * as_reader()
Returns this object as an EggReader pointer, if it is in fact an EggReader, or NULL if it is not.
bool read(const Filename &filename, PNMFileType *type=nullptr, bool report_unknown_type=true)
Reads the indicated image filename.
bool resolve_filename(const DSearchPath &searchpath, const std::string &default_extension=std::string())
Searches the given search path for the filename.
This is a collection of textures by TRef name.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void append_directory(const Filename &directory)
Adds a new directory to the end of the search list.
This is the primary interface into all the egg data, and the root of the egg file structure.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static void convert_paths(EggNode *node, PathReplace *path_replace, const DSearchPath &additional_path)
Recursively walks the egg hierarchy.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool read(Filename filename, std::string display_name=std::string())
Opens the indicated filename and reads the egg data contents from it.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
The name of a file, such as a texture file or an Egg file.
bool load_externals(const DSearchPath &searchpath=DSearchPath())
Loads up all the egg files referenced by <File> entries within the egg structure, and inserts their c...
virtual void pre_process_egg_file()
Performs any processing of the egg file that is appropriate after reading it in.
int find_used_textures(EggNode *node)
Walks the egg hierarchy beginning at the indicated node, looking for textures that are referenced by ...
This is the base class for a program that reads egg files, but doesn't write an egg file.
std::string get_basename() const
Returns the basename part of the filename.
bool original_had_absolute_pathnames() const
Returns true if the data processed in the last call to read() contained absolute pathnames,...
int compare_timestamps(const Filename &other, bool this_missing_is_old=true, bool other_missing_is_old=true) const
Returns a number less than zero if the file named by this object is older than the given file,...
void set_dirname(const std::string &s)
Replaces the directory part of the filename.
A base class for things that may be directly added into the egg hierarchy.
This class stores a list of directories that can be searched, in order, to locate a particular file.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
This corresponds to a <SwitchCondition> entry within a group.
A SwitchCondition that switches the levels-of-detail based on distance from the camera's eyepoint.
bool exists() const
Returns true if the filename exists on the disk, false otherwise.
static Filename from_os_specific(const std::string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.