-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPluginMain.cpp
More file actions
89 lines (68 loc) · 1.95 KB
/
Copy pathPluginMain.cpp
File metadata and controls
89 lines (68 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <maya/MFnPlugin.h>
#include <maya/MGlobal.h>
#include <maya/MApiNamespace.h>
#include <maya/MViewport2Renderer.h>
#include <maya/MDrawRegistry.h>
#include <stdio.h>
// nodes
#include "MeshLoader.h"
bool RegisterPluginUI()
{
// Create menu
MGlobal::executeCommand(MString("string $mpt_root_menu = `menu -l \"Mesh Tools\" -p MayaWindow -allowOptionBoxes true`"));
MGlobal::executeCommand(MString("menuItem -label \"Create mesh loader\" -command \"createMeshLoader()\""));
return true;
}
bool DeregisterPluginUI()
{
MGlobal::executeCommand(MString("deleteUI -m $mpt_root_menu"));
// delete template editors
MGlobal::executeCommand(MString("MPT_RemoveEditorTemplate(\"MeshLoaderNode\")"));
return true;
}
MStatus initializePlugin(MObject obj)
{
MStatus status;
MFnPlugin plugin(obj, "Jan Bender", "1.0", "Any");
MString pluginPath = plugin.loadPath();
MString scriptPath = pluginPath + "/scripts";
// add path of plugin to script path
#ifdef WIN32
MGlobal::executeCommand(MString("$s=`getenv \"MAYA_SCRIPT_PATH\"`; putenv \"MAYA_SCRIPT_PATH\" ($s + \";") + scriptPath + "\")");
#else
MGlobal::executeCommand(MString("$s=`getenv \"MAYA_SCRIPT_PATH\"`; putenv \"MAYA_SCRIPT_PATH\" ($s + \":") + scriptPath + "\")");
#endif
// execute the specified mel script
status = MGlobal::sourceFile("MayaMeshTools.mel");
status = plugin.registerNode("MeshLoader", MeshLoader::m_id,
&MeshLoader::creator, &MeshLoader::initialize,
MPxNode::kEmitterNode);
if (!status)
{
status.perror("register MeshLoader");
return status;
}
if (!RegisterPluginUI())
{
status.perror("Failed to create UI");
return status;
}
return status;
}
MStatus uninitializePlugin(MObject obj)
{
MStatus status;
MFnPlugin plugin(obj);
status = plugin.deregisterNode(MeshLoader::m_id);
if (!status)
{
status.perror("deregister MeshLoader");
return status;
}
if (!DeregisterPluginUI())
{
status.perror("Failed to deregister UI");
return status;
}
return status;
}