From ea17cc3fc020cb32c07a80312bde7fc901eda9dd Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 6 Oct 2005 18:04:42 +0000 Subject: [PATCH] respect -a for animate --- pandatool/src/mayaprogs/mayaPview.cxx | 34 +++++++++++++++++++---- pandatool/src/mayaprogs/mayaPview.h | 4 +-- pandatool/src/mayaprogs/mayaSavePview.cxx | 32 ++++++++++++++++++--- pandatool/src/mayaprogs/mayaSavePview.h | 2 +- 4 files changed, 59 insertions(+), 13 deletions(-) diff --git a/pandatool/src/mayaprogs/mayaPview.cxx b/pandatool/src/mayaprogs/mayaPview.cxx index c800051755..225162c42b 100755 --- a/pandatool/src/mayaprogs/mayaPview.cxx +++ b/pandatool/src/mayaprogs/mayaPview.cxx @@ -32,6 +32,9 @@ #include #include #include +#include +#include +#include #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(); diff --git a/pandatool/src/mayaprogs/mayaPview.h b/pandatool/src/mayaprogs/mayaPview.h index 1cfc96745c..17f5358dbb 100755 --- a/pandatool/src/mayaprogs/mayaPview.h +++ b/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); diff --git a/pandatool/src/mayaprogs/mayaSavePview.cxx b/pandatool/src/mayaprogs/mayaSavePview.cxx index bd7ff5f7a4..7570cb0435 100644 --- a/pandatool/src/mayaprogs/mayaSavePview.cxx +++ b/pandatool/src/mayaprogs/mayaSavePview.cxx @@ -21,6 +21,9 @@ #include #include #include +#include +#include +#include #include @@ -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) { diff --git a/pandatool/src/mayaprogs/mayaSavePview.h b/pandatool/src/mayaprogs/mayaSavePview.h index 60500b58e2..0021b3ee89 100644 --- a/pandatool/src/mayaprogs/mayaSavePview.h +++ b/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(); };