8.2. VC Predefined Variables

There is one specific predefined variable in VC: the variable now that carries the current time. In the expression Equation 8-1, the value is equal to the current time augmented by three times the parameter startdelay.

Equation 8-1. Expression with the now predefined variable

(now + 3 * {#startdelay})

All the other predefined variables are defined as scalars attached to the environment node. In the expression Equation 8-2, the result is the value of the blue color under the mouse pointer. It is obtained by referencing the predefined variable mouse_color_b of the environment node configuration node.

Equation 8-2. Expression with the mouse_color_b predefined variable

({$configuration node:mouse_color_b})

The following table lists all the predefined variables that can be accessed as variables attached to the environment node (see preceding equation Equation 8-2).

Variable IDSemanticsType
current_frameCurrent frame noINTEGER
shiftShift key modifierINTEGER (0 or 1)
altAlt key modifierINTEGER (0 or 1)
controlControl key modifierINTEGER (0 or 1)
mouse_xHorizontal screen coordinate of the cursorFLOAT
mouse_yVertical screen coordinate of the cursorFLOAT
mouse_color_rRed color under the cursorFLOAT
mouse_color_gGreen color under the cursorFLOAT
mouse_color_bBlue color under the cursorFLOAT
window_widthWidth of the current window (in pixels)FLOAT
window_heightHeight of the current window (in pixels)FLOAT
nb_selected_objectsNumber of objects selected through sensor or mouseINTEGER
selected_objectsTable of selected object IDsSTRING TABLE
joystick_xX joystick valueINTEGER
joystick_yY joystick valueINTEGER
joystick_zZ joystick valueINTEGER
joystick_buttonIndex of pressed joystick buttonINTEGER

The following script uses the environment variables nb_selected_objects and selected_objects to enumerate and output to the console the IDs of the selected objects:

<repeatAction begin="1" end="({$conf_node:nb_selected_objects})" 
              step="1" id="n">
  <action>
    <write_console value="ID ({$conf_node:selected_objects[({$main node:n})]})" />
  </action>
</repeatAction>

The following script uses the environment variables that report the joystick manipulation to control navigation steps:

<action>
  <set_node_scalar_value id="angleyaw" 
                 value="({$conf_node:joystick_z}/1000)" 
                 operator="-="/>
  <target type="single_node" value="#root" />
</action>
<action>
  <set_node_scalar_value id="angleroll" 
                 value="({$conf_node:joystick_x}/1000)" 
                 operator="-="/>
  <target type="single_node" value="#root" />
</action>
<action>
  <set_node_scalar_value id="stepx" 
                 value="({$conf_node:joystick_button})" 
                 operator="="/>
  <target type="single_node" value="#root" />
</action>
<action>
  <set_node_scalar_value id="stepy" 
                 value="({$conf_node:joystick_y}/10000)" 
                 operator="="/>
  <target type="single_node" value="#root" />
</action>