Jelajahi Sumber

respect -a for animate

David Rose 20 tahun lalu
induk
melakukan
ea17cc3fc0

+ 28 - 6
pandatool/src/mayaprogs/mayaPview.cxx

@@ -32,6 +32,9 @@
 #include <maya/MString.h>
 #include <maya/MFnPlugin.h>
 #include <maya/MFileIO.h>
+#include <maya/MArgParser.h>
+#include <maya/MArgList.h>
+#include <maya/MSyntax.h>
 #include "post_maya_include.h"
 
 ////////////////////////////////////////////////////////////////////
@@ -49,13 +52,30 @@ MayaPview() {
 //  Description: Called when the plugin command is invoked.
 ////////////////////////////////////////////////////////////////////
 MStatus MayaPview::
-doIt(const MArgList &) {
+doIt(const MArgList &args) {
+  MStatus result;
+
+  // First, parse the plugin arguments.
+  MSyntax syntax;
+  syntax.addFlag("a", "animate");
+
+  MArgParser parser(syntax, args, &result);
+  if (!result) {
+    result.perror("arguments");
+    return result;
+  }
+
+  bool animate = parser.isFlagSet("a", &result);
+  if (!result) {
+    result.perror("isFlagSet");
+    return result;
+  }
+
   // Maya seems to run each invocation of the plugin in a separate
   // thread.  To minimize conflict in our
   // not-yet-completely-thread-safe Panda, we'll create a separate
   // PandaFramework for each invocation, even though in principle we
   // could be sharing one framework for all of them.
-
   int argc = 0;
   char **argv = NULL;
   PandaFramework framework;
@@ -93,7 +113,7 @@ doIt(const MArgList &) {
   window->setup_trackball();
   framework.get_models().instance_to(window->get_render());
 
-  if (!convert(framework.get_models())) {
+  if (!convert(framework.get_models(), animate)) {
     nout << "failure in conversion.\n";
     return MS::kFailure;
   }
@@ -125,7 +145,7 @@ creator() {
 //               geometry, and parents it to the indicated NodePath.
 ////////////////////////////////////////////////////////////////////
 bool MayaPview::
-convert(const NodePath &parent) {
+convert(const NodePath &parent, bool animate) {
   // Now make a converter to get all the Maya structures.
   MayaToEggConverter converter("plug-in");
 
@@ -133,8 +153,10 @@ convert(const NodePath &parent) {
   // results.
   converter._polygon_output = true;
 
-  // We also want to get the animation if there is any.
-  converter.set_animation_convert(AC_both);
+  if (animate) {
+    // We also want to get the animation if there is any.
+    converter.set_animation_convert(AC_both);
+  }
 
   PathReplace *path_replace = converter.get_path_replace();
 

+ 2 - 2
pandatool/src/mayaprogs/mayaPview.h

@@ -37,12 +37,12 @@
 class MayaPview : public MPxCommand {
 public:
   MayaPview();
-  virtual MStatus doIt(const MArgList &);
+  virtual MStatus doIt(const MArgList &args);
 
   static void *creator();
 
 private:
-  bool convert(const NodePath &parent);
+  bool convert(const NodePath &parent, bool animate);
 };
 
 EXPCL_MISC MStatus initializePlugin(MObject obj);

+ 28 - 4
pandatool/src/mayaprogs/mayaSavePview.cxx

@@ -21,6 +21,9 @@
 #include <maya/MString.h>
 #include <maya/MFnPlugin.h>
 #include <maya/MFileIO.h>
+#include <maya/MArgParser.h>
+#include <maya/MArgList.h>
+#include <maya/MSyntax.h>
 
 #include <stdlib.h>
 
@@ -43,10 +46,26 @@ MayaSavePview() {
 //  Description: Called when the plugin command is invoked.
 ////////////////////////////////////////////////////////////////////
 MStatus MayaSavePview::
-doIt(const MArgList &) {
+doIt(const MArgList &args) {
   MStatus result;
+
+  // First, parse the plugin arguments.
+  MSyntax syntax;
+  syntax.addFlag("a", "animate");
+
+  MArgParser parser(syntax, args, &result);
+  if (!result) {
+    result.perror("arguments");
+    return result;
+  }
+
+  bool animate = parser.isFlagSet("a", &result);
+  if (!result) {
+    result.perror("isFlagSet");
+    return result;
+  }
   
-  // First, make sure the current buffer is saved.
+  // Now make sure the current buffer is saved.
   result = MFileIO::save(false);
   if (result != MS::kSuccess) {
     return result;
@@ -54,12 +73,17 @@ doIt(const MArgList &) {
 
   MString filename = MFileIO::currentFile();
 
+  MString pview_args = "-cl";
+  if (animate) {
+    pview_args = "-cla";
+  }
+
 #ifdef WIN32_VC
   // On Windows, we use the spawn function to run pview
   // asynchronously.
   MString quoted = MString("\"") + filename + MString("\"");
   int retval = _spawnlp(_P_DETACH, "pview", 
-                        "pview", "-cla", quoted.asChar(), NULL);
+                        "pview", pview_args.asChar(), quoted.asChar(), NULL);
   if (retval == -1) {
     return MS::kFailure;
   }
@@ -68,7 +92,7 @@ doIt(const MArgList &) {
   // On non-Windows (e.g. Unix), we just use the system function,
   // which runs synchronously.  We could fork a process, but no one's
   // asked for this yet.
-  MString command = MString("pview -cla \"") + filename + MString("\"");
+  MString command = MString("pview " + pview_args + MString(" \"") + filename + MString("\"");
 
   int command_result = system(command.asChar());
   if (command_result != 0) {

+ 1 - 1
pandatool/src/mayaprogs/mayaSavePview.h

@@ -64,7 +64,7 @@
 class MayaSavePview : public MPxCommand {
 public:
   MayaSavePview();
-  virtual MStatus doIt(const MArgList &);
+  virtual MStatus doIt(const MArgList &args);
 
   static void *creator();
 };