Custom register plugin
-
Hi folks,
just doing some brainstorming and hoping someone may be able to suggest/contribute some ideas.
I have a dialog plugin with a graphical interface. I'd like to be able to register plugins for my plugin, so that I can build them separately if needed, or perhaps so others in the future may be able to.
Is it possible to register a custom plugin type? Or, could I piggyback off one of the Register*() functions and grab the registration in my plugin somewhere?
WP.
-
@WickedP
Not sure what you're after but you can always use aSpecialEventAdd
in your "separate" plugin to communicate with your dialog plugin.
Say, for instance, you can register a unique pluginID to use for a handshake message, so your separate plugin can pass its pluginID to the dialog plugin, which would listen to that specific pluginID.Other solution would be to make use of a "library plugin", providing some sort of API for the separate plugin to communicate with. Or even creating the separate plugin as such library plugin, which your dialog plugin would be calling for specific functionality.
I seem to remember having tried some "library plugin" once in the past ... can't really remember much details, though.
-
You can create arbitrary plugin hooks using the MAXON API's interface system:
https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_interfaces.html
Especially look at registries:
https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_registry_overview.html
or published objects:
https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_publishedobjects.html
See these examples in maxonsdk.module:
Alternatively, you can register arbitrary node plugins with RegisterNodePlugin().
You could implement your functionality e.g. in the Message() method.
https://developers.maxon.net/docs/cpp/2023_2/class_node_data.html
-
Thanks both of you. I'm still thinking this one through.
@C4DS I hadn't thought of SpecialEventAdd, thanks for the suggestion. This had me looking into, and finding, GePluginMessage(). I'm wondering if I could call this in PluginStart(). This does seem to work. I could maybe avoid Cinema's Register system with this.
@PluginStudent can I register a custom type using GeRegistryAdd()? Or does it have to be one of the listed types? E.g. can I register a type under my main plugin id?
WP.
-
@WickedP said in Custom register plugin:
I have a dialog plugin with a graphical interface. I'd like to be able to register plugins for my plugin, so that I can build them separately if needed, or perhaps so others in the future may be able to.
Hi WickedP!
We are doing something similar in the 3delightForCinema4D renderer plugin. (source available here: https://gitlab.com/3Delight/3delight-for-cinema-4d/. We have a custom plugin system, separate from the normal c4d one, that allows 3rd party modules to add functionality to our plugin.This is handled via the "PluginMessage" function. When c4d has loaded, our plugin sends a special message to all other plugins, and passes along a pointer to a "pluginmanager" structure. Other plugins can then respond to this message, and register their plugins via the pluginmanager. You can see how this works in our source code. Some hints on where to look:
The "API" for our plugin system consists of a few header files, describing the supported plugin types (called "hooks" and "translators"):
https://gitlab.com/3Delight/3delight-for-cinema-4d/-/tree/master/3Delight/API/include
Here is the main file of the module that manages plugin loading: https://gitlab.com/3Delight/3delight-for-cinema-4d/-/blob/master/3Delight/source/main.cpp
The "PluginMessage" function in this file is where the message to load custom plugins is sent (in response to "C4DPL_STARTACTIVITY".
Here is the main file of an example separate module that registers a number of plugins:
https://gitlab.com/3Delight/3delight-for-cinema-4d/-/blob/master/3Delight Geometry/source/main.cppI hope this description is somewhat clear. We have found it to be a really straightforward but powerful way of designing a custom plugin system for c4d! Let me know if you have any questions.
Best regards
/Filip -
You could also create a plugin that registered a C4DLibrary. Then your other plugins would make sure they are initialized after your plugin is by using the plugin startup priorities. Then those other plugins can safely call the library and register themselves with your main plugin via the library. Unfortunately I don't think there is much documentation on this though. This is how I handle my plugin manager, all of my other plugins register themselves with my plugin so that it can deal with licensing etc.. and only allow certain plugins to actually load at startup.
-
Thanks @Filip and @kbar, I've setup a simple message system that I'm experimenting with.
Just a question (for anyone) regarding the start up procedures for Cinema, will my plugin receive PluginMessage() messages if my main plugin is not registered yet? Asking to make sure I can receive a message from another plugin that Cinema might try to register before mine.
WP.
-
@WickedP yes you can assume it.
Cinema 4D first loads all dlls, then PluginMessage is forwarded to each dlls.