I'm coding in Maya API (C++) these days, first thing that I was a little bit confused is that when you define a class in your header file, apparently you only have to make static member variable (attributes), so all the instances share common data. At the same time in Maya for example when I create a instance of a plugin name "Sphere", it creates it and I can change the attributes and everything works fine. But when I create another Sphere object in Maya scene the static attributes have their local values too. Like if I change "Sphere2.radius", it wouldn't update the first instance "Sphere1.radius" at all.
Here is a code that does the same behavior:
class Morpher : public MPxDeformerNode
{
public:
Morpher();
virtual ~Morpher();
static void* creator();
static MStatus initialize();
virtual MStatus deform(
MDataBlock& data,
MItGeometry& itGeo,
const MMatrix& localToWorldMatrix,
unsigned int geomIndex);
static MTypeId id;
static MObject aBlendMesh;
static MObject aRadius;
};
And the initialize function:
MStatus Morpher::initialize(){
MStatus status;
MFnNumericAttribute nAttr;
MFnTypedAttribute tAttr;
aBlendMesh = tAttr.create("blendMesh", "blendMesh", MFnData::kMesh);
addAttribute(aBlendMesh);
attributeAffects(aBlendMesh, outputGeom);
aRadius = nAttr.create("radius", "radius", MFnNumericData::kFloat);
nAttr.setKeyable(true);
nAttr.setMin(0);
nAttr.setMax(1);
addAttribute(aRadius);
attributeAffects(aRadius, outputGeom);
MGlobal::executeCommand(
"makePaintable -attrType multiFloat -sm deformer blendMesh weights;");
return MS::kSuccess;
}
So I wanted to know if you guys have any experience with this API, or am I not understanding the static concept correctly or Maya is handling that part in its own way?
Thanks,