Panda3D
|
00001 // Filename: eggToX.cxx 00002 // Created by: drose (19Jun01) 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 "eggToX.h" 00016 #include "config_xfile.h" 00017 #include "pystub.h" 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: EggToX::Constructor 00021 // Access: Public 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 EggToX:: 00025 EggToX() : EggToSomething("DirectX", ".x", true, false) { 00026 add_texture_options(); 00027 add_delod_options(0.0); 00028 00029 set_program_description 00030 ("This program reads an Egg file and outputs an equivalent, " 00031 "or nearly equivalent, DirectX-style .x file. Only simple " 00032 "hierarchy and polygon meshes are supported; advanced features " 00033 "like LOD's, decals, and animation or skinning are not supported."); 00034 00035 add_option 00036 ("m", "", 0, 00037 "Convert all the objects in the egg file as one big mesh, instead of " 00038 "preserving the normal egg hierarchy.", 00039 &EggToX::dispatch_none, &xfile_one_mesh); 00040 00041 // X files are always y-up-left. 00042 remove_option("cs"); 00043 _got_coordinate_system = true; 00044 _coordinate_system = CS_yup_left; 00045 00046 // We always have -f on: force complete load. X files don't support 00047 // external references. 00048 remove_option("f"); 00049 _force_complete = true; 00050 } 00051 00052 00053 //////////////////////////////////////////////////////////////////// 00054 // Function: EggToX::run 00055 // Access: Public 00056 // Description: 00057 //////////////////////////////////////////////////////////////////// 00058 void EggToX:: 00059 run() { 00060 if (!do_reader_options()) { 00061 exit(1); 00062 } 00063 00064 if (!_x.add_tree(_data)) { 00065 nout << "Unable to define egg structure.\n"; 00066 exit(1); 00067 } 00068 00069 if (!_x.write(get_output_filename())) { 00070 nout << "Unable to write " << get_output_filename() << ".\n"; 00071 exit(1); 00072 } 00073 } 00074 00075 00076 int main(int argc, char *argv[]) { 00077 // A call to pystub() to force libpystub.so to be linked in. 00078 pystub(); 00079 00080 init_libxfile(); 00081 EggToX prog; 00082 prog.parse_command_line(argc, argv); 00083 prog.run(); 00084 return 0; 00085 }