In my node plugin, I would like to grab the start and end joints of a joint chain in order to find the offset matrices between each joint. To do that, I am trying to create message attributes for connecting the joints and figure out the dag path between the two. But I can’t seem to find a way to extract the dag path information from it.
Any ideas on how that can be done? Or should I use something else than MFnMessageAttribute?
Thanks!
The connections in the API are done through the MPlug class. MPlug class has a method called MPlug::node() returns the node it belongs to. If you want to find the other end of the connection just do MPlug::connectionByPhysicalIndex(0) which returns the target MPlug, then call MPlug::node() on that.
Once you have the MObject returned by MPlug::node() just call the static method of MDagPath::getAPathTo( MObject &) and it returns a MDagPath for you
This was all written by checking the C++ API, I’ve used these before but that was probably 3-4 month ago, so just try it out, should work!
Oh I see, that really helps, thank you very much! :p:
Ah don’t mention it
Incase someone else wonders the MPlug is received through the function set class MFnDependencyNode, also inherited by MFnDagNode, MFnMesh etc etc.
Every DAG node is a Dependency node
Hello ,
nothing original here , just a snippet inspired by the MPxDeformer documentation
MObject thisNode = thisMObject();
//let say that we have on your node an inputColor attribute
// inputColor here is an MObject that reference it
MPlug imagePlug (thisNode,inputColor);
if ( imagePlug.isConnected() == true ) // is there something feeding this input attribute ?
{
MPlugArray connectedPlugs;
connectedPlugs.clear();
imagePlug.connectedTo(connectedPlugs, true, false);
if ( connectedPlugs.length() > 0 )
{
MObject textureNode = connectedPlugs[0].node(); // <-- you cant have in maya multiple attributes connected to the same destination attribute
}
}
Just curious ,
you want to step outside your node to retrieve a dagPath in order to extract matrix informations?
Have you though of creating an input matrix attribute and connect your transform/joint matrix into it?
[QUOTE=cedricB;14784]Just curious ,
you want to step outside your node to retrieve a dagPath in order to extract matrix informations?
Have you though of creating an input matrix attribute and connect your transform/joint matrix into it?[/QUOTE]
Actually when I posted I was going in the wrong direction – I wanted to create a dependency node that takes in the first and last joints of a hierarchy (via message attributes) and modify their transformations (seems to be a really bad idea). I am now going to do that through a constraint instead so I am not using message attributes anymore.
It is still good to know how to find out the dagPath from a message nonetheless, so thanks!