#include <string.h>
#include <maya/MIOStream.h>
#include <math.h>
#include <maya/MPxNode.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnTypedAttribute.h>
#include <maya/MFnPlugin.h>
#include <maya/MFnNurbsCurve.h>
#include <maya/MFnNurbsCurveData.h>
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MPointArray.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MArrayDataHandle.h>
#include <maya/MArrayDataBuilder.h>
{
public:
multiCurve() {};
~multiCurve() override;
static void* creator();
public:
};
#define PERRORfail(stat,msg) \
if (!(stat)) { \
stat.perror((msg)); \
return (stat); \
}
multiCurve::~multiCurve () {}
void* multiCurve::creator()
{
return new multiCurve();
}
{
numCurves = nAttr.
create (
"numCurves",
"nc",
PERRORfail(stat, "initialize create numCurves attribute");
stat = addAttribute( numCurves );
PERRORfail(stat, "addAttribute(numCurves)");
curveOffset = nAttr.
create (
"curveOffset",
"co",
PERRORfail(stat, "initialize create curveOffset attribute");
stat = addAttribute( curveOffset );
PERRORfail(stat, "addAttribute(curveOffset)");
inputCurve = typedAttr.
create(
"inputCurve",
"ic",
PERRORfail(stat, "initialize create inputCurve attribute");
stat = addAttribute( inputCurve );
PERRORfail(stat, "addAttribute(inputCurve)");
outputCurves = typedAttr.
create(
"outputCurves",
"oc",
PERRORfail(stat, "initialize create outputCurves attribute");
stat = addAttribute( outputCurves );
PERRORfail(stat, "addAttribute(outputCurves)");
stat = attributeAffects( numCurves, outputCurves );
PERRORfail(stat, "attributeAffects(inputCurve, outputCurves)");
stat = attributeAffects( curveOffset, outputCurves );
PERRORfail(stat, "attributeAffects(inputCurve, outputCurves)");
stat = attributeAffects( inputCurve, outputCurves );
PERRORfail(stat, "attributeAffects(inputCurve, outputCurves)");
return stat;
}
{
if ( plug == outputCurves )
{
PERRORfail(stat, "multiCurve::compute getting numCurves");
int num = numCurvesHandle.
asInt();
PERRORfail(stat, "multiCurve::compute getting curveOffset");
double baseOffset = curveOffsetHandle.
asDouble();
PERRORfail(stat, "multiCurve::compute getting inputCurve");
&stat);
PERRORfail(stat, "multiCurve::compute getting output data handle");
PERRORfail(stat, "multiCurve::compute creating builder");
for (int curveNum = 0; curveNum < num; curveNum++) {
MObject outputCurve = inCurveFS.copy(inputCurveObject,
outCurveData, &stat);
PERRORfail(stat, "multiCurve::compute copying curve");
double offset = baseOffset * (curveNum+1);
for (int i = 0; i < numCVs; i++) {
cvs[i].x += offset;
}
outCurveFS.setCVs ( cvs );
outHandle.
set(outCurveData);
}
stat = outputArray.
set(builder);
PERRORfail(stat, "multiCurve::compute setting the builder");
PERRORfail(stat, "multiCurve::compute cleaning outputCurves");
} else {
return MS::kUnknownParameter;
}
return stat;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
CHECK_MSTATUS (plugin.registerNode(
"multiCurve", multiCurve::id,
multiCurve::creator, multiCurve::initialize ) );
return MS::kSuccess;;
}
{
return MS::kSuccess;;
}