SceneHook Plugin Problem



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

    On 15/10/2011 at 10:16, xxxxxxxx wrote:

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

    ---------
    I'm trying to learn more about SceneHooks. And I found an old plugin that Matthias posted.
    But it appears that Maxon has commented out the old "virtual LONG GetBranchInfo" code and no longer wants us to override it anymore.
    So I need to know how, and where, I should put the  LONG MySceneHook::GetBranchInfo code to make this plugin work in R12?

    The code:

    //just a extremly simple Nodedata plugin  
      
    #include "c4d.h"  
    #include "c4d_symbols.h"  
    class MyNode : public NodeData  
    {  
      public:  
          static NodeData *Alloc(void) { return gNew MyNode; }  
    };  
      
    #define ID_MYNODE 1024726  
      
    Bool RegisterMyNode(void)  
    {  
      return RegisterNodePlugin(ID_MYNODE, "My Node", 0, MyNode::Alloc, NULL, 0, NULL);  
    }  
      
      
      
    //the SceneHookData plugin to store the NodeData plugin:  
      
    #include "c4d.h"  
    #include "c4d_symbols.h"  
      
      
    class MyNode;  
      
    #define ID_MYSCENEHOOK 1025181  
      
      
    class MySceneHook : public SceneHookData  
    {  
      public:  
          //constructor; initialization and plugin node allocation  
          MySceneHook()  
          {  
              hookname = String("My SceneHook Name");  
              mynode = (BaseList2D* )AllocListNode(1024726);  
          }  
      
          virtual Bool Init(GeListNode *node);  
          virtual Bool Read(GeListNode *node, HyperFile *hf, LONG level);  
          virtual Bool Write(GeListNode *node, HyperFile *hf);  
          //virtual LONG GetBranchInfo(GeListNode* node, BranchInfo* info, LONG max, ULONG flags); //<--No longer supported?  
      
          static NodeData *Alloc(void) { return gNew MySceneHook; }  
      
      private:  
          AutoAlloc<GeListHead> head;   //This is the list head were the plugin node will be inserted to  
          String hookname;  
          BaseList2D *mynode;           //Pointer to an instance of the plugin node  
    };  
      
    Bool MySceneHook::Init(GeListNode *node)  
    {  
      if (!head || !mynode) return FALSE;  
      
      head->SetParent(node);              //Needed to save the node list  
      
      head->Insert(mynode, NULL, NULL);   //Insert the plugin node into the list  
      
      return TRUE;  
    }  
      
    Bool MySceneHook::Read(GeListNode *node, HyperFile *hf, LONG level)  
    {  
      return head->ReadObject(hf, TRUE);    //Read files  
    }  
      
    Bool MySceneHook::Write(GeListNode *node, HyperFile *hf)  
    {  
      return head->WriteObject(hf);    //Save files  
    }  
      
    LONG MySceneHook::GetBranchInfo(GeListNode *node, BranchInfo *info, LONG max, ULONG flags) //<----How do I re-write this part, without overriding it, for R12?  
    {  
      //Specify if your node acts as a container of other nodes  
      //fill the info structure array; only one element is saved in this example  
      
      info[0].head = head;           //An array of elements  
      //info[1].head = myotherhead;  //Another array of list elements..Not used here  
      info[0].name = &hookname;  
      info[0].id = ID_MYSCENEHOOK;  
      //info[0].flags = 0;      
      
      return 1;    //Return the number of filled BranchInfo elements  
                   //If info[1] was used here. use return 2...etc.....  
    }  
      
      
    Bool RegisterMySceneHook(void)  
    {      
      return RegisterSceneHookPlugin(ID_MYSCENEHOOK, "My SceneHook", 0, MySceneHook::Alloc, EXECUTIONPRIORITY_EXPRESSION, 0, NULL);  
    }
    

    Any other info about SceneHooks that anyone can provide would also be greatly appreciated. I'm still trying to grasp the basics with them.

    -ScottA



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

    On 15/10/2011 at 10:56, xxxxxxxx wrote:

    Where did you see that we aren't supposed to override GetBranchInfo any more? It's still in the R12 and indeed R13 SDK. The only thing aboout your code is that the definition of GetBranchInfo has changed - instead of ULONG flags, it's GETBRANCHINFO flags from R12 onwards.

    Try that and see if it compiles now.



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

    On 15/10/2011 at 12:29, xxxxxxxx wrote:

    Thanks Spedler.

    When I tried to compile it. V.S. gave me an error that override wasn't available. So I did a search for "SceneHookData" in the SDK examples. And found the c4d_scenehookdata.h file that has virtual LONG GetBranchInfo() commented out.
    So I thought maybe they took it out and used some other method. But Being new to this kind of Hook I wasn't really sure.

    After replacing "ULONG flags" with "GETBRANCHINFO flags". The only other problem I'm having with it now is the line: info[0].flags = 0;
    It's producing this error "cannot convert from int to 'BRANCHINFOFLAGS'

    -ScottA



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

    On 15/10/2011 at 13:07, xxxxxxxx wrote:

    Hi,

    If you didn't found the solution yet, just use GETBRANCHINFO_0 instead of literal 0. Or see GETBRANCHINFO enum in ge_prepass.h header file for other possible flags.



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

    On 15/10/2011 at 13:26, xxxxxxxx wrote:

    Ugh. I'm just not getting it.
    I'm sure I'm missing something really stupid.

    LONG MySceneHook::GetBranchInfo(GeListNode *node, BranchInfo *info, LONG max, GETBRANCHINFO flags)   
    {  
      //Specify if your node acts as a container of other nodes  
      //fill the info structure array; only one element is saved in this example  
      
      info[0].head = head;           //An array of elements  
      //info[1].head = myotherhead;  //Another array of list elements..Not used here  
      info[0].name = &hookname;  
      info[0].id = ID_MYSCENEHOOK;  
      info[0].flags = GETBRANCHINFO_0;   //<----- Does not work       
      
      return 1;    //Return the number of filled BranchInfo elements  
                   //If info[1] was used here. use return 2...etc.....  
    }
    

    -ScottA



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

    On 15/10/2011 at 13:41, xxxxxxxx wrote:

    Ah ok my fault 🙂.
    BranchInfo.flags is of type enum BRANCHINFOFLAGS , so the flag to use in your code is BRANCHINFOFLAGS_0.
    GETBRANCHINFO enum is used to send specific flags to GetBranchInfo() method. _

    _



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

    On 15/10/2011 at 14:09, xxxxxxxx wrote:

    Bingo! That's the ticket. 🍺
    After all this fuss getting it to work. I don't see it anywhere in the C4D UI. So now I have to learn how to actually use it. 😊

    As I understand it. It's supposed to let you store things in a document (virtual?) so you can use them in your current document? I'm not really sure how that works.

    This is the thread I got it from: https://plugincafe.maxon.net/topic/5000/4913_nodedata-list&KW=extremly+simple+Nodedata&PID=20203#20203

    -ScottA



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

    On 19/10/2011 at 02:39, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Thanks Spedler.

    When I tried to compile it. V.S. gave me an error that override wasn't available. So I did a search for "SceneHookData" in the SDK examples. And found the c4d_scenehookdata.h file that has virtual LONG GetBranchInfo() commented out.
    So I thought maybe they took it out and used some other method. But Being new to this kind of Hook I wasn't really sure.

    SceneHookData inherits GetBranchInfo from its parent class NodeData.

    cheers,
    Matthias



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

    On 19/10/2011 at 07:37, xxxxxxxx wrote:

    Thanks Matthias.

    I have it working now. But I don't understand how to use it.
    I'm new to scene hooks. And I've only just learned about things like: BranchInfo(), GeListHead() & GelistNode().
    I was introduced to these things recently when dealing with layers.

    I think I understand the basics of these things. And how you can store&retrieve data from them where GeListHead() is the root etc...
    But I'm still not sure how to use your example to do that.

    -ScottA


Log in to reply