Reputation: 185
I'm developing a C++ plugin and I would like to know a way to work with a non-Maya class objects through the scene. I mean, I want to have an instance of a class external to Maya API as attribute of the Node class. The class is quite complex and is composed by multiple classes.
What I've seen is that a Node can give me Structured Data Storage, but as far as I know it works only with Maya types which is not enough for my purposes.
Right now I'm using MPxCommand to execute the computation of that object, but once it has finished, it's destroyed. I want to keep it alive in the scene so I need to use Nodes somehow. At the moment it's not necessary storing the data.
So, do you know a way to do the equivalent in Maya of a typical OOP class? I've not found any example in the devkit or documentation.
class Foo : public MPxNode
{
public:
Foo () {};
virtual ~Foo () {};
virtual MStatus compute(const MPlug& plug, MDataBlock& data);
static void* creator();
static MStatus initialize();
static MObject inputMesh;
static MTypeId id;
// I want to keep it alive through the scene.
// static ClassBar myBarObject; // How can I do this??
// barFunction(...); // use ClassBar myBarObj
};
MObject Foo::inputMesh;
MTypeId Foo::id( 0x80000 );
//ClassBar Foo::myBarObj; // ????
Thank you very much
Upvotes: 0
Views: 645
Reputation: 2659
No, there is no way for you to create a Maya node from a pure OOP point of view and derive from what ever classes coming from our libraries. Maya MPxNode is a proxy class which encapsulate the Maya internal node logic. However, when you implement a custom node, you describe what the attributes should be, so Maya can work with your data and create connections in the DG. The way to set, and process the attribute is up to you. You would need to put your own logic in the computer() method when Maya request an attribute value to be re-computed.
For further details on custom nodes and libraries integration, see the articles posted there http://around-the-corner.typepad.com/
Upvotes: 0