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