PDA

View Full Version : Overload Maya API operators


westiemad
05-12-2005, 05:45 PM
Hi,
I want to write a modulus node, now that i have a taste for the API. In a simple test program (console application) I can modulus to work no probs as its just a %, but when I do it inside a node it comes up, "illegal left operand has type double", do I have to overload the operator, and although I understand the process outside the API, how would I do it inside the API.

Is thats not a stupid question.

AnDy

playmesumch00ns
05-12-2005, 07:52 PM
Can you post the code? It's kinda difficult to tell otherwise

westiemad
05-12-2005, 08:03 PM
something along these lines

MStatus mod::compute(const MPlug &plug, MDataBlock &data)
{
MStatus status;
if(plug == output)
{
MDataHandle inputData1 = data.inputValue( inputA );
MDataHandle inputData2= data.inputValue( inputB );
double inp1 = inputData1.asDouble();
double inp2= inputData2.asDouble();

MDataHandle outputData = data.outputValue( output );
outputData.set(inp1 % inp2);

data.setClean(plug);

}
else
status = MS::kUnknownParameter;

return status;

}

playmesumch00ns
05-13-2005, 08:33 AM
The % operator is only defined for integers. That's what your compiler is trying to tell you in a rather opaque way.

For doubles use fmod() from math.h or cmath

westiemad
05-13-2005, 09:34 AM
thanks m8, I can never use the help file in this visual.net thing.


AnDy (jogging the learning curve)

Moonblood
05-13-2005, 09:36 AM
i think its not possible

CGTalk Moderation
05-13-2005, 09:36 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.