Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/fltprogs/fltToEgg.cxx

Go to the documentation of this file.
00001 // Filename: fltToEgg.cxx
00002 // Created by:  drose (17Apr01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "fltToEgg.h"
00020 
00021 #include <fltToEggConverter.h>
00022 #include <config_flt.h>
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //     Function: FltToEgg::Constructor
00026 //       Access: Public
00027 //  Description:
00028 ////////////////////////////////////////////////////////////////////
00029 FltToEgg::
00030 FltToEgg() :
00031   SomethingToEgg("MultiGen", ".flt")
00032 {
00033   add_path_replace_options();
00034   add_path_store_options();
00035   add_units_options();
00036   add_normals_options();
00037   add_transform_options();
00038   add_merge_externals_options();
00039 
00040   set_program_description
00041     ("This program converts MultiGen OpenFlight (.flt) files to egg.  Most "
00042      "features of MultiGen that are also recognized by egg are supported.");
00043 
00044   redescribe_option
00045     ("cs",
00046      "Specify the coordinate system of the input " + _format_name +
00047      " file.  Normally, this is z-up.");
00048 
00049   // Does anyone really care about this option?  It's mainly useful
00050   // for debugging the flt2egg logic.
00051   /*
00052   add_option
00053     ("C", "", 0,
00054      "Compose node transforms into a single matrix before writing them to "
00055      "the egg file, instead of writing them as individual scale, rotate, and "
00056      "translate operations.",
00057      &FltToEgg::dispatch_none, &_compose_transforms);
00058   */
00059   _compose_transforms = false;
00060 
00061   _coordinate_system = CS_zup_right;
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function: FltToEgg::run
00066 //       Access: Public
00067 //  Description:
00068 ////////////////////////////////////////////////////////////////////
00069 void FltToEgg::
00070 run() {
00071   PT(FltHeader) header = new FltHeader(_path_replace);
00072 
00073   nout << "Reading " << _input_filename << "\n";
00074   FltError result = header->read_flt(_input_filename);
00075   if (result != FE_ok) {
00076     nout << "Unable to read: " << result << "\n";
00077     exit(1);
00078   }
00079 
00080   header->check_version();
00081 
00082   _data.set_coordinate_system(_coordinate_system);
00083 
00084   if (_input_units == DU_invalid) {
00085     _input_units = header->get_units();
00086   }
00087 
00088   FltToEggConverter converter;
00089   converter.set_merge_externals(_merge_externals);
00090   converter.set_egg_data(&_data, false);
00091   converter._compose_transforms = _compose_transforms;
00092   converter._allow_errors = _allow_errors;
00093 
00094   apply_parameters(converter);
00095 
00096   if (!converter.convert_flt(header)) {
00097     nout << "Errors in conversion.\n";
00098     exit(1);
00099   }
00100 
00101   write_egg_file();
00102   nout << "\n";
00103 }
00104 
00105 
00106 int main(int argc, char *argv[]) {
00107   init_libflt();
00108   FltToEgg prog;
00109   prog.parse_command_line(argc, argv);
00110   prog.run();
00111   return 0;
00112 }

Generated on Fri May 2 03:19:58 2003 for Panda-Tool by doxygen1.3