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
ReferenceMakerclass. The target object is called the reference target and is derived from theReferenceTargetclass. Reference relationships are not represented by a specific class, but are managed by methods of theReferenceMakerclass. For example, if a node is deleted from the scene, the reference maker that references the deleted node will receive theREFMSG_TARGET_DELETEDmessage through theReferenceMaker::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
ISceneEventManagerclass. 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
ISceneEventManagerclass for more informationBroadcast Notification System - The broadcast notification system uses callback functions when certain events occur. The header file
notify.hcontains 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_NODEandNOTIFY_SCENE_POST_DELETED_NODEmessages are sent with acallParamcontaining anINode*. The following code snippet demonstrates how to register a callback to handle theNOTIFY_SCENE_PRE_DELETED_NODEmessage.//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.
