Problem with Effector plugin overloading Message()
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/01/2012 at 06:51, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R12
Platform: Windows ;
Language(s) : C++ ;---------
Hi,
I'm currently trying to write an effector plugin and started with the dropeffector example. Now, I have problem with adding a button to the effector's description.
The button is declared in the resource files and appears correctly within the GUI. But as soon as I overload Message(), the plugin stops working. It still registers successfully, but InitPoint() and ModifyPoints() aren't called anymore. Also the effector isn't automatically added to a selected MoGraph object on creation anymore (but it's still possible to add it manually, but still InitPoints() and ModifyPoints() aren't called anymore ). ModifyDDescription() keeps working though. Quite obviously, I'm doing something wrong, but I don't find the point...
As soon as I add this Message() function to my plugin, it stops working:Bool MyTestPlugin::Message(GeListNode *node, LONG type, void *t_data) { BaseObject * const obj = static_cast<BaseObject*>(node); BaseContainer * const bcData = obj->GetDataInstance(); // Button commands if (type == MSG_DESCRIPTION_COMMAND) { DescriptionCommand *dc = (DescriptionCommand* )t_data; if (dc->id == MYTESTPLUGIN_BUTTON_RESET) { // do something } } return TRUE; }
Even a completely empty Message() function has the same effect.
Bool MyTestPlugin::Message(GeListNode *node, LONG type, void *t_data) { return TRUE; }
Anybody an idea?
Thanks for your help in advance,
Andreas -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/01/2012 at 10:17, xxxxxxxx wrote:
Hi,
You need to call parent's class Message() implementation as your last return, like this:
Bool DropEffector::Message(GeListNode* node, LONG type, void* t_data) { return EffectorData::Message(node, type, t_data); }
If you just return TRUE, InitPoints() and ModifyPoints() aren't called.
Regards,
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/01/2012 at 10:29, xxxxxxxx wrote:
Hello,
thanks for the quick response.
It works as expected, thanks. I was already looking in this direction but messed it up by calling ObjectData::Message()...
Best regards,
Andreas -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/01/2012 at 11:26, xxxxxxxx wrote:
Originally posted by xxxxxxxx
It works as expected, thanks. I was already looking in this direction but messed it up by calling ObjectData::Message()...
In fact when we subclass a C4D class, we should always declare the class with the macro INSTANCEOF:
class DropEffector : public EffectorData { INSTANCEOF(DropEffector, EffectorData) public: DropEffectorData ed; etc.. };
INSTANCEOF() declares SUPER as the parent's class to make it easier to call parent's class methods:
Bool DropEffector::Message(GeListNode* node, LONG type, void* t_data) { return SUPER::Message(node, type, t_data); }