#include <maya/MIOStream.h>
#include <maya/MPxNode.h>
#include <maya/MFnPlugin.h>
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MRampAttribute.h>
#include <maya/MCurveAttribute.h>
class exampleRampAttrNode :
public MPxNode
{
public:
exampleRampAttrNode() {};
~exampleRampAttrNode() override {};
static void *creator();
};
MTypeId exampleRampAttrNode::id( 0x81027 );
MObject exampleRampAttrNode::input1;
MObject exampleRampAttrNode::input2;
MObject exampleRampAttrNode::input3;
void *exampleRampAttrNode::creator()
{
return((void *) new exampleRampAttrNode);
}
void exampleRampAttrNode::postConstructor()
{
MPlug curvePlug( thisMObject(), exampleRampAttrNode::input3 );
MStatus stat = curveAttr.setCurve(pos, val);
if(!stat)
{
cout << "ERROR setting curve points!\n";
}
}
MStatus exampleRampAttrNode::initialize()
{
MString curveAttrRamp(
"curveAttrRamp");
stat = addAttribute(input1);
if(!stat)
{
cout << "ERROR in adding curveRamp Attribute!\n";
}
stat = addAttribute(input2);
if(!stat)
{
cout << "ERROR in adding colorRamp Attribute!\n";
}
stat = addAttribute(input3);
if(!stat)
{
cout << "ERROR in adding curveAttrRamp Attribute!\n";
}
return stat;
}
{
}
MStatus exampleRampAttrNode::shouldSave(
const MPlug &plug,
bool &result)
{
if (plug == input3 || plug.
parent() == input3) {
result = true;
return MS::kSuccess;
}
}
{
MFnPlugin plugin(obj, PLUGIN_COMPANY,
"7.0",
"Any");
status = plugin.registerNode("exampleRampAttrNode", exampleRampAttrNode::id,
exampleRampAttrNode::creator, exampleRampAttrNode::initialize);
if (!status)
{
status.
perror(
"registerNode");
return status;
}
return status;
}
{
status = plugin.deregisterNode(exampleRampAttrNode::id);
if (!status)
{
status.
perror(
"deregisterNode");
return status;
}
return status;
}