vcVREvents

vcVREvents is used together with Visual Components Experience for interactive Virtual Reality (VR) applications.

How It Works

VRStreaming must be enabled in the configuration file.

Properties

Name Type Access Description
Buttons List of Integer R

- Index 0: a bitmask for pressed buttons, first 32 bits (see ulButtonPressed )

- Index 1: see above, last 32 bits

- Index 2: a bitmask for touched buttons, first 32 bits (see ulButtonTouched )

- Index 3: see above, last 32 bits

ClientId Integer R A number identifying which client sent the data that is currently stored in the VREvents object
DeviceInputs List of Dictionary R

A list of dictionaries, where each dictionary contains the following key-value pairs

- key: "DeviceRole", value: string, "LeftHanded"/"RightHanded"

- key: "Axis2DInputs", value: dict<string, Tuple<float, float>>, 2D inputs (e.g. touchpad)

- key: "AxisInputs", value: dict<string, float>, 1D inputs (e.g. trigger)

- key: "ButtonInputs", value: dict<string, bool>, digital (0/1) button inputs

Note: in all input dictionaries the key value is a string value identifying the input type

(see InputFeatureUsage column in Unity XR input mappings)

DeviceModel String R The model of the connected VR device
Directions List of vcVector R

- Index 0: right controller - forward

- Index 1: right controller - right

- Index 2: left controller - forward

- Index 3: left controller - right

- Index 4: HMD - forward

- Index 5: HMD - right

Note: the up vector can be computed as the crossproduct of the right and forward vector

EventCounter Integer R The number of events processed by the server
EventsEnabled Boolean RW Enable/disable the events
MaxUpdateRate Integer RW Defines the maximum update rate
OneMeterLength Real RW Defines the scale of the units used in Experience. For example, when the value is 1000.0, one meter in Experience is 1000 units in simulation.
Position List of vcVector R

- Index 0: right controller position

- Index 1: left controller position

- Index 2: Head-mounted device (HMD) position

RealEventCounter Integer R Number of events sent by the client

RoomCenter

vcVector R The physical location of the room
Times List of Real R

- Index 0: time as reported by Experience

- Index 1: delta from the last message sent by Experience

- Index 2: delta from the last update (basically the frametime in Experience)

- Index 3: VR event updates skipped before the last update (the client skips sending updates according to the MaxUpdateRate and also if the server is still processing a certain number of old messages)

- Index 4: VR event updates skipped in total

Touches List of vcVector R

- Index 0: Vector (touchpad x-axis, touchpad y-axis, touchpad is pressed (0.0/1.0)) (right controller)

- Index 1: Vector (??? x-axis, ??? y-axis, 0.0) (right controller, device-specific)

- Index 2: Vector (trigger value, has teleported (0.0/1.0), trigger pressed (0.0/1.0)) (right controller)

Methods

Name Return Type Parameters Description
toggleAction None Integer clientId, String action, Boolean value Makes it possible to enable or disable certain VR actions in Visual Components Experience.   The clientId argument is the ClientId received through the VREvents object.   The action argument defines the action to be enabled or disabled.   Teleport toggles the user's ability to teleport,   Elevator toggles the user's ability to use the built-in elevator platform   Pause toggles the user's ability to pause and resume the simulation within Experience.   The value argument denotes whether the action is enabled (True) or disabled (False).

Events

Name Parameters Description
OnVREvents None Called when a VR event has been received and the data in the VREvents object has been updated.

Examples

Example. Print the info for VREvents

from vcScript import *
 
app = getApplication()
vrevents = getApplication().VREvents
last_update = getApplication().RealTime
processed_count = 0
 
def OnVREvents():
  global last_update, processed_count, vrevents, app
  if app.RealTime - last_update > 1.0:
    last_update = app.RealTime
    
    onemeter = vrevents.OneMeterLength
    physical_room_center = vrevents.RoomCenter
    helmet_pos = vrevents.Positions[2]
    helmet_dir = vrevents.Directions[2*2 + 0]
    right_controller_pos = vrevents.Positions[0]
    right_controller_dir = vrevents.Directions[0*2 + 0]
    axis1 = vrevents.Touches[0]
    axis2 = vrevents.Touches[1]
    axis3 = vrevents.Touches[2]
    
    print "VREvents: TIMING: ", processed_count, vrevents.Times[0], vrevents.Times[1], vrevents.Times[2], vrevents.Times[3], vrevents.Times[4]
    print "VREvents: ROOM INFO: ", physical_room_center.X, physical_room_center.Y, physical_room_center.Z, ", OneMeter:", onemeter
    print "VREvents: HELMET:", helmet_pos.X, helmet_pos.Y, helmet_pos.Z, helmet_dir.X, helmet_dir.Y, helmet_dir.Z
    print "VREvents: CONTROLLER:", right_controller_pos.X, right_controller_pos.Y, right_controller_pos.Z, right_controller_dir.X, right_controller_dir.Y, right_controller_dir.Z
    print "VREvents: AXIS1:", axis1.X, axis1.Y, axis1.Z
    print "VREvents: AXIS2:", axis2.X, axis2.Y, axis2.Z
    print "VREvents: AXIS3:", axis3.X, axis3.Y, axis3.Z
    print "VREvents: BUTTONS: ", vrevents.Buttons[0], vrevents.Buttons[1], vrevents.Buttons[2], vrevents.Buttons[3]
    
    print "---------------------------------------"
    print "Device model:", vrevents.DeviceModel
    print "Client ID:", vrevents.ClientId
    
    for di in vrevents.DeviceInputs:
      print "---------------------------------------"
      print "Device role:", di["DeviceRole"]
      for name, value in di["Axis2DInputs"].iteritems():
        print "Input:", name, value
      for name, value in di["AxisInputs"].iteritems():
        print "Input:", name, value
      for name, value in di["ButtonInputs"].iteritems():
        print "Input:", name, value
      print "---------------------------------------"
    
    processed_count = 0
  else:
    processed_count = processed_count + 1
 
vrevents.EventsEnabled = True
vrevents.MaxUpdateRate = 20
vrevents.OnVREvents = OnVREvents
 
print "VREvents: ", vrevents.EventsEnabled, vrevents.MaxUpdateRate