PDA

View Full Version : input as output


enrigger
12-14-2007, 09:43 AM
I created a custom node with some inputs readable and writable, but sometimes(?) if I connect these inputs to others nodes (treating them as outputs) I catch a plug error, because in the compute function I made a check of the outputs


if(plug == someOutput)
else {
MGlobal::displayError ("plug error");
return MS::kUnknownParameter;
}


The fact is that the node works always, in some situation it gives me an error (but works anyway).
I corrected this including in the plug checking "someInput":


if(plug == someOutput||plug == someInput)
else {
MGlobal::displayError ("plug error");
return MS::kUnknownParameter;
}


But I saw in some devkit nodes that they didn't put this line:
MGlobal::displayError ("plug error");

What do you think it is the right way to approach this situation?
thankyou in advance

enrigger
12-16-2007, 06:53 PM
no ideas?
thanks anyway.

pgraham
12-18-2007, 08:59 PM
You should handle someInput separately, such as if(plug == someOutput){
// handle output
// if you want to use the value of someInput to affect someOutput
// you should add an attributeAffects(someInput, someOutput) in the initialize function
}
else if(plug == someInput){
// handle input...
// you should get input and output data handles for someInput (do not use someOutput)
// assign the output data handle to the value of the input
// then set the plug to be clean
}
else {
MGlobal::displayError ("plug error");
return MS::kUnknownParameter;
}

enrigger
12-19-2007, 07:25 AM
thank you very much, I'm gonna try this way.
cheers.

Robert Bateman
12-19-2007, 10:06 AM
Why are you computing an input when compute is asking for an output ???

You should handle someInput separately, such as
else if(plug == someInput){
// handle input...
// you should get input and output data handles for someInput (do not use someOutput)
// assign the output data handle to the value of the input
// then set the plug to be clean
}

Have i missed something here???

I would have suggested that :


if(plug == someOutput)
{
// calculate someOutput
}
else {
return MS::kUnknownParameter;
}
might be the solution? Don't print an error message within compute. compute may be called for attributes on base classes of your node, in which case it returns unknown param so that maya knows to find the base compute func that deals with it.

enrigger
12-19-2007, 02:10 PM
first of all, thankyou for the material on your web site, I found it very usefull.

thankyou for the suggestion too.

Anyway I need to get the value of the input because I organized my rig in this way using maya nodes (such as pointOnSurface), maya allowed me to do this, and I found it more readable for the rigger.
After I've done this I decided to substitute a lot of maya nodes with few custom nodes and I got this error message, I was just wondering how correct could work in this way.

Another reason is that connecting an input to others attribute I just need to update this input to change all the others.
cheers

pgraham
12-19-2007, 06:41 PM
Why are you computing an input when compute is asking for an output ???I'm doing it because I thought that's what the question was.

If the output attribute is supposed to be a different value from the input, you may want to reserve the option of using the input as a "pass through" to other nodes. Hopefully I'm doing that correctly? It's correct to set the output handle on someInput and set it clean, right? I mean, I've done that before and had no bad side effects.

CGTalk Moderation
12-19-2007, 06:41 PM
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.