Panda3D
lwoScan.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file lwoScan.cxx
10  * @author drose
11  * @date 2001-04-24
12  */
13 
14 #include "lwoScan.h"
15 
16 #include "lwoInputFile.h"
17 #include "lwoChunk.h"
18 #include "config_lwo.h"
19 
20 /**
21  *
22  */
23 LwoScan::
24 LwoScan() {
25  clear_runlines();
26  add_runline("[opts] input.lwo");
27 
28  set_program_brief("describe the contents of a Lightwave object file");
29  set_program_description
30  ("This program simply reads a Lightwave object file and dumps its "
31  "contents to standard output. It's mainly useful for debugging "
32  "problems with lwo2egg.");
33 }
34 
35 /**
36  *
37  */
38 void LwoScan::
39 run() {
40  LwoInputFile in;
41  if (!in.open_read(_input_filename)) {
42  nout << "Unable to open " << _input_filename << "\n";
43  exit(1);
44  }
45 
46  PT(IffChunk) chunk = in.get_chunk();
47  if (chunk == nullptr) {
48  nout << "Unable to read file.\n";
49  } else {
50  while (chunk != nullptr) {
51  chunk->write(std::cout, 0);
52  chunk = in.get_chunk();
53  }
54  }
55 }
56 
57 /**
58  *
59  */
60 bool LwoScan::
61 handle_args(ProgramBase::Args &args) {
62  if (args.empty()) {
63  nout << "You must specify the Lightwave object file to read on the command line.\n";
64  return false;
65  }
66  if (args.size() != 1) {
67  nout << "You may specify only one Lightwave object file to read on the command line.\n";
68  return false;
69  }
70 
71  _input_filename = args[0];
72 
73  return true;
74 }
75 
76 
77 int
78 main(int argc, char *argv[]) {
79  init_liblwo();
80  LwoScan prog;
81  prog.parse_command_line(argc, argv);
82  prog.run();
83  return 0;
84 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void init_liblwo()
Initializes the library.
Definition: config_lwo.cxx:68
virtual void parse_command_line(int argc, char **argv)
Dispatches on each of the options on the command line, and passes the remaining parameters to handle_...
bool open_read(Filename filename)
Attempts to open the indicated filename for reading.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The basic kind of record in an EA "IFF" file, which the LightWave object file is based on.
Definition: iffChunk.h:30
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A program to read a Lightwave file and report its structure and contents.
Definition: lwoScan.h:23
A specialization of IffInputFile to handle reading a Lightwave Object file.
Definition: lwoInputFile.h:26