SceneHooks and AM modes



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

    On 05/07/2010 at 19:58, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   11 
    Platform:      Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    Hey all,

    I'm building a combo plugin that includes an object, a tag, and a scenehook.  There are some global settings associated with the scenehook that I want to be available for the user to alter if necessary.

    So, I was wondering how I could get AM parameters for the hook, but it's not something that's "selectable" like an object or a tag so there's no way to display it in the AM.  Then there's a dialog, but I don't feel like going that route.  Then I remembered the new document mode in the AM in R11.5 and wondered if I could create my own mode and tie it to my hook.

    A quick look through the sdk, and I find lib_activeobjectmanager.  Woohoo, it looks like I can create my own AM mode, and it's available all the way back to R10, perfect:D  But it seems like it's a bit of a different beast than most of the other stuff I've seen in the SDK, so I thought I'd ask a couple of questions before diving in:)

    1.It looks like a class, but it's categorized as a "global", so is there any special way to deal with it? (ducks for cover in case that's a stupid noob question).

    2. It almost seems like it's designed for scenehooks... Like, it is the quintessential answer to my overall problem of adding parameters to a scenehook plugin.  Is that correct?  The function to register a new mode has a variable for a MESSAGEHOOK *hook, is that where I put my scenehook plugin to tie that mode to my scenehook?  And if so, how do I handle the description resource in this case?

    thanks!

    -kvb



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

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

    Since R11.5 you can set the PLUGINFLAG_SCENEHOOK_SUPPORT_DOCUMENT_DESCRIPTION flag when you register the scene hook. This will cause the scene hook to appear in the document settings, just like the MoDynamics global settings for instance.

    Here is a simple example:

      
    #include "c4d.h"  
    #include "c4d_symbols.h"  
    #include "smyscenehook.h"  
      
      
    class MySceneHook : public SceneHookData  
    {  
      public:  
          static NodeData *Alloc(void) { return gNew MySceneHook; }  
    };  
      
      
    // be sure to use a unique ID obtained from www.plugincafe.com  
    #define ID_MYSCENEHOOK 1025181  
      
    Bool RegisterMySceneHook(void)  
    {  
      return RegisterSceneHookPlugin(ID_MYSCENEHOOK,GeLoadString(IDS_MYSCENEHOOK),PLUGINFLAG_SCENEHOOK_SUPPORT_DOCUMENT_DESCRIPTION,MySceneHook::Alloc,EXECUTION_EXPRESSION,0,NULL);  
    }  
    

    You can use standard description resource files, just remember to register the scene hook's description files.

      
    Bool PluginMessage(LONG id, void *data)  
    {  
      ...  
        
      switch (id)  
      {  
          case C4DPL_INIT_SYS:  
              if (!resource.Init()) return FALSE; // don't start plugin without resource  
      
              if (!RegisterDescription(ID_MYSCENEHOOK, "Smyscenehook", NULL)) return FALSE;  
                
              return TRUE;  
                
      ...  
    }  
    

    cheers,
    Matthias



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

    On 07/07/2010 at 12:20, xxxxxxxx wrote:

    Thanks Matthias,

    But what about all the pre-R11.5 versions of my plugin?  I need a solution that will work for R10+.  Does that mean I can't create my own AM mode for use with my plugin in pre-11.5 versions of c4d?

    thanks,
    kvb



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

    On 08/07/2010 at 02:48, xxxxxxxx wrote:

    If you want to create a new AM mode you have to register it first. The best place to do this is probably C4DPL_STARTACTIVITY because all plugins have been already registered at this point. You have to pass a function pointer for a message hook to ActiveObjectManager_RegisterMode(). In this message hook you can pass the scene hook over to the AM.

    Here is some sample code for the AM mode registration, this goes into the main.cpp.

      
    #define ID_MYSCENEHOOK 1025181  
    #define ID_SCENEHOOKMODE 1025002  
      
    GeData SceneHookMessageHook(const BaseContainer &msg, void *data)  
    {  
      switch (msg.GetId())  
      {  
          case AOM_MSG_ISENABLED:  
          return TRUE;  
      
          case AOM_MSG_GETATOMLIST:  
          {  
              BaseDocument *doc = GetActiveDocument(); if (!doc) break;  
              PluginSceneHook *sh = doc->FindSceneHook(ID_MYSCENEHOOK); if (!sh) break;  
              ((AtomArray* )data)->Append(sh);  
              return TRUE;  
          }  
          break;  
      }  
      return FALSE;  
    }  
        
      
    Bool PluginMessage(LONG id, void *data)  
    {  
      switch (id)  
      {  
          ...  
            
          case C4DPL_STARTACTIVITY:  
              if (!ActiveObjectManager_RegisterMode((ACTIVEOBJECTMODE)ID_SCENEHOOKMODE, "Scene Hook", SceneHookMessageHook)) return FALSE;  
              return TRUE;  
                
          ...  
      }  
      
      return FALSE;  
    }  
    

    This should work from R10.x up to 11.5x.

    cheers,
    Matthias



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

    On 08/07/2010 at 19:45, xxxxxxxx wrote:

    thanks Matthias:D

    -kvb



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

    On 17/10/2010 at 20:39, xxxxxxxx wrote:

    If I may, I have a follow-up question regarding this:

    How do I then give this new AM mode an icon?

    thanks,
    kvb



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

    On 18/10/2010 at 02:55, xxxxxxxx wrote:

    You can change the icon by waiting for the MSG_GETCUSTOMICON message. Fill the passed GetCustomIconData structure with your own icon.

    cheers,
    Matthias



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

    On 18/10/2010 at 05:35, xxxxxxxx wrote:

    Thanks (yet again) Matthias:)  Working perfectly:)

    btw... you should have a donate button on your site... I just went to go click it if it existed... but it didn't:(

    -kvb


Log in to reply