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