Browse Source

added eggRename tool

Asad M. Zaman 20 years ago
parent
commit
7cb711d9bc

+ 1 - 2
pandatool/src/egg-optchar/eggOptchar.cxx

@@ -253,7 +253,7 @@ run() {
     // Also quantize the animation channels, if the user so requested.
     quantize_channels();
 
-    // Finally, flag all the groups as the user requested.
+    // flag all the groups as the user requested.
     if (!_flag_groups.empty()) {
       Eggs::iterator ei;
       for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
@@ -1346,7 +1346,6 @@ rename_primitives(EggGroupNode *egg_group, const string &name) {
   }
 }
 
-
 int main(int argc, char *argv[]) {
   EggOptchar prog;
   prog.parse_command_line(argc, argv);

+ 8 - 0
pandatool/src/eggprogs/Sources.pp

@@ -7,6 +7,14 @@
   dtoolutil:c dtoolbase:c prc:c dconfig:c dtoolconfig:m dtool:m pystub
 #define UNIX_SYS_LIBS m
 
+#begin bin_target
+  #define TARGET egg-rename
+
+  #define SOURCES \
+    eggRename.cxx eggRename.h
+
+#end bin_target
+
 #begin bin_target
   #define TARGET egg-trans
 

+ 66 - 0
pandatool/src/eggprogs/eggRename.cxx

@@ -0,0 +1,66 @@
+// Filename: eggRename.cxx
+// Created by:  masad (22Apr05)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "eggRename.h"
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggRename::Constructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+EggRename::
+EggRename() {
+  set_program_description
+    ("egg-rename reads one or more egg files and writes back with modified"
+     "node names. ie. suppressing prefix from all the nodes' names. ");
+
+  add_option
+    ("strip_prefix", "name", 0,
+     "strips out the prefix that is put on all nodes, by maya ext. ref",
+     &EggRename::dispatch_vector_string, NULL, &_strip_prefix);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggRename::run
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+void EggRename::
+run() {
+  if (!_strip_prefix.empty()) {
+    nout << "Stripping prefix from nodes.\n";
+    int num_renamed = 0;
+    int num_egg_files = 0;
+    Eggs::iterator ei;
+    for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) {
+      num_renamed += (*ei)->rename_nodes(_strip_prefix, true);
+      ++num_egg_files;
+    }
+    nout << "  (" << num_renamed << " renamed.)\n";
+  }
+
+  write_eggs();
+}
+
+
+int main(int argc, char *argv[]) {
+  EggRename prog;
+  prog.parse_command_line(argc, argv);
+  prog.run();
+  return 0;
+}

+ 42 - 0
pandatool/src/eggprogs/eggRename.h

@@ -0,0 +1,42 @@
+// Filename: eggRename.h
+// Created by:  masad (22Apr05)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef EGGRENAME_H
+#define EGGRENAME_H
+
+#include "pandatoolbase.h"
+
+#include "eggMultiFilter.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : EggTrans
+// Description : A program to read an egg file and write an equivalent
+//               egg file, with stripping prefix for now, but more
+//               along the way.
+////////////////////////////////////////////////////////////////////
+class EggRename : public EggMultiFilter {
+public:
+  EggRename();
+
+  void run();
+
+  vector_string _strip_prefix;
+};
+
+#endif
+