您的位置:首页 > 编程语言 > Qt开发

Using qt to develop maya plugin on windows

2016-07-09 03:25 381 查看
1. download the maya develop kit 
https://apps.autodesk.com/MAYA/en/Detail/Index?id=6303159649350432165&appLang=en&os=Win64
then extract to C:\Program Files\Autodesk\Maya2016

2. set environmental variable:

MAYA_PATH = c:\Program Files\Autodesk\Maya2016

add c:\Program Files\Autodesk\Maya2016\bin; to Path

3.new a plain C++ Application project 

4.overwrite the .pro file as follows:

TEMPLATE = lib

TARGET = Hello

CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt

QMAKE_EXTENSION_SHLIB = mll

QMAKE_LFLAGS = /export:initializePlugin /export:uninitializePlugin /SUBSYSTEM:WINDOWS
_CFLAGS = /FD /GS
QMAKE_CFLAGS += $${_CFLAGS}
QMAKE_CXXFLAGS += $${_CFLAGS}

SOURCES += \
main.cpp

DEFINES += WIN32 \
_WIN64 \
_WINDOWS \
_USRDLL \
NT_PLUGIN \
REQUIRE_IOSTREAM \
_BOOL
INCLUDEPATH += $$(MAYA_PATH)/include \

QMAKE_LIBDIR += $$(MAYA_PATH)/lib

LIBS += -lFoundation -lOpenMaya -lOpenMayaUI

#OBJECTS_DIR = ""


5. create a c++ source file and write into it with following contents:
#include <maya/MSimple.h>
#include <maya/MIOStream.h>
#include <maya/MGlobal.h>

DeclareSimpleCommand( HelloMaya , "NCCA", "Maya 2016") //HelloMaya is the class name

MStatus HelloMaya::doIt( const MArgList& )
{
std::cout<<"This should come from the shell\n"<<std::endl;
MGlobal::displayInfo("Hello Maya in the maya command shell");
return MS::kSuccess;
}


6. Now we can copy the Hello.mll to C:\Program Files\Autodesk\Maya2016\bin\plug-ins

7.open maya, type and execute HelloMaya in maya command shell 



note: the command HelloMaya is the class name not the plugin's name.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: