Libraries



  • On 12/10/2014 at 03:50, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R14 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi folks,
     
    I'm wanting to add an object plugin to another dialog plugin, so that the dialog plugin can read my object plugin. But I'm a little lost as to how I'm suppose to implement this. I've tried adding the main class header file for the object plugin into the dialog project, and while it compiles, trying to get anything out of it doesn't work - e.g. things like trying to return a long value from one of the object plugin's functions always returns 1 regardless.
     
    I've also played around with the virtual syntax on the object plugin's functions, but I'm getting mixed messages on what the virtual syntax is for, and when to use it.
     
    Do I have to build a library for the object plugin for this to work? Or can I use the source files I already have for the object plugin inside of the dialog plugin build?
     
    WP.
     
    EDIT: I might just mention as well, that I'm reading the scene file in the dialog via LoadDocument() - so reading in memory, not in the active viewport document.



  • On 12/10/2014 at 06:29, xxxxxxxx wrote:

    You can combine as many 'plugins' together in a single build as you want.  My InterPoser Pro plugin consists of commands w/dialogs, scenehooks, objects, tags, tools, and so on.  You just register each one in PluginStart() (just like they do in the c4dsdkexample).

    To talk to each other, you should create Get/Set methods and keep a pointer to the your plugin instance itself.  You can get that information from BaseObject using GetNodeData(), casting to your plugin data type (MyObjectData* e.g.).  The methods need to be public.



  • On 12/10/2014 at 08:20, xxxxxxxx wrote:

    WickedP, depending on the combination of plugins and given usecase, you might also use messages to interact with eachother.
    Oh, and don't forget, that you still need unique IDs for all included plugins.



  • On 14/10/2014 at 01:17, xxxxxxxx wrote:

    Thanks Robert/Andreas,
     
    I've got multiple plugins in some of the projects, but as far as I can see, the project itself will only build to the one cdl file. I'm after two separate plugin files, as one of them will be given out free, while the other one will be a fee-for (that's the idea anyway). There's a dialog plugin and an object plugin. Both have unique IDs themselves, both projects include a few plugins too (e.g. the object plugin also has some custom gui plugins with unique IDs).
     
    I had been trying to get my object by casting from a BaseObject that matches the plugin id, a bit like the following:

    BaseObject *obj = NULL;
    // while loop to find the matching object plugin in a scene
    // file here, the scene file is opened via LoadDocument()
    MyObjectPlugin *MyPlug = (MyObjectPlugin* )obj;
    // run functions etc from MyPlug here..
    

    That side of it works. The issue I'm having is that if I include the object plugin class header file into the dialog project, and then use the above code to operate on the object plugin, I get a list of "C2027  use of undefined type" errors. So, I tried making a dummy header with empty functions, which looks a little like this

    // standard BaseObject overrides  
    Bool DIRECTOROBJECT::Init(GeListNode *node){return SUPER::Init(node);}  
    BaseObject* DIRECTOROBJECT::GetVirtualObjects(BaseObject* op,HierarchyHelp* hh){return SUPER::GetVirtualObjects(op,hh);}
    // custom function overrides  
    int DIRECTOROBJECT::GetCurrentFrame(void){return SUPER::GetCurrentFrame();}  
    int DIRECTOROBJECT::GetLastFrame(void){return SUPER::GetLastFrame();}
    

    But the build fails because the custom ones aren't apart of the BaseObject class. I'm confused as to how I bring in the object class plugin that includes the custom functions into the dialog project. My lack of the c++ lingo talk probably doesn't help here, but I hope the above explains it a little better.
     
    Cheers,
     
    WP.



  • On 14/10/2014 at 02:52, xxxxxxxx wrote:

    WickedP,
    I'm afraid you have two distinct problems.

    The first will be to set up your project structure, to get the distinct parts compile without the need for the other (of course you may share defines, etc.). I'm not sure, how to help on this, my insight into your project structure is superficial only.

    Second you will indeed need to make use of a library. Again I'm missing details (or didn't understand correctly). I don't even understand, which part you think should be based on which.

    But there's a nice example in ScottA's example library: The slider customgui. It makes use of a library and might give you an idea, where and how to separate your project.

    The basic idea here is:
    The custom gui (parent class CustomGuiData) gets registered as a library (the actual library implementation is abstracted here by the CustomGuiData, so one does not need to bother). Afterwards other plugins can find the new customgui and make use of it.

    I'd recommend the SDK docs on "Creating Libraries" and "c4d_library.h" as a starter. I'm not sure the later already went into R16 online docs, that's why I don't provide links here. Be warned, this topic is no no-brainer.


Log in to reply