forked from code-google-com/stretchmesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pluginMain.cpp
112 lines (91 loc) · 2.63 KB
/
pluginMain.cpp
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <iostream>
#include <maya/MFnPlugin.h>
#include <maya/MIOStream.h>
#include <maya/MGlobal.h>
#include <maya/MSceneMessage.h>
#include "stretchMeshDeformer.h"
#include "stretchMeshCmd.h"
#include "stretchMeshConsts.h"
#include "curveColliderLocator.h"
using namespace std;
//---------------------------------------------------------------------------------------------------------------------
// initializePlugin / uninitializePlugin
//---------------------------------------------------------------------------------------------------------------------
MStatus initializePlugin( MObject obj )
{
char smVersionStr[16];
sprintf(smVersionStr, "%.1f", SM_VERSION);
MStatus status;
MFnPlugin plugin( obj, "Kickstand", smVersionStr, "Any");
bool licensed = true;
MString buildMenuCmd;
if ( licensed )
{
buildMenuCmd = "int $smCmdEcho;\n";
buildMenuCmd += "$smCmdEcho = `commandEcho -q -state`;\n";
buildMenuCmd += "commandEcho -state off;\n";
MGlobal::executeCommand(buildMenuCmd);
}
// Register Deformer, passing licensed parameter
status = stretchMeshDeformer::Register( plugin, licensed );
if (!status) {
status.perror("Couldn't register plugin");
return status;
}
// Register Command only if licensed
if ( licensed )
{
status = stretchMeshCmd::Register( plugin );
if (!status) {
status.perror("Couldn't register plugin");
return status;
}
}
// Register Curve Collider Locator
status = curveColliderLocator::Register( plugin );
if (!status) {
status.perror("Couldn't register plugin");
return status;
}
// Make the stiffness attribute paintable only if licensed
if ( licensed )
{
MGlobal::executeCommand("makePaintable -attrType \"multiFloat\" -sm \"deformer\" \"weightGeometryFilter\" \"stiffness\"");
stretchMeshCmd::buildstretchMeshCmdMenu();
buildMenuCmd = "commandEcho -state $smCmdEcho;\n";
MGlobal::executeCommand(buildMenuCmd);
}
return MStatus::kSuccess;
}
MStatus uninitializePlugin( MObject obj)
{
MStatus status;
MFnPlugin plugin( obj );
if ( stretchMeshCmd::Registered )
{
// Remove Menu
MGlobal::executeCommand("catch(`stretchMeshCmdMenuRemove`)");
status = stretchMeshCmd::Deregister( plugin );
if (!status) {
status.perror("Couldn't unload plugin.");
return status;
}
}
if ( stretchMeshDeformer::Registered )
{
status = stretchMeshDeformer::Deregister( plugin );
if (!status) {
status.perror("Couldn't unload plugin.");
return status;
}
}
if ( curveColliderLocator::Registered )
{
status = curveColliderLocator::Deregister( plugin );
if (!status) {
status.perror("Couldn't unload plugin.");
return status;
}
}
return status;
}