7.20. SetMaterialAttributeValue

set_material_attribute_value ‐ Dynamic modification of the material or the video properties

7.20.1. Attributes

NameTypeDefaults
operatorSTRINGNone (required)

7.20.2. Description

This action is used to modify the values associated with attributes in a color, a material, a texture, a shader_source_texture, a video, or a shader_source_video element. 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 string value of the operator attribute is an operator string. The values of the operator must be "=", "=", "+=", "-=", "*=", or "/=". The child node should be a color, or any possible child of a material element, a texture, a shader_source_texture, a video, or a shader_source_video. The currently supported children of material elements are ambient, diffuse, specular, emission, and shininess.

The attributes of the child node are called source attributes. The target node must have an element (a media-object) with a color, a material, a texture, a shader_source_texture, a video, or a shader_source_video child. This color, material, texture, shader_source_texture, video, or shader_source_video element is called the target material. In this case, the values of the source attributes are used to modify the values of the corresponding child element in the target material.

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

As another example, if the source element is a video with attributes begin and end that define the begin and end time of video playing, and if the operator is "=", the source values define the begin and end time of the target video property.

7.20.3. Expected children

The following element must occur in set_material_attribute_value: one color or one child node of a material element, one texture, one shader_source_texture, one video, or one shader_source_video.

7.20.4. Expected target

The target node must have a child element with color, material texture, shader_source_texture, video, or shader_source_video properties.

7.20.5. Example

The example below defines an action that sets the values of the three diffuse primary colors to 0.75, 0.6, and 0.22.

<set_material_attribute_value operator="=">
  <diffuse r="0.75" g="0.6" b="0.22"/> 
</set_material_attribute_value>

The example below rewinds a video by setting its begin time at the current time.

<set_material_attribute_value operator="=">
  <video begin="now" end="(now + 10000)"/>
</set_material_attribute_value>

In the case of shader_source_video, the index of the video in the list of shader material properties should be provided.

<set_material_attribute_value index="1" operator="=">
  <shader_source_video begin="now" end="(now + 10000)"/>
</set_material_attribute_value>