add mayaSavePview

This commit is contained in:
David Rose 2003-10-28 07:54:43 +00:00
parent c58963671a
commit da3c2a3be9
3 changed files with 191 additions and 0 deletions

View File

@ -95,6 +95,18 @@
#end lib_target
#begin lib_target
#define USE_PACKAGES maya
#define TARGET mayasavepview
#if $[WINDOWS_PLATFORM]
#define dlllib mll
#endif
#define SOURCES \
mayaSavePview.cxx mayaSavePview.h
#end lib_target
#begin lib_target
#define USE_PACKAGES maya
#define TARGET mayaloader

View File

@ -0,0 +1,104 @@
// Filename: mayaSavePview.cxx
// Created by: drose (27Oct03)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, 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://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#include "mayaSavePview.h"
#include <maya/MString.h>
#include <maya/MFnPlugin.h>
#include <maya/MFileIO.h>
#include <stdlib.h>
////////////////////////////////////////////////////////////////////
// Function: MayaSavePview::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
MayaSavePview::
MayaSavePview() {
}
////////////////////////////////////////////////////////////////////
// Function: MayaSavePview::doIt
// Access: Public, Virtual
// Description: Called when the plugin command is invoked.
////////////////////////////////////////////////////////////////////
MStatus MayaSavePview::
doIt(const MArgList &) {
MStatus result;
// First, make sure the current buffer is saved.
result = MFileIO::save(false);
if (result != MS::kSuccess) {
return result;
}
MString filename = MFileIO::currentFile();
MString command = MString("pview \"") + filename + MString("\"");
int command_result = system(command.asChar());
if (command_result != 0) {
return MS::kFailure;
}
return MS::kSuccess;
}
////////////////////////////////////////////////////////////////////
// Function: MayaSavePview::creator
// Access: Public, Static
// Description: This is used to create a new instance of the plugin.
////////////////////////////////////////////////////////////////////
void *MayaSavePview::
creator() {
return new MayaSavePview;
}
////////////////////////////////////////////////////////////////////
// Function: initializePlugin
// Description: Called by Maya when the plugin is loaded.
////////////////////////////////////////////////////////////////////
EXPCL_MISC MStatus
initializePlugin(MObject obj) {
MFnPlugin plugin(obj, "VR Studio", "1.0");
MStatus status;
status = plugin.registerCommand("savePview", MayaSavePview::creator);
if (!status) {
status.perror("registerCommand");
}
return status;
}
////////////////////////////////////////////////////////////////////
// Function: uninitializePlugin
// Description: Called by Maya when the plugin is unloaded.
////////////////////////////////////////////////////////////////////
EXPCL_MISC MStatus
uninitializePlugin(MObject obj) {
MFnPlugin plugin(obj);
MStatus status;
status = plugin.deregisterCommand("savePview");
if (!status) {
status.perror("deregisterCommand");
}
return status;
}

View File

@ -0,0 +1,75 @@
// Filename: mayaSavePview.h
// Created by: drose (27Oct03)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, 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://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef MAYASAVEPVIEW_H
#define MAYASAVEPVIEW_H
// Maya will try to typedef bool unless this symbol is defined.
#ifndef _BOOL
#define _BOOL 1
#endif
#include <maya/MArgList.h>
#include <maya/MPxCommand.h>
#include <maya/MObject.h>
// Even though we don't include any Panda headers, it's safe to
// include this one, since it only defines some macros that we need to
// make this program platform-independent.
#include "dtool_config.h"
////////////////////////////////////////////////////////////////////
// Class : MayaSavePview
// Description : This class serves as a plug-in to Maya to save the
// scene and view it using the external pview program,
// rather than linking in any part of Panda to a Maya
// plugin.
//
// Since it does not link with any Panda code, and hence
// is a very lean plugin, it is less likely than
// MayaPview to cause interoperability problems within
// Maya. However, it does force a save-to-disk and a
// spawning of a separate executable, including a
// complete reloading of all of the Maya libraries, so
// it is quite a bit slower to execute. And the
// potential for interactive control is substantially
// reduced.
////////////////////////////////////////////////////////////////////
class MayaSavePview : public MPxCommand {
public:
MayaSavePview();
virtual MStatus doIt(const MArgList &);
static void *creator();
};
// Since we don't include any of the Panda headers (other than
// dtool_config.h), we have to define this macro ourselves, to tell
// Windows to export the following functions from the DLL.
#ifdef WIN32_VC
#define EXPCL_MISC __declspec(dllexport)
#else
#define EXPCL_MISC
#endif
EXPCL_MISC MStatus initializePlugin(MObject obj);
EXPCL_MISC MStatus uninitializePlugin(MObject obj);
#endif