This object provides access to the SteamVR interface.
Related sample code
Other related reference items
Related help topics
This function does not accept any parameters. |
This function does not return any values. |
clear_layers ( )Clears all layers
|
This function does not accept any parameters. |
This function does not return any values. |
controller_held ( controller, button ) : booleanReturns true or false depending if the specified button is held this frame for a given controller.
|
controller : | integer | Controller index |
button : | integer | Controller button [SteamVR.BUTTON_SYSTEM, SteamVR.BUTTON_MENU, SteamVR.BUTTON_GRIP, SteamVR.BUTTON_TOUCH and SteamVR.BUTTON_TRIGGER SteamVR.BUTTON_TOUCH_UP, SteamVR.BUTTON_TOUCH_DOWN, SteamVR.BUTTON_TOUCH_LEFT, SteamVR.BUTTON_TOUCH_RIGHT] |
boolean |
Returns true if specified button is held on controller, false otherwise. |
controller_local_pose ( index ) : stingray.Matrix4x4Returns the local pose of the specified controller.
|
index : | integer | Controller index |
Local pose of the controller |
Identity matrix is returned if controller is not tracked.
controller_pressed ( controller, button ) : booleanReturns true or false depending if the specified button is pressed this frame for a given controller.
|
controller : | integer | Controller index |
button : | integer | Controller button [SteamVR.BUTTON_SYSTEM, SteamVR.BUTTON_MENU, SteamVR.BUTTON_GRIP, SteamVR.BUTTON_TOUCH and SteamVR.BUTTON_TRIGGER SteamVR.BUTTON_TOUCH_UP, SteamVR.BUTTON_TOUCH_DOWN, SteamVR.BUTTON_TOUCH_LEFT, SteamVR.BUTTON_TOUCH_RIGHT] |
boolean |
Returns true if specified button is pressed on controller, false otherwise. |
controller_pulse ( index, seconds )Triggers a haptic pulse on the specified controller.
|
index : | integer | Controller index |
seconds : | number | Duration of pulse in seconds, the maximum length of a pulse is 0.003999 seconds. |
This function does not return any values. |
This should be called every frame you want the vibration to happen. The duration of the pulse supplied to this function is, in effect, the vibration strength.
controller_released ( controller, button ) : booleanReturns true or false depending if the specified button has been released this frame for a given controller.
|
controller : | integer | Controller index |
button : | integer | Controller button [SteamVR.BUTTON_SYSTEM, SteamVR.BUTTON_MENU, SteamVR.BUTTON_GRIP, SteamVR.BUTTON_TOUCH and SteamVR.BUTTON_TRIGGER SteamVR.BUTTON_TOUCH_UP, SteamVR.BUTTON_TOUCH_DOWN, SteamVR.BUTTON_TOUCH_LEFT, SteamVR.BUTTON_TOUCH_RIGHT] |
boolean |
Returns true if specified button is released on controller, false otherwise. |
controller_setup ( unit, root, material )Setup and create a controller mesh by filling geometry buffers and applying the specified material.
|
unit : | Controller unit | |
root : | string | Name of geometry root |
material : | string | Name of material |
This function does not return any values. |
controller_touched ( controller, button ) : booleanReturns true or false depending if the specified button has been touched this frame for a given controller.
|
controller : | integer | Controller index |
button : | integer | Controller button [SteamVR.BUTTON_SYSTEM, SteamVR.BUTTON_MENU, SteamVR.BUTTON_GRIP, SteamVR.BUTTON_TOUCH and SteamVR.BUTTON_TRIGGER SteamVR.BUTTON_TOUCH_UP, SteamVR.BUTTON_TOUCH_DOWN, SteamVR.BUTTON_TOUCH_LEFT, SteamVR.BUTTON_TOUCH_RIGHT] |
boolean |
Returns true if specified button is touched on the controller, false otherwise. |
Note, only SteamVR.BUTTON_TOUCH currently has these events. If other buttons are requested, false will be returned.
controller_untouched ( controller, button ) : booleanReturns true or false depending if the specified button has been untouched this frame for a given controller.
|
controller : | integer | Controller index |
button : | integer | Controller button [SteamVR.BUTTON_SYSTEM, SteamVR.BUTTON_MENU, SteamVR.BUTTON_GRIP, SteamVR.BUTTON_TOUCH and SteamVR.BUTTON_TRIGGER SteamVR.BUTTON_TOUCH_UP, SteamVR.BUTTON_TOUCH_DOWN, SteamVR.BUTTON_TOUCH_LEFT, SteamVR.BUTTON_TOUCH_RIGHT] |
boolean |
Returns true if specified button is untouched on the controller, false otherwise. |
Note, only SteamVR.BUTTON_TOUCH currently has these events. If other buttons are requested, false will be returned.
controller_value ( controller, button ) : number, numberReturns the analog values of a specified controller button.
|
controller : | integer | Controller index |
button : | integer | Controller button [SteamVR.BUTTON_SYSTEM, SteamVR.BUTTON_MENU, SteamVR.BUTTON_GRIP, SteamVR.BUTTON_TOUCH and SteamVR.BUTTON_TRIGGER SteamVR.BUTTON_TOUCH_UP, SteamVR.BUTTON_TOUCH_DOWN, SteamVR.BUTTON_TOUCH_LEFT, SteamVR.BUTTON_TOUCH_RIGHT] |
number |
First analog value of specified controller button. If unused, 0.0 is returned. |
number |
Second analog value of specified controller button. If unused, 0.0 is returned. |
If SteamVR.BUTTON_TOUCH is requested, x and y analog positions will be returned. Otherwise, for any other button, the first value will contain the analog value (varying between 0 and 1) while the second will always be 0.
controller_world_pose ( index ) : stingray.Matrix4x4Returns the world pose of the specified controller.
|
index : | integer | Controller index |
World pose of the controller |
Identity matrix is returned if controller is not tracked.
create_layer ( name, layer_rt )Creates a monoscopic image that is displayed as a rectangle at a given pose and size in the virtual world.
|
name : | string | The layer name. |
layer_rt : | string | The layer render target name. |
This function does not return any values. |
This is useful for heads-up-displays, text information, object labels and so on.
fade_to_color ( color, seconds )Fades the view on the HMD to the specified color.
|
color : | Color to fade in/out | |
seconds : | number | Time to fade in/out |
This function does not return any values. |
This color is faded on top of the scene based on the alpha parameter that you pass to stingray.Color() when you create the color object you pass in the color parameter. Note that this function requires the alpha value to be the first parameter.
For example, to remove the fade color instantly, you can "fade" to a fully transparent color with a time of 0 seconds:
stingray.SteamVR.fade_to_color(stingray.Color(0, 0, 0, 0), 0)
To fade to a semi-transparent blue over the course of 2 seconds:
stingray.SteamVR.fade_to_color(stingray.Color(127, 0, 0, 255), 2) -- Alpha = 127, Blue = 255
Or, to fade in a fully opaque white over the course of 5 seconds:
stingray.SteamVR.fade_to_color(stingray.Color(255, 255, 255, 255), 5)
hmd_local_pose ( ) : stingray.Matrix4x4, stingray.Matrix4x4, stingray.Matrix4x4Returns the head, left eye and right eye local poses of the HMD.
|
This function does not accept any parameters. |
Head local pose | |
Left eye local pose | |
Right eye local pose |
If not tracked, identity matrices are returned.
hmd_world_pose ( ) : stingray.Matrix4x4, stingray.Matrix4x4, stingray.Matrix4x4Returns the head, left eye and right eye world poses of the HMD.
|
This function does not accept any parameters. |
Head world pose | |
Left eye world pose | |
Right eye world pose |
If not tracked, identity matrices are returned.
initialize ( render_target, camera, world, flags ) : booleanInitializes SteamVR system.
|
render_target : | string | The stereo render target name. |
camera : | The camera used for stereo rendering. | |
world : | The world containing the camera. | |
flags : | integer? | Optional; Initialization flags. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
boolean |
Returns true if SteamVR was initialized properly, otherwise returns false. |
is_hmd_tracked ( index ) : booleanReturns if a specified controller is tracked.
|
index : | integer | Controller index |
boolean |
Returns true if controller with the specified index is currently tracked, otherwise returns false. |
is_hmd_tracked ( ) : booleanReturns if HMD is tracked.
|
This function does not accept any parameters. |
boolean |
Returns true if HMD is currently tracked, otherwise returns false. |
link_node_to_tracker ( unit, node, world, type, index )Links a Unit node to be automatically updated by the VR tracker.
|
unit : | Unit to link to tracker | |
node : | integer | Scene graph node that is linked within the unit |
world : | World containing the unit | |
type : | integer | Type of tracker link (SteamVR.LINK_HMD or SteamVR.LINK_CONTROLLER) |
index : | integer? | Optional index when using SteamVR.LINK_HMD (SteamVR.EYE_LEFT or SteamVR.EYE_RIGHT, omitting the index will simply link to HMD) or controller index The ? notation indicates that this type is optional: there may be zero or one instances of it. |
This function does not return any values. |
remove_layer ( name )Removes the specified layer.
|
name : | string | The layer name. |
This function does not return any values. |
set_camera ( camera, world )Sets a new camera for SteamVR.
|
camera : | The camera used for stereo rendering. | |
world : | The world containing the camera. |
This function does not return any values. |
This is useful, when you create a new world in your game and want to transition to it in VR
set_high_quality_layer ( name, hq_enabled, curved, min_curve, max_curve )Specify if a layer should use the high quality render path and which high quality options it should have enabled.
|
name : | string | The name of the layer to set to the high quality render path. |
hq_enabled : | boolean | Whether or not this layer should use the high quality render path. |
curved : | boolean? | Optional; Whether or not to curve the layer (only in high quality rendering). The ? notation indicates that this type is optional: there may be zero or one instances of it. |
min_curve : | number? | Optional; Distance in meters where the layer will be most curved. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
max_curve : | number? | Optional; Distance in meters where the layer will be least curved. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
This function does not return any values. |
Only one high quality layer is supported at a time.
set_layer_dimensions ( name, width )Sets the width of the layer quad in meters.
|
name : | string | The name of the layer to update. |
width : | number | The layer quad width in meters |
This function does not return any values. |
By default layers are rendered on a quad that is 1 meter across.
set_layer_pose ( name, pose, headlocked )Sets the layer pose.
|
name : | string | The name of the layer to update. |
pose : | The layer center pose. | |
headlocked : | boolean | Whether the layer pose is relative to the HMD (headlocked) or if it's in worldspace. |
This function does not return any values. |
By default, the pose is headlocked 0.5m infront of the HMD.
set_layer_visibility ( name, visible )Specify if a layer should be visible or hidden.
|
name : | string | The name of the layer. |
visible : | boolean | Whether or not this layer is visible. |
This function does not return any values. |
set_tracking_space ( position, rotation, scale )Sets tracking space pose
|
position : | Tracking space position | |
rotation : | Tracking space rotation | |
scale : | Tracking space scale |
This function does not return any values. |
Related sample code
set_tracking_space_pose ( pose )Sets provided pose as the default tracking space pose DEPRECATED: Use SteamVR.set_tracking_space(Vector3, Quaternion, Vector3) instead.
|
pose : | Tracking space pose |
This function does not return any values. |
shutdown ( )Shuts down SteamVR system.
|
This function does not accept any parameters. |
This function does not return any values. |
tracking_space_local_rectangle ( ) : stingray.Vector3, stingray.Vector3, stingray.Vector3, stingray.Vector3Returns the local space rectangle corners of the tracking space.
|
This function does not accept any parameters. |
Local position of the corner 1. | |
Local position of the corner 2. | |
Local position of the corner 3. | |
Local position of the corner 4. |
Corners are in counter-clockwise order where the standing center (0,0,0) is the center of the tracking space. The z value of every corner is 0 in local space (on the floor).
tracking_space_pose ( ) : stingray.Matrix4x4Returns the tracking space pose
|
This function does not accept any parameters. |
Tracking space pose |
tracking_space_scale ( ) : stingray.Vector3Returns the tracking space scale
|
This function does not accept any parameters. |
Tracking space scale |
tracking_space_size ( ) : number, numberReturns the size (width, depth) of the tracking space.
|
This function does not accept any parameters. |
number |
The width of the tracking space |
number |
The depth of the tracking space |
tracking_space_world_rectangle ( ) : stingray.Vector3, stingray.Vector3, stingray.Vector3, stingray.Vector3Returns the world space rectangle corners of the tracking space.
|
This function does not accept any parameters. |
World position of the corner 1. | |
World position of the corner 2. | |
World position of the corner 3. | |
World position of the corner 4. |
Corners are in counter-clockwise order and are centered around the defined tracking space pose.
unlink_node_from_tracker ( unit, node )Unlinks a Unit node that is being automatically updated by the VR tracker.
|
unit : | Unit to unlink from the VR tracker | |
node : | integer | Scene graph node within the unit that is to be unlinked |
This function does not return any values. |