Share

Monitoring the Node Events

You can monitor the node events in a scene using one of these methods:

  • Reference System - The reference system is an implementation of the subject-observer pattern. Objects (observers) that must be notified of changes to target objects (subjects) are called reference makers and are derived from the ReferenceMaker class. The target object is called the reference target and is derived from the ReferenceTarget class. Reference relationships are not represented by a specific class, but are managed by methods of the ReferenceMaker class. For example, if a node is deleted from the scene, the reference maker that references the deleted node will receive the REFMSG_TARGET_DELETED message through the ReferenceMaker::NotifyRefChanged() method, and it can respond appropriately to the node deletion event. Obtaining complete information about each node in a scene requires managing several references, which can be complex and in this case using one of the other alternative systems is recommended.

    See Reference System for more information.

  • Scene Event System - The scene event system provides a simplified mechanism for monitoring all nodes in a scene simultaneously using the ISceneEventManager class. This system supports a broader range of messages than the other systems, but provides fewer details regarding single events. It is useful in situations that require high-level information about the node changes and where precision timing of messages is not a priority. For example, it is an ideal method to use for monitoring the scene to trigger a UI refresh.

    See ISceneEventManager class for more information

  • Broadcast Notification System - The broadcast notification system uses callback functions when certain events occur. The header file notify.h contains the list of notification event IDs that can be handled.

    The following example shows how to handle a node deletion event by registering a notification callback with the broadcast notification system. When a node is deleted, the NOTIFY_SCENE_PRE_DELETED_NODE and NOTIFY_SCENE_POST_DELETED_NODE messages are sent with a callParam containing an INode*. The following code snippet demonstrates how to register a callback to handle the NOTIFY_SCENE_PRE_DELETED_NODE message.

    //Declare the callback function  
    static void NodeDeleteNotify(void *param, NotifyInfo *info)
    {
      // Get the nodes being deleted
      INode* deleted_node = (INode*)info->callParam;
      
      // Do custom processing
       ...
    }
     
    // Register the callback
    RegisterNotification(NodeDeleteNotify, this, NOTIFY_SCENE_PRE_DELETED_NODE);
     
    ...
     
    // When done, unregister the callback
    UnRegisterNotification(NodeDeleteNotify, this, NOTIFY_SCENE_PRE_DELETED_NODE);

    See Broadcast Notification System for more information.

Was this information helpful?