00001 // Filename: eggFilter.cxx 00002 // Created by: drose (14Feb00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "eggFilter.h" 00016 00017 //////////////////////////////////////////////////////////////////// 00018 // Function: EggFilter::Constructor 00019 // Access: Public 00020 // Description: 00021 //////////////////////////////////////////////////////////////////// 00022 EggFilter:: 00023 EggFilter(bool allow_last_param, bool allow_stdout) : 00024 EggWriter(allow_last_param, allow_stdout) 00025 { 00026 // The default path store for programs that read egg files and write 00027 // them again is PS_relative. 00028 _path_replace->_path_store = PS_relative; 00029 00030 clear_runlines(); 00031 if (allow_last_param) { 00032 add_runline("[opts] input.egg output.egg"); 00033 } 00034 add_runline("[opts] -o output.egg input.egg"); 00035 if (allow_stdout) { 00036 add_runline("[opts] input.egg >output.egg"); 00037 } 00038 00039 redescribe_option 00040 ("cs", 00041 "Specify the coordinate system of the resulting egg file. This may be " 00042 "one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default " 00043 "is the same coordinate system as the input egg file. If this is " 00044 "different from the input egg file, a conversion will be performed."); 00045 } 00046 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: EggFilter::handle_args 00050 // Access: Protected, Virtual 00051 // Description: Does something with the additional arguments on the 00052 // command line (after all the -options have been 00053 // parsed). Returns true if the arguments are good, 00054 // false otherwise. 00055 //////////////////////////////////////////////////////////////////// 00056 bool EggFilter:: 00057 handle_args(ProgramBase::Args &args) { 00058 if (!check_last_arg(args, 1)) { 00059 return false; 00060 } 00061 00062 if (!_got_path_directory && _got_output_filename) { 00063 // Put in the name of the output directory. 00064 _path_replace->_path_directory = _output_filename.get_dirname(); 00065 } 00066 00067 return EggReader::handle_args(args); 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: EggFilter::post_command_line 00072 // Access: Protected, Virtual 00073 // Description: 00074 //////////////////////////////////////////////////////////////////// 00075 bool EggFilter:: 00076 post_command_line() { 00077 // writer first, so we can fiddle with the _path_replace options if 00078 // necessary. 00079 return EggWriter::post_command_line() && EggReader::post_command_line(); 00080 }