On 14/09/2014 at 08:40, xxxxxxxx wrote:
Nothing difficult about them. You just have to keep in mind that they run above the document level, near to C4D level, therefore your SceneHook should do its thing (if there is anything to be done) and get out fast. Here a basic example of a SceneHook:
MySceneHook.h
#pragma once
////////////////////////////////////////////////////////////////
// MySceneHook.h
////////////////////////////////////////////////////////////////
// CLASS: MySceneHook
class MySceneHook : public SceneHookData
{
INSTANCEOF(MySceneHook, SceneHookData)
public:
// General
MySceneHook();
~MySceneHook();
// SceneHookData
Bool Message(GeListNode* node, LONG type, void* data);
// - Alloc
static NodeData* Alloc() { return gNew MySceneHook; }
};
MySceneHook.cpp
////////////////////////////////////////////////////////////////
// MySceneHook.cpp
////////////////////////////////////////////////////////////////
#include "c4d.h"
#include "MySceneHook.h"
// METHODS: MySceneHook ==================================================================================================
// Constructor
//*---------------------------------------------------------------------------*
MySceneHook::MySceneHook()
//*---------------------------------------------------------------------------*
{
}
// Destructor
//*---------------------------------------------------------------------------*
MySceneHook::~MySceneHook()
//*---------------------------------------------------------------------------*
{
}
// NodeData.Message
//*---------------------------------------------------------------------------*
Bool MySceneHook::Message(GeListNode* node, LONG type, void* data)
//*---------------------------------------------------------------------------*
{
if (type != MSG_DOCUMENTINFO)
return TRUE;
DocumentInfoData* pDocumentInfo = static_cast<DocumentInfoData*>(data);
if (!pDocumentInfo)
return FALSE;
if (pDocumentInfo->type == MSG_DOCUMENTINFO_TYPE_UNDO)
{
// Do whatever - as quickly as possible
}
return SUPER::Message(node,type,data);
}
// Global Registrant Method for MySceneHook plugin
//*---------------------------------------------------------------------------*
Bool RegisterMySceneHook()
//*---------------------------------------------------------------------------*
{
return RegisterSceneHookPlugin(ID_MYSCENEHOOK, "SceneHook", PLUGINFLAG_HIDE|PLUGINFLAG_HIDEPLUGINMENU|PLUGINFLAG_SCENEHOOK_NOTDRAGGABLE, MySceneHook::Alloc, EXECUTIONPRIORITY_INITIAL, 0L, NULL);
}