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

pandatool/src/fltprogs/fltInfo.cxx

Go to the documentation of this file.
00001 // Filename: fltInfo.cxx
00002 // Created by:  drose (05Sep01)
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 "fltInfo.h"
00020 
00021 #include "fltHeader.h"
00022 #include "indent.h"
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //     Function: FltInfo::Constructor
00026 //       Access: Public
00027 //  Description:
00028 ////////////////////////////////////////////////////////////////////
00029 FltInfo::
00030 FltInfo() {
00031   set_program_description
00032     ("This program reads a MultiGen OpenFlight (.flt) file and reports "
00033      "some interesting things about its contents.");
00034 
00035   clear_runlines();
00036   add_runline("[opts] input.flt");
00037 
00038   add_option
00039     ("ls", "", 0,
00040      "List the hierarchy in the flt file.",
00041      &FltInfo::dispatch_none, &_list_hierarchy);
00042 }
00043 
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: FltInfo::run
00047 //       Access: Public
00048 //  Description:
00049 ////////////////////////////////////////////////////////////////////
00050 void FltInfo::
00051 run() {
00052   PT(FltHeader) header = new FltHeader(_path_replace);
00053 
00054   nout << "Reading " << _input_filename << "\n";
00055   FltError result = header->read_flt(_input_filename);
00056   if (result != FE_ok) {
00057     nout << "Unable to read: " << result << "\n";
00058     exit(1);
00059   }
00060 
00061   if (header->check_version()) {
00062     nout << "Version is " << header->get_flt_version() / 100.0 << "\n";
00063   }
00064 
00065   if (_list_hierarchy) {
00066     list_hierarchy(header, 0);
00067   }
00068 }
00069 
00070 ////////////////////////////////////////////////////////////////////
00071 //     Function: FltInfo::list_hierarchy
00072 //       Access: Protected
00073 //  Description: Recursively lists the flt file's hierarchy in a
00074 //               meaningful way.
00075 ////////////////////////////////////////////////////////////////////
00076 void FltInfo::
00077 list_hierarchy(FltRecord *record, int indent_level) {
00078   // Maybe in the future we can do something fancier here.
00079   record->write(cout, indent_level);
00080 }
00081 
00082 
00083 ////////////////////////////////////////////////////////////////////
00084 //     Function: FltInfo::handle_args
00085 //       Access: Protected, Virtual
00086 //  Description:
00087 ////////////////////////////////////////////////////////////////////
00088 bool FltInfo::
00089 handle_args(ProgramBase::Args &args) {
00090   if (args.empty()) {
00091     nout << "You must specify the .flt file to read on the command line.\n";
00092     return false;
00093 
00094   } else if (args.size() != 1) {
00095     nout << "You must specify only one .flt file to read on the command line.\n";
00096     return false;
00097   }
00098 
00099   _input_filename = args[0];
00100 
00101   return true;
00102 }
00103 
00104 
00105 int main(int argc, char *argv[]) {
00106   FltInfo prog;
00107   prog.parse_command_line(argc, argv);
00108   prog.run();
00109   return 0;
00110 }

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