Here are few steps for developing plugins from scratch and not using the wizard, thanks to Rob Bateman for most of the info,
1. Create dll project
2. add a c++ file to it
3. change the output extension to mll
4. change project settings->C/C++->Code generation to Multi-threaded or Multi-threaded-debug
5. add NT_PLUGIN & REQUIRE_IOSTREAM to the C/C++ -> pre-processor defines in the project settings
6. set the library and include paths to the maya API (additional include directories, and additional lib directories (Foundation.lib, OpenMaya.lib)
in the cpp file:
//
#include <maya/MFnPlugin.h>
#include <maya/MPxCommand.h>
//
// link libs under VisualC++/Win32
#ifdef WIN32
#pragma comment(lib,"Foundation.lib")
#pragma comment(lib,"OpenMaya.lib")
#pragma comment(lib,"OpenMayaFx.lib")
#pragma comment(lib,"OpenMayaUi.lib")
#pragma comment(lib,"Image.lib")
#pragma comment(lib,"OpenMayaAnim.lib")
#pragma comment(lib,"OpenGl32.lib")
#pragma comment(lib,"glu32.lib")
#endif
#ifdef WIN32
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
//--------------------------------------------------------------------------------------------------
class helloCmd : public MPxCommand{
public:
virtual MStatus doIt(const MArgList&);
static void *creator(){
return new helloCmd;
}
};
//--------------------------------------------------------------------------------------------------
MStatus helloCmd::doIt(const MArgList& args){
MStatus status = MS::kSuccess;
MGlobal::displayInfo("Hello\n");
setResult("initialized");
return status;
}
//--------------------------------------------------------------------------------------------------
EXPORT MStatus initializePlugin( MObject obj )
{
MStatus status;
MFnPlugin pluginFn( obj, "Vishang Shah", "1.0");
status = pluginFn.registerCommand("helloCmd",helloCmd::creator);
if(!status)
status.perror("registerCommand Failed");
return status;
}
EXPORT MStatus uninitializePlugin( MObject obj)
{
MFnPlugin pluginFn( obj );
MStatus status;
status = pluginFn.deregisterCommand("helloCmd");
if(!status)
status.perror("deregister failed");
return status;
}
//--------------------------------------------------------------------------------------------------
Maya Plugin Development Primer
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment