#include <string.h>
#include <maya/MIOStream.h>
#include <math.h>
#include <maya/MPxNode.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnGenericAttribute.h>
#include <maya/MFnPlugin.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MGlobal.h>
class genericAttributeNode :
public MPxNode
{
public:
genericAttributeNode();
~genericAttributeNode() override;
static void* creator();
static MStatus addComplexFloatGenericAttribute(
MObject& attrObject,
const char *longName,
const char *shortName );
public:
static MObject gOutputFloat_2Float_3Float;
};
MTypeId genericAttributeNode::id( 0x81031 );
MObject genericAttributeNode::gInputInt;
MObject genericAttributeNode::gOutputFloat_2Float_3Float;
genericAttributeNode::genericAttributeNode() {}
genericAttributeNode::~genericAttributeNode() {}
{
if ( plug == gOutputFloat_2Float_3Float )
{
int inputInt = inputDataInt.
asInt();
bool isGenericNumeric = false;
bool isGenericNull = false;
if ( outputData.
isGeneric( isGenericNumeric, isGenericNull ) )
{
if ( inputInt == 1 )
else if ( inputInt == 2 )
else if ( inputInt == 3 )
else if ( inputInt == 4 )
else if ( inputInt == 5 )
else if ( inputInt == 6 )
else if ( inputInt == 7 )
else if ( inputInt == 8 )
{
returnStatus = numericData.
setData( (
float)1.5, (
float)6.7 );
}
else if ( inputInt == 9 )
{
returnStatus = numericData.
setData( (
float)2.5, (
float)8.7, (
float)2.3345 );
}
else if ( inputInt == 10 )
{
}
data.
setClean( gOutputFloat_2Float_3Float );
}
}
else
{
return MS::kUnknownParameter;
}
return MS::kSuccess;
}
void* genericAttributeNode::creator()
{
return new genericAttributeNode();
}
MStatus genericAttributeNode::addComplexFloatGenericAttribute(
const char *longName, const char *shortName )
{
attrObject = gAttr.
create( longName, shortName );
status = addAttribute( attrObject );
return MS::kSuccess;
}
MStatus genericAttributeNode::initialize()
{
gInputInt = nAttr.
create(
"gInputInt",
"gii",
status = addAttribute( gInputInt );
if ( !addComplexFloatGenericAttribute( gOutputFloat_2Float_3Float,
"gOutputFloat_2Float_3Float", "gof2f3f" ) )
return MS::kFailure;
status = attributeAffects( gInputInt, gOutputFloat_2Float_3Float );
return MS::kSuccess;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"7.0",
"Any");
status = plugin.registerNode( "genericAttributeNode",
genericAttributeNode::id, genericAttributeNode::creator,
genericAttributeNode::initialize );
if (!status) {
status.
perror(
"registerNode");
return status;
}
return status;
}
{
status = plugin.deregisterNode( genericAttributeNode::id );
if (!status) {
status.
perror(
"deregisterNode");
return status;
}
return status;
}