Just a little question about MPxNode

Just a little question about MPxNode

Anonymous
Not applicable
279 Views
1 Reply
Message 1 of 2

Just a little question about MPxNode

Anonymous
Not applicable
Hi, all

Since i learn to wrire maya shading node I wonder why the "compute" function is not a static function ? I don't know why every created node with the same type have to own it's own compute function even each compute function do the same thing. Can anyone give me some suggestion about this issue? Thanks !!
0 Likes
280 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Hi HuSeila, 

 

in general nodes have the static part, like the static create and init functions you need to register a new node type. 

This static part describes the node type, but not the actual node object with its current attribute values. 

 

I even have these static methods do nothing else than call the same methods of a static member (NodeManager),

to get rid of the static context. 

In my NodeManager nothing is static then and I can use inheritance and reuse some code.

Less copy code. 😉

 

Compute works with the actual attribute values, so it makes sense, to have it not static,

else you would have to pass in the MObject of your node, to know which nodes attribute values you want to use. 

 

Its a pretty weird imitation of object orientation in general with the nodes. Maybe connected to the naming conventions for calls exposed in the .mll

They need to be static, cause object methods names follow a different naming scheme, afaik. 

 

For example when I delete my node in the node editor, the destructor of MPXNode is not called,

but I have to register a callback externally of my MPXNode class to know about the deletion of a node. 

This is so not OO and makes simple things in a proper OO based library really hard in Maya API. 

Even finding it,...found it on StackOverflow and not in the documentation. 😞

 

Found it here:

delete callback

 

Best, 

Kai

0 Likes