SceneGraph

Home About XEngine Engine API SceneGraph Changelog Programming Guide

Index

| Scene Description Language | camera | directory | eventmessage | geometry | group | input | light | node | primitives | root | spinner | transformation | user |

Eventmessage

Derived from: -
Class name: -
Description: Declares an association between an event that is produced by the incuding (parent) node and a message that should be sent to a recipient node.

 

Function List

Name XE_eventmessage_create
Arguments int parent_node_id, const char* event_name, int recipient_node_id, const char* msg, float notification_delay
Return Type bool
Description Creates an event message

For each node type, a number of events is available in order to perform a certain action. For example:
XE_eventmessage_create(input_id, "button1pressed", user_id, "input none", 0.0f);
In the above case, the Input node generates an event each time button 1 is pressed.
When button 1 pressed is pressed, a message is posted to the specified user node which sets the attached input to none (deactivates keyboard input).

Parameters:
- parent_node_id, the node that generates the event
- event_name, the name of the event
- recipient_node_id, the recipient of the event
- msg, the message of the event
- notification_delay, the delay in seconds that need to pass before the event is sent to the recipient

Returns true if the parent node id was found
Notes:  

Name XE_eventmessage_post
Arguments int node_id, const char* msg
Return Type bool
Description Posts an event message
Similarly to the above function, a message can be created and posted explicitly only once during the next update.
For example: XE_eventmessage_post(user_id, "input none");
In the above case, the user node receives a message that removes any attached input.
See function KeyPressedSpecialOperations() in Input.cpp

Parameters:
- node_id - the recipient of the message
- msg - the message of the event

Returns true if the node id was found
Notes:  

 

Scene Description Language Declaration

XML node name eventmessage
Placement: Within any node
Special notes: Multiple eventmessages can be included within the scope of a node, even if they respond to the same event. This is necessary if you need to notify many nodes at once when an event occurs. The event, message and recipient attributes are mandatory.
Inherited attributes: -
New attributes:
attribute type description
event STRING The event that the eventmessage should respond to. Whenever the event is triggered, the text defined in the message attribute is posted to the recipient node, after a time period defined by the delay attribute. No default value.
recipient STRING The scene graph name of the recipient to receive the message.
message STRING The message that is posted to the recipient. Accepted messages and their corresponding values are listed in the documentation of each node.
delay FLOAT The time delay between the event triggering and the message post operations. Default is zero, e.g. the message is dispatched as soon as the event is activated.
Events:
event name condition
-  
Inherited events: -
New messages:
attribute value description
Inherited messages: -
Redefined messages: -
Obsolete messages: -

Example

<world ambient="0.3 0.3 0.3" background="0.2 0.2 0.2">
  
    <camera name="first_person" aperture="50.0" 
            near="2.0" far="1000" follow="Myself" primary="true">
    </camera> 

    <transformation name="environment" scale="1.0,1.0,1.0" translation="0,0,-10">
        
        <object name="geom2" file="arena.obj"></object>
    
    </transformation>
 
    <user name="Myself" control="navigate" speed="2.0" turn="0.5"
          position="0,10,100" lookat="0,10,0" input="MouseKeyboard">
    </user>

    <input name="MouseKeyboard" devicename="device0">
        <eventmessage event="button3pressed" recipient="%Myself" message="input none">
        </eventmessage>    
        <eventmessage event="button1pressed" recipient="%Myself" message="input Console">
        </eventmessage>
    </input>
</world>

Last updated: 3 Jun. 2013