How to place own materials into the root menu?
-
On 27/02/2016 at 07:54, xxxxxxxx wrote:
Well, the question was how to move menu items
from default "Root -> Shaders -> Your Plugin Folder -> Material ... "
to "Root -> Your Plugin Folder -> Material ... "
i.e. one level up -
On 27/02/2016 at 09:04, xxxxxxxx wrote:
I don't know how they do it, but Thea Renderer puts its material menu in with the root menus of the Material Manager and Arnold Renderer (C4DToA) puts it in the Create menu outside of the Shaders submenu in the Material Manager. Maybe you can email the creators of these plugins to get some insights.
ETA: You can find the resource used to describe the Material Manager menus in:
resource/modules/c4dplugin/menus/c4d_m_material_manager.res
After that, you just need to figure out how to get at the material manager resource to insert menus.
-
On 27/02/2016 at 10:01, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Well, the question was how to move menu items
from default "Root -> Shaders -> Your Plugin Folder -> Material ... "
to "Root -> Your Plugin Folder -> Material ... "
i.e. one level upWell, then still using the menu functions is probably what you need. Have you looked at GetMenuResource() etc.?
-
On 27/02/2016 at 10:10, xxxxxxxx wrote:
GetMenuResource() does look like the best approach. And you can do this in main.cpp using C4DPL_BUILDMENU (in PluginMessage() as shown in the sdk example code).
-
On 27/02/2016 at 10:31, xxxxxxxx wrote:
...and there are also other functions like SearchMenuResource etc. which might help as well.
-
On 27/02/2016 at 14:31, xxxxxxxx wrote:
Ok, this code inserts my custom category in the root menu of material creation:
void MySearchMenuResource(BaseContainer* bc) { if (!bc) return; BrowseContainer browse(bc); Int32 id = 0; GeData * dat = nullptr; while (browse.GetNext(&id, &dat)) { if (id == MENURESOURCE_SUBMENU || id == MENURESOURCE_STRING) { MySearchMenuResource(dat->GetContainer()); } else if (id == MENURESOURCE_COMMAND) { if (dat->GetString() == String("IDM_MNEU")) { BaseContainer sc; sc.InsData(MENURESOURCE_SUBTITLE, String("Category In Root")); sc.InsData(MENURESOURCE_COMMAND, String("PLUGIN_CMD_XXXXXX")); bc->InsDataAfter(MENURESOURCE_STRING, sc, dat); } } } } void EnhanceMaterialMainMenu(void) { BaseContainer *bc = GetMenuResource(String("M_MATERIAL_MANAGER")); if (!bc) return; MySearchMenuResource(bc); }
But the command PLUGIN_CMD_123456 doesn't create any material (we asume that 123456 is material plugin ID). How to fix that?
-
On 27/02/2016 at 16:20, xxxxxxxx wrote:
Check out this post:
Plus, yes, the plugin ID must be a real ID associated with a material/shader plugin.
-
On 28/02/2016 at 01:19, xxxxxxxx wrote:
Sure, instead of the digits in the string PLUGIN_CMD_123456 I write a real plugin id of material (derived from MaterialData) but it doesn't work. If I write instead of these digits the plugin id of some command plugin it then works.
-
On 28/02/2016 at 02:55, xxxxxxxx wrote:
If you cannot add materials that way you can always hide the original material entry (pass ~PLUGINFLAG_HIDE in RegisterMaterialData()) and create a commanddata plugin which creates the material (and then you can place the command in that menu instead)
-
On 28/02/2016 at 14:31, xxxxxxxx wrote:
Thanks Katachi, I have been also thinking about this not so elegant workaround.
Maybe I will do it or will wait for what secret trick Sebastian can advice after the weekend -
On 29/02/2016 at 02:33, xxxxxxxx wrote:
Hello,
I don't know any secret trick and I don't know what exactly Solid Angle did. But looking at the plugin it seems they created custom commands.
When Cinema registers a ObjectData plugin with RegisterObjectPlugin() internally also a command with the same ID is created. Because of this one can add such a command to a menu and one can use CallCommand() to create an object. When a material is registered no such internal command is created.
Best wishes,
Sebastian -
On 01/03/2016 at 05:46, xxxxxxxx wrote:
Ok, thanks Sebastian for explanation! It seems that for this task we only can create many corresponding command plugins with doc->InsertMaterial() inside.