Panda3D
eggRename.cxx
1 // Filename: eggRename.cxx
2 // Created by: masad (22Apr05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "eggRename.h"
16 #include "pystub.h"
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: EggRename::Constructor
20 // Access: Public
21 // Description:
22 ////////////////////////////////////////////////////////////////////
23 EggRename::
24 EggRename() {
25  set_program_brief("rename nodes in .egg files");
26  set_program_description
27  ("egg-rename reads one or more egg files and writes back with modified"
28  "node names. ie. suppressing prefix from all the nodes' names. ");
29 
30  add_option
31  ("strip_prefix", "name", 0,
32  "strips out the prefix that is put on all nodes, by maya ext. ref",
33  &EggRename::dispatch_vector_string, NULL, &_strip_prefix);
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: EggRename::run
38 // Access: Public
39 // Description:
40 ////////////////////////////////////////////////////////////////////
41 void EggRename::
42 run() {
43  if (!_strip_prefix.empty()) {
44  nout << "Stripping prefix from nodes.\n";
45  int num_renamed = 0;
46  int num_egg_files = 0;
47  Eggs::iterator ei;
48  for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
49  num_renamed += (*ei)->rename_nodes(_strip_prefix, true);
50  ++num_egg_files;
51  }
52  nout << " (" << num_renamed << " renamed.)\n";
53  }
54 
55  write_eggs();
56 }
57 
58 
59 int main(int argc, char *argv[]) {
60  // A call to pystub() to force libpystub.so to be linked in.
61  pystub();
62 
63  EggRename prog;
64  prog.parse_command_line(argc, argv);
65  prog.run();
66  return 0;
67 }
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_...
A program to read an egg file and write an equivalent egg file, with stripping prefix for now...
Definition: eggRename.h:28