Registering SceneHookData



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/07/2010 at 02:50, xxxxxxxx wrote:

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

    ---------
    Hi all!

    I'm a beginner in writing C++ plugins for C4D. I would like to control the rotations of the camera in the active viewport. I've read the basics about writing plugins in C++ and I think my plugin class should derive from SceneHookData.

    The problem seems to be the registration of my plugin. Here is my code :

    Main.cpp

    #include "c4d.h"
      
    Bool RegisterMyPlugin();
      
    Bool PluginStart(void)
    {
        if(!RegisterMyPlugin()) return FALSE;
        return TRUE;
    }
      
    void PluginEnd(void)
    {
    }
    Bool PluginMessage(LONG id, void *data)
    {
        switch (id)
        {
            case C4DPL_INIT_SYS:
                if (!resource.Init()) return FALSE; // don't start plugin without resource
                return TRUE;
            case C4DMSG_PRIORITY: 
                return TRUE;
        }
        return FALSE;
    }
    

    MyPlugin.cpp

    #include "c4d.h"
      
    #define ID_MYPLUGIN 123456789
      
    class MyPlugin : public SceneHookData
    {
        public:
            static NodeData *Alloc(void) { return gNew MyPlugin; }
    };
      
    Bool RegisterMySceneHook(void)
    {
        return RegisterSceneHookPlugin(ID_MYPLUGIN,"My Plugin",PLUGINFLAG_SCENEHOOK_SUPPORT_DOCUMENT_DESCRIPTION,MyPlugin::Alloc,EXECUTION_EXPRESSION,0,NULL);
    }
    

    And my Errors (I use Visual Studio) :

    Error	1	error LNK2019: unresolved external symbol "int __cdecl RegisterMyPlugin(void)" (?RegisterMyPlugin@@YAHXZ) referenced in function "int __cdecl PluginStart(void)" (?PluginStart@@YAHXZ)	Main.obj	plugintemplate
      
    Error	2	fatal error LNK1120: 1 unresolved externals	plugintemplate.cdl	plugintemplate
    

    Thank you for your help !



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/07/2010 at 03:51, xxxxxxxx wrote:

    try addin "void" in the brackets

    Bool RegisterMyPlugin();
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/07/2010 at 05:38, xxxxxxxx wrote:

    Thank you sandidolsak but I finally rearranged the project and it works!


Log in to reply