Panda3D

eggRename.cxx

00001 // Filename: eggRename.cxx
00002 // Created by:  masad (22Apr05)
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 "eggRename.h"
00016 #include "pystub.h"
00017 
00018 ////////////////////////////////////////////////////////////////////
00019 //     Function: EggRename::Constructor
00020 //       Access: Public
00021 //  Description:
00022 ////////////////////////////////////////////////////////////////////
00023 EggRename::
00024 EggRename() {
00025   set_program_description
00026     ("egg-rename reads one or more egg files and writes back with modified"
00027      "node names. ie. suppressing prefix from all the nodes' names. ");
00028 
00029   add_option
00030     ("strip_prefix", "name", 0,
00031      "strips out the prefix that is put on all nodes, by maya ext. ref",
00032      &EggRename::dispatch_vector_string, NULL, &_strip_prefix);
00033 }
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //     Function: EggRename::run
00037 //       Access: Public
00038 //  Description:
00039 ////////////////////////////////////////////////////////////////////
00040 void EggRename::
00041 run() {
00042   if (!_strip_prefix.empty()) {
00043     nout << "Stripping prefix from nodes.\n";
00044     int num_renamed = 0;
00045     int num_egg_files = 0;
00046     Eggs::iterator ei;
00047     for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
00048       num_renamed += (*ei)->rename_nodes(_strip_prefix, true);
00049       ++num_egg_files;
00050     }
00051     nout << "  (" << num_renamed << " renamed.)\n";
00052   }
00053 
00054   write_eggs();
00055 }
00056 
00057 
00058 int main(int argc, char *argv[]) {
00059   // A call to pystub() to force libpystub.so to be linked in.
00060   pystub();
00061 
00062   EggRename prog;
00063   prog.parse_command_line(argc, argv);
00064   prog.run();
00065   return 0;
00066 }
 All Classes Functions Variables Enumerations