Skip to main content

Events

Writing Lua scripts can be quite an involved process, so Visionary Render enables you to automatically generate common scripts using Events. An EventHandler can be attached to an Assembly, which then registers interest in certain Events. These events may have a Guard condition attached to them to filter for specific occurrences of these events.

To create an Event, right-click on a node and select Create > Event from the context menu. A default Key Press Event should be added as in the image above.

Event

EventRegistersDescription
Activate__OtherFired when vrActivate is called. The caller of vrActivate can set the value of __Other to whatever is required inside this event. Also triggered by double clicking on some node types in the tree.
Break__OtherFired when two objects stop touching each other in the scene. __Self is this object, __Other is the object that it touched. The guard condition can be set to an Assembly to only fire Break events for that Assembly instead of any node in the scene. Note: you’ll need to add a Collision node to __Self for this event to be fired.
ClickFired when a 3D GUI item receives a full click (a press followed by a release)
CreateFired when the node is created, loaded from file, or when the event script is compiled.
Double ClickFired when a 3D GUI item receives a double click.
EnterFired when a fly-to operation arrives at the node.
Gesture Activated__GestureFired when a gesture is made that matches one of the recorded ones.
Key Press__KeyCode, __KeyStateFired when a key on the keyboard is pressed, or the mouse is clicked, or a tracker button is pressed.
Key Release__KeyCode, __KeyStateFired when a key, mouse, or tracker button is released.
LeaveFired when a subsequent fly-to operation flies somewhere else.
MoveFired when an assembly is moved in the scene.
Pose Entered__Pose, __PoseStateFired when a pose is made.
Pose Left__Pose, __PoseStateFired when a pose is left.
PressFired when a 3D GUI item is pressed (i.e. the cursor is held down).
ReleaseFired when a 3D GUI item is released.
RenameFired when the node is renamed.
SequenceFired when the sequencer reaches an event frame.
Time Step__TimeDeltaFired every frame.
ToggleFired when a 3D GUI item toggle state changes.
Touch__OtherFired when two objects touch each other in the scene. __Self is this object, __Other is the object that it touched. The guard condition can be set to an Assembly to only fire Touch events for that Assembly instead of any node in the scene. Note: you’ll need to add a Collision node to __Self for this event to be fired.
View Deselect__OtherFired when a node is deselected. This otherwise behaves the same as View Select.
View Select__OtherFired when a node is selected. __Other contains the view selection node containing the selection. Note that selecting in the Scenes or Developer views will fire this event twice (once for each view, as the selection is synchronized).

Guard

The Guard condition may be:

  • A key on the keyboard (modifiers can be used, e.g. Ctrl, Alt, Shift).
  • A time value in seconds.
  • An Assembly.

Action

If an event occurs and the Guard condition is met, an Action is performed. Examples of typical actions include:

  • Activate a Snapshot
  • Play a Sequence
  • Fly to a Viewpoint
  • Change a Material
  • Execute a Lua Script
  • Toggle the enabled state
  • Play a sound

Assembly

All the Actions have been dragged and dropped onto the EventHandler property window from the Scenes, Libraries or Developer window. When dragging a node which Visionary Render is not sure what to do with it offers you a choice depending on the type of node that is dropped:

ActionDescription
DisableSet the Enabled state of the Assembly to OFF.
EnableSet the Enabled state of the Assembly to ON.
Fly ToFly the view to the Assembly location.
Fly To FitFly the view to bounding box of the Assembly.
Look AtRotate the view to look at the Assembly.
ToggleToggle the Enabled state of the Assembly.
note

The same actions are provided for Lights, Dynamic Sections and Viewpoints.

Snapshot

When dragging a Snapshot, it will execute that snapshot.

Sequence

When dragging a Sequence from the Developer view or the Browser it will present these options:

ActionDescription
Decrease SpeedDivide the current play speed by 2.
Increase SpeedIncrease the current play speed by a factor of 2.
PausePauses the sequence playback.
Play ForwardSets the sequence to be played forward and set the sequence playing.
Play ReverseSets the sequence to be played backward and set the sequence playing.
Seek to EndSet the current position to be the end of the sequence.
Seek to StartSet the current position to be the start of the sequence.
Switch DirectionToggles the current sequence playback direction.
ToggleToggles the playing state of the sequence.

Group

When dragging a Group, it will present a menu to Disable, Enable, Toggle or Execute any of the Snapshots on that Group. The Group can be dragged from the Scenes, Developer or Browser tab.

Movie

When dragging a Movie onto the Action it will Pause, Play or Toggle. The Movie can be dragged from the Library or Browser tabs.

Model

When dragging a Model, it will simply change the Model used from its current one to the dropped Model. The script must be on an Assembly with a Visual for this to work. The Model can be dragged from the Browser or Libraries tab.

Material

When dragging a Material onto the Action, it will present the following options:

ActionDescription
Apply To OtherIf the Event is touch or break, then the material is applied to the assembly that touched this assembly (the “other” assembly). Any other event causes undefined behaviour.
Apply To ThisApplies the material to the Visual as a Material Override.
Clear From OtherIf the Event is touch or break, then the material is cleared from the assembly that touched this assembly (the “other” assembly). Any other event causes undefined behaviour.
Clear From ThisDragging any material and selecting this option will clear the Material Override from the Visual.

AudioSound

When dragging an AudioSound from the Developer tab, it will play the sound when the Event is triggered.

AudioTrack

When dragging an AudioTrack from the Developer tab onto an Action, it will offer the following options:

ActionDescription
PlayStarts playing the sound at the last point it was paused.
PausePauses the playback of the sound.
StopResets it back to the start of the sound.

Browser

Scripts can also be navigated in the Browser. In the small and large icon views, the name of the script is shown beneath an icon. In the list view, event type, guard and parent assemblies are also shown.

Double-click on a script to open it in the Script Editor.