00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "fltToEgg.h"
00016
00017 #include "fltToEggConverter.h"
00018 #include "config_flt.h"
00019 #include "pystub.h"
00020
00021
00022
00023
00024
00025
00026 FltToEgg::
00027 FltToEgg() :
00028 SomethingToEgg("MultiGen", ".flt")
00029 {
00030 add_path_replace_options();
00031 add_path_store_options();
00032 add_units_options();
00033 add_normals_options();
00034 add_transform_options();
00035 add_merge_externals_options();
00036
00037 set_program_description
00038 ("This program converts MultiGen OpenFlight (.flt) files to egg. Most "
00039 "features of MultiGen that are also recognized by egg are supported.");
00040
00041 redescribe_option
00042 ("cs",
00043 "Specify the coordinate system of the input " + _format_name +
00044 " file. Normally, this is z-up.");
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 _compose_transforms = false;
00057
00058 _coordinate_system = CS_zup_right;
00059 }
00060
00061
00062
00063
00064
00065
00066 void FltToEgg::
00067 run() {
00068 _data->set_coordinate_system(_coordinate_system);
00069
00070 FltToEggConverter converter;
00071 converter.set_merge_externals(_merge_externals);
00072 converter.set_egg_data(_data);
00073 converter._compose_transforms = _compose_transforms;
00074 converter._allow_errors = _allow_errors;
00075
00076 apply_parameters(converter);
00077
00078
00079 PT(FltHeader) header = new FltHeader(_path_replace);
00080
00081 nout << "Reading " << _input_filename << "\n";
00082 FltError result = header->read_flt(_input_filename);
00083 if (result != FE_ok) {
00084 nout << "Unable to read: " << result << "\n";
00085 exit(1);
00086 }
00087
00088 header->check_version();
00089
00090
00091 if (!converter.convert_flt(header)) {
00092 nout << "Errors in conversion.\n";
00093 exit(1);
00094 }
00095
00096 if (_input_units == DU_invalid) {
00097 _input_units = converter.get_input_units();
00098 }
00099
00100 write_egg_file();
00101 nout << "\n";
00102 }
00103
00104
00105 int main(int argc, char *argv[]) {
00106
00107 pystub();
00108
00109 init_libflt();
00110 FltToEgg prog;
00111 prog.parse_command_line(argc, argv);
00112 prog.run();
00113 return 0;
00114 }