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.
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
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 ID | Semantics | Type |
---|---|---|
current_frame | Current frame no | INTEGER |
shift | Shift key modifier | INTEGER (0 or 1) |
alt | Alt key modifier | INTEGER (0 or 1) |
control | Control key modifier | INTEGER (0 or 1) |
mouse_x | Horizontal screen coordinate of the cursor | FLOAT |
mouse_y | Vertical screen coordinate of the cursor | FLOAT |
mouse_color_r | Red color under the cursor | FLOAT |
mouse_color_g | Green color under the cursor | FLOAT |
mouse_color_b | Blue color under the cursor | FLOAT |
window_width | Width of the current window (in pixels) | FLOAT |
window_height | Height of the current window (in pixels) | FLOAT |
nb_selected_objects | Number of objects selected through sensor or mouse | INTEGER |
selected_objects | Table of selected object IDs | STRING TABLE |
joystick_x | X joystick value | INTEGER |
joystick_y | Y joystick value | INTEGER |
joystick_z | Z joystick value | INTEGER |
joystick_button | Index of pressed joystick button | INTEGER |
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>