#include <maya/MIOStream.h>
#include <stdio.h>
#include <stdlib.h>
#include <maya/MFn.h>
#include <maya/MPxNode.h>
#include <maya/MPxManipContainer.h>
#include <maya/MPxSelectionContext.h>
#include <maya/MPxContextCommand.h>
#include <maya/MModelMessage.h>
#include <maya/MFnPlugin.h>
#include <maya/MGlobal.h>
#include <maya/MItSelectionList.h>
#include <maya/MPoint.h>
#include <maya/MVector.h>
#include <maya/MDagPath.h>
#include <maya/MManipData.h>
#include <maya/MMatrix.h>
#include <maya/MFnFreePointTriadManip.h>
#include <maya/MFnDistanceManip.h>
{
public:
moveManip();
~moveManip() override;
static void * creator();
private:
void updateManipLocations(
const MObject &node);
public:
};
moveManip::moveManip()
{
}
moveManip::~moveManip()
{
}
void *moveManip::creator()
{
return new moveManip();
}
{
return stat;
}
MStatus moveManip::createChildren()
{
fDistanceManip = addDistanceManip("distanceManip",
"distance");
MPoint startPoint(0.0, 0.0, 0.0);
distanceManipFn.setStartPoint(startPoint);
distanceManipFn.setDirection(direction);
fFreePointManip = addFreePointTriadManip("pointManip",
"freePoint");
return stat;
}
void moveManip::updateManipLocations(
const MObject &node)
{
double rot[3];
manipFn.setRotation(rot, rOrder);
}
{
MPlug syPlug = nodeFn.findPlug(
"scaleY",
true, &stat);
MPlug tPlug = nodeFn.findPlug(
"translate",
true, &stat);
distanceManipFn.connectToDistancePlug(syPlug);
freePointManipFn.connectToPointPlug(tPlug);
updateManipLocations(node);
finishAddingManips();
return stat;
}
{
}
{
public:
MoveManipContext();
static void updateManipulators(void * data);
private:
MCallbackId id1;
};
MoveManipContext::MoveManipContext()
{
MString str(
"Plugin move Manipulator");
setTitleString(str);
}
void MoveManipContext::toolOnSetup(
MEvent &)
{
MString str(
"Move the object using the manipulator");
setHelpString(str);
updateManipulators(this);
updateManipulators,
this, &status);
if (!status) {
}
}
void MoveManipContext::toolOffCleanup()
{
if (!status) {
}
}
void MoveManipContext::updateManipulators(void * data)
{
MoveManipContext * ctxPtr = (MoveManipContext *) data;
ctxPtr->deleteManipulators();
if (MS::kSuccess == stat) {
for (; !iter.isDone(); iter.next()) {
iter.getDependNode(dependNode);
{
"a depend node.");
continue;
}
MPlug rPlug = dependNodeFn.findPlug(
"translate",
true, &stat);
MPlug sPlug = dependNodeFn.findPlug(
"scaleY",
true, &stat);
dependNodeFn.name());
continue;
}
moveManip* manipulator =
(moveManip *) moveManip::newManipulator(manipName, manipObject);
if (NULL != manipulator) {
ctxPtr->addManipulator(manipObject);
if (!manipulator->connectToDependNode(dependNode))
{
" object: " + dependNodeFn.name());
}
}
}
}
}
{
public:
moveManipContext() {};
public:
static void* creator();
};
{
return new MoveManipContext();
}
void *moveManipContext::creator()
{
return new moveManipContext;
}
{
MFnPlugin plugin(obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerContextCommand("moveManipContext",
&moveManipContext::creator);
if (!status) {
return status;
}
status = plugin.registerNode("moveManip", moveManip::id,
&moveManip::creator, &moveManip::initialize,
if (!status) {
return status;
}
return status;
}
{
status = plugin.deregisterContextCommand("moveManipContext");
if (!status) {
return status;
}
status = plugin.deregisterNode(moveManip::id);
if (!status) {
return status;
}
return status;
}