PDA

View Full Version : MDGModifier !


chuong
10-15-2005, 04:08 AM
When create a sphere in maya, looking in hypergraph, i see that there are two node with connection between them, one is nurbsSphere, and the other is makeNurbSphere. The ouputsurface attribute of makeNurbSphere is connected to the create Attr of nurbsSphere.
So, i tried to make the same thing with maya API.

When using MFnDependencyNode to create node, it work ok. But when i use MDGModifier, it doesn't work (the compilation is ok). Load my plugin in maya, execute the my command, and nothing happen, no node was created !

Here is my code.


#include<maya/MPXCommand.h>
#include<maya/MGlobal.h>
#include<maya/MFnPlugin.h>
#include<maya/MFnDependencyNode.h>
#include<maya/MDGModifier.h>

/////////////////////////////////////////////////////
class myCmd : public MPxCommand{
public:
virtual MStatus doIt(const MArgList&);
virtual MStatus undoIt();
virtual MStatus redoIt();
virtual bool isUndoable() const{return true;};
static void *creator(){return new myCmd;}
private:
MDGModifier mdg;
};
/////////////////////////////////////////////////////



MStatus initializePlugin(MObject obj){
MFnPlugin pluginFn(obj,"","1.0");
MStatus stat;
stat = pluginFn.registerCommand("myPlug",myCmd::creator);
if(!stat)
stat.perror("registerCommand failed");
return stat;
}

MStatus uninitializePlugin(MObject obj){
MFnPlugin pluginFn(obj);
MStatus stat;
stat = pluginFn.deregisterCommand("myPlug");
if(!stat)
stat.perror("deregisterCommand failed");
return stat;
}


//doIt function

MStatus myCmd::doIt(const MArgList&){

MObject sphere=mdg.createNode("nurbsSurface");
MObject makeSphere=mdg.createNode("makeNurbSphere");
MFnDependencyNode Fnsphere(sphere);
MFnDependencyNode FnmakeSphere(makeSphere);

mdg.connect(FnmakeSphere.findPlug("outputSurface"),Fnsphere.findPlug("create"));
return redoIt();
}

MStatus myCmd::redoIt(){
return mdg.doIt();
}

MStatus myCmd::undoIt(){
return mdg.undoIt();
}

The implementation like the one of David Gould (complete maya program).

Did i miss something ? :cry:

chuong
10-18-2005, 07:10 AM
hmm,
It take me a long time to test other nodes like blinn, lambert... and these nodes work ok, only nodes like nurbsSphere, circle .... doesn't.
I don't know why !!! :banghead:

CGTalk Moderation
10-18-2005, 07:10 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.