Panda3D
|
00001 // Filename: objToEgg.cxx 00002 // Created by: drose (04May04) 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 "objToEgg.h" 00016 00017 #include "objToEggConverter.h" 00018 #include "pystub.h" 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: ObjToEgg::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 ObjToEgg:: 00026 ObjToEgg() : 00027 SomethingToEgg("obj", ".obj") 00028 { 00029 add_units_options(); 00030 add_points_options(); 00031 add_normals_options(); 00032 add_transform_options(); 00033 00034 set_program_description 00035 ("This program converts obj files to egg. It " 00036 "only converts polygon data, with no fancy tricks. " 00037 "Very bare-bones at the moment, not even texture maps are supported."); 00038 00039 redescribe_option 00040 ("cs", 00041 "Specify the coordinate system of the input " + _format_name + 00042 " file. Normally, this is z-up."); 00043 00044 _coordinate_system = CS_zup_right; 00045 } 00046 00047 //////////////////////////////////////////////////////////////////// 00048 // Function: ObjToEgg::run 00049 // Access: Public 00050 // Description: 00051 //////////////////////////////////////////////////////////////////// 00052 void ObjToEgg:: 00053 run() { 00054 nout << "Reading " << _input_filename << "\n"; 00055 00056 _data->set_coordinate_system(_coordinate_system); 00057 00058 ObjToEggConverter converter; 00059 converter.set_egg_data(_data); 00060 converter._allow_errors = _allow_errors; 00061 00062 apply_parameters(converter); 00063 00064 if (!converter.convert_file(_input_filename)) { 00065 nout << "Errors in conversion.\n"; 00066 exit(1); 00067 } 00068 00069 write_egg_file(); 00070 nout << "\n"; 00071 } 00072 00073 00074 int main(int argc, char *argv[]) { 00075 // A call to pystub() to force libpystub.so to be linked in. 00076 pystub(); 00077 00078 ObjToEgg prog; 00079 prog.parse_command_line(argc, argv); 00080 prog.run(); 00081 return 0; 00082 }