7.21. SetNodeAttributeValue

set_node_attribute_value ‐ Dynamic modification of the attribute values of a node or of its child element (a media-object or a transformation)

7.21.1. Attributes

NameTypeDefaults
operatorSTRINGNone (required)

7.21.2. Description

This action is used to modify the values associated with attributes in a node node or in a node child element (media-object or transformation). The string value of the operator attribute is an operator string. The values of the operator must be "=", "=", "+=", "-=", "*=", or "/=". The child element is a node child that contains at least one attribute and its associated value or the set_node_attribute_value action is an empty XML element. If the set_node_attribute_value element is empty, the attributes modified by this action are the node attributes or the attributes of its physical properties (see second example below). If the attribute values contain parenthesized expressions, they are dynamically evaluated as numerical expressions and their values are replaced in the attribute value strings.

The attributes of the child node are called source attributes. If the child node is a node child element (a transformation or a media object), the target node must contain an element of the same type as the child node (for instance, the child node is a quad element and the target node contains a quad element). If source and target type match, the values of the source attributes are used to modify the values of the corresponding attributes in the target node child element. If there is no child node (the set_node_attribute_value action is an empty XML element), the values of the source attributes are used to modify the attributes in the target node.

For instance if the source element is a quad that contains the attributes x1, y1, and z1, and if the operator is "=", the source values replace the target values. The other operators respectively correspond to addition, substraction, multiplication, and division of the target values by the source values. The attributes of the target element that are not instantiated in the source node element (the child node) are not modified by this action.

7.21.3. Expected children

If it is not an empty element, the following element must occur in set_node_attribute_value: a node child element (media-object or transformation).

7.21.4. Expected target

If the node is not an empty element, the child node is a node child element, and the target node must contain an element of the same type as the second argument (a media-object or a transformation). If the set_node_attribute_value element is not empty, the target node can be any node in a scene graph.

7.21.5. Example

The example below defines an action that increases the values of the coefLoop1 and coefLoop2 attributes of the target subdivision node(s).

<set_node_attribute_value operator="+=">
  <subdivision coefLoop1="0.1" coefLoop2="0.1"/> 
</set_node_attribute_value>

In the case of node attribute modification, the set_node_attribute_value is an empty node. The example below defines an action that displays the node with the ID patch7_8 and sets its local position at the origin of its coordinate system.

<action>
  <set_node_attribute_value displayed="true" 
                            x_phys="0" y_phys="0" z_phys="0" />
  <target type="single_node" value="#patch7_8" />
</action>