#include <string.h>
#include <maya/MIOStream.h>
#include <math.h>
#include <maya/MPxNode.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnCompoundAttribute.h>
#include <maya/MFnPlugin.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MArrayDataHandle.h>
#include <maya/MArrayDataBuilder.h>
#define McheckErr(stat,msg) \
if ( MS::kSuccess != stat ) { \
cerr << msg; \
return MS::kFailure; \
}
{
public:
weightList();
virtual ~weightList();
static void* creator();
public:
private:
};
weightList::weightList() {}
weightList::~weightList() {}
void* weightList::creator()
{
return new weightList();
}
{
addAttribute(aBias);
addAttribute(aWeights);
aWeightsList = cmpAttr.
create(
"weightsList",
"wl", &status);
addAttribute(aWeightsList);
attributeAffects(aBias, aWeightsList);
}
{
unsigned i, j;
MPlug wPlug(thisNode, aWeights);
for( i = 0; i < 3; i++) {
status = wPlug.selectAncestorLogicalIndex( i, aWeightsList );
McheckErr(status, "arrayHandle construction failed\n");
McheckErr(status, "arrayBuilder accessing/construction failed\n");
for( j = 0; j < i+2; j++) {
McheckErr(status, "addElement to arrayBuilder failed\n");
float val = (float)(1.0f*(i+j));
}
status = arrayHandle.
set(arrayBuilder);
McheckErr(status, "set arrayBuilder failed\n");
wPlug.setValue(wHandle);
wPlug.destructHandle(wHandle);
}
McheckErr(status, "arrayHandle construction for aWeightsList failed\n");
for( i = 0; i < count; i++) {
McheckErr(status, "handle evaluation failed\n");
McheckErr(status, "arrayHandle construction for aWeights failed\n");
unsigned eCount = eArrayHandle.elementCount();
for( j = 0; j < eCount; j++) {
eArrayHandle.jumpToElement(j);
float weight = eArrayHandle.outputValue(&status).asFloat();
McheckErr(status, "weight evaluation error\n");
fprintf(stderr, "weightList[%u][%u] = %g\n",i,j,weight);
}
}
McheckErr(status, "arrayHandle construction for aWeightsList failed\n");
for( i = 0; i < count; i++) {
McheckErr(status, "handle evaluation failed\n");
McheckErr(status, "arrayHandle construction for aWeights failed\n");
unsigned eCount = eArrayHandle.elementCount();
for( j = 0; j < eCount; j++) {
eArrayHandle.jumpToArrayElement(j);
float weight = eArrayHandle.outputValue(&status).asFloat();
McheckErr(status, "weight evaluation error\n");
fprintf(stderr, "weightList[%d][%d] = %g\n",i,j,weight);
}
}
return status;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
result = plugin.registerNode( "weightList",
weightList::id,
weightList::creator,
weightList::initialize);
return result;
}
{
result = plugin.deregisterNode( weightList::id );
return result;
}