QUOTE(Joojaa @ 04/23/07, 05:13 PM) [snapback]264680[/snapback]
just a question why why would you bother with all this if your own external implementation intend to use arrays? whats wrong with one of the following?
MColorArray
Because I am unware of the existence of these and don't see why I would need to use them anyway. Surely Maya can cope with a declaration like float arr[10]? Do I really need to use MFloatArray arr[10] instead in my C++ code? Wouldn't this just be a wrapper around a float array in any case?
QUOTE(Joojaa @ 04/23/07, 05:13 PM) [snapback]264680[/snapback]
So why would you try to implement something way beyond your skill set in first place? especially when theres a much more natural way. Anyway if you cant bother to read the api manuals yourself the entire point is moot. Because no one can help a person who's not willing to help himself? So either post your source, because your not demonstrating any progress here, and its jus ta matter of time till i label you as a lost cause.
I value your help but don't appreciate having assumptions made about me, thank you.
To answer your questions:
- Q: Why implement this? A: Because my employer asked me to. If there is a more natural way, then please let me know what it is.
- Q: Why aren't I reading the manuals? A: I am reading the manuals, but I haven't found the answer I require there; hence I'm posting a question here in the hope that I'll get the answer more quickly this way. So I hope you'll see that I am willing to help myself.
I can't post the source as it is company confidential. That is why I have only posted disguised snippets or descriptions of what I am doing. Here's an outline of my source that might be helpful. This is meant for illustration only and is not intended to be compilable.
CODE
enum { NUMRESULTS = 10; }
class MyClass
{
public: //members are public so that I need not provide access functions in this illustrative example
int value;
std::string str;
};
class MyNode
{
private:
MObject maya_value;
MObject maya_str;
MyClass obj1;
};
MStatus MyNode::readData(MDataBlock& data)
{
MStatus stat = MS::kSuccess;
MDataHandle handle;
handle = data.inputValue(maya_value, &stat);
value = handle.asInt();
handle = data.inputValue(maya_str, &stat);
str = maya_str.asString();
}
MStatus MyNode::compute(const MPlug& plug, MDataBlock& data)
{
MStatus stat = MS::kSuccess;
if ((plug == output1) || (plug == output2))
{
if (readData(data) != MS::kSuccess)
return MS::kFailure;
double result[NUMRESULTS];
bool success = my_stand_alone_function(obj1, result);
if (success)
{
for (unsigned int i = 0; i != NUMRESULTS; ++i)
{
std::cerr << "Result " << i << " = " << result[i] << std::endl;
}
}
}
else
{
return MS::kUnknownParameter;
}
data.setClean(plug);
return stat;
}
class MyModel
{
//various simple types here, and also a variable of type std::pair<double, std::valarray >
};
bool my_stand_alone_function(const MyClass& obj, double* const arr)
{
MyModel model;
simplex simplex_method(&model);
//compute stuff here
//set elements of arr here
}
simplex makes copies of MyModel objects, so I MyModel has operator= defined that makes a deep copy.
QUOTE(Joojaa @ 04/23/07, 05:13 PM) [snapback]264680[/snapback]
Anyway i don't think your problem has to do anything with the smart pointers. Just something really fundamental
Right, that's exactly what I am thinking now, because I've got rid of the smart pointers.
Note that all my arrays are now fixed-sized arrays declared in header files. All instances of std::cout have been replaced with std::cerr, and all instances of printf have been removed (as the stack trace looks like it might have something to do with strings).
QUOTE(Joojaa @ 04/23/07, 05:13 PM) [snapback]264680[/snapback]
PS. Amway im beginning to see why the computer engineering majors were first introduced to scheme as a language to learn the vocabulary of programming to reset all the previous bad habits ![]()
Please don't post smart-alecky comments like these. They don't help. Be assured that my computing qualifications, experience and skills are well above average. It's just I have a lot of gaps in my knowledge of Maya, which is still fairly new to me.
QUOTE(Joojaa @ 04/23/07, 05:13 PM) [snapback]264680[/snapback]
Anyway im looking into your stack trace.
Thank you for your help. By the way, this posting was much more readable - thanks.