Panda3D
 All Classes Functions Variables Enumerations
lwoToEgg.cxx
00001 // Filename: lwoToEgg.cxx
00002 // Created by:  drose (17Apr01)
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 "lwoToEgg.h"
00016 
00017 #include "lwoToEggConverter.h"
00018 #include "lwoHeader.h"
00019 #include "lwoInputFile.h"
00020 #include "config_lwo.h"
00021 #include "pystub.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: LwoToEgg::Constructor
00025 //       Access: Public
00026 //  Description:
00027 ////////////////////////////////////////////////////////////////////
00028 LwoToEgg::
00029 LwoToEgg() :
00030   SomethingToEgg("Lightwave", ".lwo")
00031 {
00032   add_path_replace_options();
00033   add_path_store_options();
00034   add_units_options();
00035   add_normals_options();
00036   add_transform_options();
00037 
00038   set_program_description
00039     ("This program converts Lightwave Object (.lwo) files to egg.  Many "
00040      "rendering characteristics of Lightwave (like layered shaders, etc.) "
00041      "are not supported, but fundamental things like polygons and texture "
00042      "maps are.  This program is primarily designed to support files written "
00043      "by Lightwave version 6.x (LWO2 files), but it also has some limited "
00044      "support for version 5.x files (LWOB files).");
00045 
00046   redescribe_option
00047     ("cs",
00048      "Specify the coordinate system of the input " + _format_name +
00049      " file.  Normally, this is y-up-left.");
00050 
00051   redescribe_option
00052     ("ui",
00053      "Specify the units of the input Lightwave file.  By convention, "
00054      "this is assumed to be meters if it is unspecified.");
00055 
00056   _coordinate_system = CS_yup_left;
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: LwoToEgg::run
00061 //       Access: Public
00062 //  Description:
00063 ////////////////////////////////////////////////////////////////////
00064 void LwoToEgg::
00065 run() {
00066   _data->set_coordinate_system(_coordinate_system);
00067 
00068   if (_input_units == DU_invalid) {
00069     _input_units = DU_meters;
00070   }
00071 
00072   LwoToEggConverter converter;
00073   converter.set_egg_data(_data);
00074   apply_parameters(converter);
00075 
00076   if (!converter.convert_file(_input_filename)) {
00077     nout << "Errors in conversion.\n";
00078     exit(1);
00079   }
00080 
00081   write_egg_file();
00082   nout << "\n";
00083 }
00084 
00085 
00086 int main(int argc, char *argv[]) {
00087   // A call to pystub() to force libpystub.so to be linked in.
00088   pystub();
00089 
00090   init_liblwo();
00091   LwoToEgg prog;
00092   prog.parse_command_line(argc, argv);
00093   prog.run();
00094   return 0;
00095 }
 All Classes Functions Variables Enumerations