#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/MEulerRotation.h>
#include <maya/MFnRotateManip.h>
#include <maya/MFnStateManip.h>
{
double x,y,z;
return result;
}
else {
return result;
}
}
{
public:
exampleRotateManip();
~exampleRotateManip() override;
static void * creator();
MManipData rotationChangedCallback(
unsigned index);
public:
private:
unsigned rotatePlugIndex;
};
MTypeId exampleRotateManip::id( 0x80022 );
exampleRotateManip::exampleRotateManip()
{
}
exampleRotateManip::~exampleRotateManip()
{
}
void *exampleRotateManip::creator()
{
return new exampleRotateManip();
}
MStatus exampleRotateManip::initialize()
{
}
MStatus exampleRotateManip::createChildren()
{
fRotateManip = addRotateManip("RotateManip", "rotation");
fStateManip = addStateManip("StateManip", "state");
stateManip.setMaxStates(4);
stateManip.setInitialState(0);
return stat;
}
{
MPlug rPlug = nodeFn.findPlug(
"rotate",
true, &stat);
if (!stat)
{
return stat;
}
MPlug rcPlug = nodeFn.findPlug(
"rotatePivot",
true, &stat);
if (!stat)
{
return stat;
}
MPlug tPlug = nodeFn.findPlug(
"translate",
true, &stat);
MVector existingTranslation(vectorPlugValue(tPlug));
rotateManip.setInitialRotation(existingRotation);
rotateManip.displayWithNode(node);
rotatePlugIndex = addManipToPlugConversionCallback( rPlug,
(manipToPlugConversionCallback)
&exampleRotateManip::rotationChangedCallback );
rotateManip.connectToRotationCenterPlug(rcPlug);
stateManip.setTranslation(existingTranslation+
MVector(2,0,0),
addPlugToInViewEditor( rxPlug );
addPlugToInViewEditor( ryPlug );
addPlugToInViewEditor( rzPlug );
finishAddingManips();
return stat;
}
MManipData exampleRotateManip::rotationChangedCallback(
unsigned index) {
if (index != rotatePlugIndex)
{
return obj;
}
int mode = stateManip.state();
if (mode != 3)
{
rotateManip.setSnapMode(false);
}
else {
rotateManip.setSnapMode(true);
rotateManip.setSnapIncrement(15.0);
}
if (!getConverterManipValue (rotateManip.rotationIndex(), manipRotation))
{
}
else {
numericData.
setData(manipRotation.
x, manipRotation.
y, manipRotation.
z);
}
}
{
public:
RotateManipContext();
static void updateManipulators(void * data);
private:
MCallbackId id1;
};
RotateManipContext::RotateManipContext()
{
MString str(
"Plugin Rotate Manipulator");
setTitleString(str);
}
void RotateManipContext::toolOnSetup(
MEvent &)
{
MString str(
"Rotate the object using the rotation handles");
setHelpString(str);
updateManipulators(this);
updateManipulators,
this, &status);
if (!status) {
}
}
void RotateManipContext::toolOffCleanup()
{
if (!status) {
}
}
void RotateManipContext::updateManipulators(void * data)
{
RotateManipContext * ctxPtr = (RotateManipContext *) data;
ctxPtr->deleteManipulators();
if (MS::kSuccess == stat) {
for (; !iter.isDone(); iter.next()) {
iter.getDependNode(dependNode);
{
"a depend node.");
continue;
}
dependNodeFn.findPlug("rotate", true, &stat);
if (!stat) {
dependNodeFn.name());
continue;
}
MString manipName (
"exampleRotateManip");
exampleRotateManip* manipulator =
(exampleRotateManip *) exampleRotateManip::newManipulator(
manipName,
manipObject);
if (NULL != manipulator) {
ctxPtr->addManipulator(manipObject);
if (!manipulator->connectToDependNode(dependNode))
{
" object: " + dependNodeFn.name());
}
}
}
}
}
{
public:
rotateContext() {};
public:
static void* creator();
};
{
return new RotateManipContext();
}
void *rotateContext::creator()
{
return new rotateContext;
}
{
MFnPlugin plugin(obj, PLUGIN_COMPANY,
"6.0",
"Any");
status = plugin.registerContextCommand("rotateContext",
&rotateContext::creator);
if (!status) {
return status;
}
status = plugin.registerNode("exampleRotateManip", exampleRotateManip::id,
&exampleRotateManip::creator, &exampleRotateManip::initialize,
if (!status) {
return status;
}
return status;
}
{
status = plugin.deregisterContextCommand("rotateContext");
if (!status) {
return status;
}
status = plugin.deregisterNode(exampleRotateManip::id);
if (!status) {
return status;
}
return status;
}