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

pandatool/src/lwoprogs/lwoScan.cxx

Go to the documentation of this file.
00001 // Filename: lwoScan.cxx
00002 // Created by:  drose (24Apr01)
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 "lwoScan.h"
00020 
00021 #include <lwoInputFile.h>
00022 #include <lwoChunk.h>
00023 #include <config_lwo.h>
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //     Function: LwoScan::Constructor
00027 //       Access: Public
00028 //  Description:
00029 ////////////////////////////////////////////////////////////////////
00030 LwoScan::
00031 LwoScan() {
00032   clear_runlines();
00033   add_runline("[opts] input.lwo");
00034 
00035   set_program_description
00036     ("This program simply reads a Lightwave object file and dumps its "
00037      "contents to standard output.  It's mainly useful for debugging "
00038      "problems with lwo2egg.");
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: LwoScan::run
00043 //       Access: Public
00044 //  Description:
00045 ////////////////////////////////////////////////////////////////////
00046 void LwoScan::
00047 run() {
00048   LwoInputFile in;
00049   if (!in.open_read(_input_filename)) {
00050     nout << "Unable to open " << _input_filename << "\n";
00051     exit(1);
00052   }
00053 
00054   PT(IffChunk) chunk = in.get_chunk();
00055   if (chunk == (IffChunk *)NULL) {
00056     nout << "Unable to read file.\n";
00057   } else {
00058     while (chunk != (IffChunk *)NULL) {
00059       chunk->write(cout, 0);
00060       chunk = in.get_chunk();
00061     }
00062   }
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: LwoScan::handle_args
00067 //       Access: Protected, Virtual
00068 //  Description:
00069 ////////////////////////////////////////////////////////////////////
00070 bool LwoScan::
00071 handle_args(ProgramBase::Args &args) {
00072   if (args.empty()) {
00073     nout << "You must specify the Lightwave object file to read on the command line.\n";
00074     return false;
00075   }
00076   if (args.size() != 1) {
00077     nout << "You may specify only one Lightwave object file to read on the command line.\n";
00078     return false;
00079   }
00080 
00081   _input_filename = args[0];
00082 
00083   return true;
00084 }
00085 
00086 
00087 int
00088 main(int argc, char *argv[]) {
00089   init_liblwo();
00090   LwoScan prog;
00091   prog.parse_command_line(argc, argv);
00092   prog.run();
00093   return 0;
00094 }

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