<ifAction> ‐ A conditional execution of structured actions
The ifAction element is used to control the execution a sequence or structured actions.
The float value of the value1 and value2 attributes define the condition under which the embraced actions are executed. The value Op of the string attribute bool_operator defines the value comparison operator: ==, <=, <, >=, >, or !=. The execution of the sequence of operations in the ifAction element is only performed if the result of the boolean comparison value1 Op value2 is true.
Inside the ifAction element, an empty elseAction element can be inserted in order to define a sequence of elementary or structured actions that are executed if the boolean test is false. In this case the sequence of actions executed if the test is true are the actions between the opening ifAction element and the empty elseAction element, the sequence of actions executed if the test is false are the actions between the empty elseAction element and the closing ifAction element.
A sequence of structured actions: action, repeatAction, whileAction, or ifAction elements.
The following example is an ifAction. in which the first structured action is executed if the variable level of the node motion is equal to 1. If not, the second structured action (the one that follows the empty elseAction element) is executed:
<ifAction value1="({$motion:level})" value2="1" operator="=="> <action> <set_node_attribute_value operator="=" > <transformation x="({$motion:target.X} - {$root:cam_transl[({$motion:level})]})" y="({$motion:target.Y})" z="({$motion:target.Z})" /> </set_node_attribute_value> <target type="single_node" value="#target_trans_camera.({$motion:level})" /> </action> <elseAction/> <action> <set_node_attribute_value operator="=" > <transformation x="({$motion:target.X} - {$root:cam_transl[({$motion:level} - 1)]})" y="({$motion:target.Y})" z="({$motion:target.Z})" /> </set_node_attribute_value> <target type="single_node" value="#target_trans_camera.({$motion:level})" /> </action> </ifAction>