Merge branch 'main' into interaction

This commit is contained in:
Crispy 2021-05-18 12:36:12 +02:00
commit 3e2a6096bf
57 changed files with 3550 additions and 195 deletions

View file

@ -1,27 +1,43 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=10 format=2]
[ext_resource path="res://addons/openvr_overlay/OverlayInstance.tscn" type="PackedScene" id=1] [ext_resource path="res://addons/openvr_overlay/OverlayInstance.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/openvr_overlay/interaction/OverlayInteraction.tscn" type="PackedScene" id=2] [ext_resource path="res://overlays/FPSOverlay.tscn" type="PackedScene" id=2]
[ext_resource path="res://overlays/TimeOverlay.tscn" type="PackedScene" id=3] [ext_resource path="res://overlays/TimeOverlay.tscn" type="PackedScene" id=3]
[ext_resource path="res://temp.gd" type="Script" id=4] [ext_resource path="res://temp.gd" type="Script" id=4]
[ext_resource path="res://overlays/xyz_widget/zx.tscn" type="PackedScene" id=5] [ext_resource path="res://overlays/xyz_widget/zx.tscn" type="PackedScene" id=5]
[ext_resource path="res://overlays/xyz_widget/yz.tscn" type="PackedScene" id=6] [ext_resource path="res://overlays/xyz_widget/yz.tscn" type="PackedScene" id=6]
[ext_resource path="res://overlays/BatteryOverlay.tscn" type="PackedScene" id=7]
[ext_resource path="res://addons/openvr_overlay/interaction/OverlayInteraction.tscn" type="PackedScene" id=8]
[sub_resource type="Environment" id=1] [sub_resource type="Environment" id=1]
background_mode = 1 background_mode = 1
background_color = Color( 0.105882, 0.0862745, 0.164706, 1 ) background_color = Color( 0.113725, 0.0705882, 0.196078, 1 )
[node name="Overlays" type="Node"] [node name="Overlays" type="Node"]
script = ExtResource( 4 ) script = ExtResource( 4 )
[node name="OverlayInstance Battery" parent="." instance=ExtResource( 1 )]
target = 1
overlay_scene = ExtResource( 7 )
offset_pos = Vector3( -0.12, 0, 0.1 )
offset_rot = Vector3( -135, 90, 0 )
[node name="OverlayInteraction" parent="OverlayInstance Battery" instance=ExtResource( 8 )]
[node name="OverlayInstance FPS" parent="." instance=ExtResource( 1 )]
target = 1
overlay_scene = ExtResource( 2 )
offset_pos = Vector3( 0.05, -0.01, 0.15 )
offset_rot = Vector3( -135, 90, 0 )
[node name="OverlayInstance Time" parent="." instance=ExtResource( 1 )] [node name="OverlayInstance Time" parent="." instance=ExtResource( 1 )]
target = 1 target = 1
overlay_scene = ExtResource( 3 ) overlay_scene = ExtResource( 3 )
offset_pos = Vector3( -0.05, 0.02, 0.15 ) offset_pos = Vector3( -0.05, 0.02, 0.15 )
offset_rot = Vector3( 0, -90, -135 ) offset_rot = Vector3( -135, 90, 0 )
width_meters = 0.1 width_meters = 0.1
[node name="OverlayInteraction" parent="OverlayInstance Time" instance=ExtResource( 2 )] [node name="OverlayInteraction" parent="OverlayInstance Time" instance=ExtResource( 8 )]
[node name="XYZ Widget" type="Node" parent="."] [node name="XYZ Widget" type="Node" parent="."]
@ -29,20 +45,19 @@ width_meters = 0.1
target = 1 target = 1
overlay_scene = ExtResource( 6 ) overlay_scene = ExtResource( 6 )
offset_pos = Vector3( 0, 0, 0 ) offset_pos = Vector3( 0, 0, 0 )
offset_rot = Vector3( 0, -90, 0 ) offset_rot = Vector3( 0, 90, 0 )
[node name="OverlayInteraction" parent="XYZ Widget/YZ" instance=ExtResource( 8 )]
[node name="ZX" parent="XYZ Widget" instance=ExtResource( 1 )] [node name="ZX" parent="XYZ Widget" instance=ExtResource( 1 )]
target = 1 target = 1
overlay_scene = ExtResource( 5 ) overlay_scene = ExtResource( 5 )
offset_pos = Vector3( 0, 0, 0 ) offset_pos = Vector3( 0, 0, 0 )
offset_rot = Vector3( 90, 0, 0 ) offset_rot = Vector3( -90, 0, 0 )
[node name="OverlayInstance" parent="." instance=ExtResource( 1 )] [node name="OverlayInteraction" parent="XYZ Widget/ZX" instance=ExtResource( 8 )]
target = 3
offset_pos = Vector3( 0, 0, 0 )
offset_rot = Vector3( 45, 45, 0 )
[node name="OverlayInteraction" parent="OverlayInstance" instance=ExtResource( 2 )] [node name="Spatial" type="Spatial" parent="."]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."] [node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( 1 ) environment = SubResource( 1 )

View file

@ -4,10 +4,19 @@ Changes to the Godot OpenVR asset
Note, version numbers listed here are the version number assigned to the asset. Each time a new version is uploaded to the asset store we will increase the version number. Note, version numbers listed here are the version number assigned to the asset. Each time a new version is uploaded to the asset store we will increase the version number.
More frequent updates may be available on the source repository. More frequent updates may be available on the source repository.
1.1.0 - In progress
-------------------
- Build for Godot 3.2
- Added support for actions
- Added support for request play area
- Added skeleton support (finger tracking)
1.0.5 - 1 March 2019 1.0.5 - 1 March 2019
-------------------- --------------------
- Now using OpenVR 1.9.16 - Now using OpenVR 1.9.16
- Added support for overlays - Added support for overlays
- Proper asynchronious loading of controller meshes and textures
- Rewrite to using godot_cpp classes
1.0.4 - 27 March 2019 1.0.4 - 27 March 2019
--------------------- ---------------------

View file

@ -1,9 +0,0 @@
Contributors
============
This plugin has mostly been developed by [Bastiaan Olij](https://github.com/BastiaanOlij).
Special thanks to [Benedikt](https://github.com/beniwtv) for doing all the work on overlay support.
Other people who have helped out by submitting fixes, enhancements, etc are:
- [RMKD](https://github.com/RMKD)
- [Bruvzg](https://github.com/bruvzg)

View file

@ -0,0 +1,25 @@
tool
extends EditorPlugin
var export_plugin
func _enter_tree():
# Initialization of the plugin goes here
export_plugin = preload("res://addons/godot-openvr/OpenVRExportPlugin.gd")
if export_plugin:
# print("Loaded res://addons/godot-openvr/OpenVRExportPlugin.gd")
export_plugin = export_plugin.new()
if export_plugin:
# print("New res://addons/godot-openvr/OpenVRExportPlugin.gd")
add_export_plugin(export_plugin)
# else:
# print("Failed to instance res://addons/godot-openvr/OpenVRExportPlugin.gd")
#else:
# print("Failed to load res://addons/godot-openvr/OpenVRExportPlugin.gd")
func _exit_tree():
# Clean-up of the plugin goes here
if export_plugin:
remove_export_plugin(export_plugin)

View file

@ -0,0 +1,8 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://addons/godot-openvr/godot_openvr.gdnlib" type="GDNativeLibrary" id=1]
[resource]
resource_name = "OpenVRAction"
class_name = "OpenVRAction"
library = ExtResource( 1 )

View file

@ -0,0 +1,8 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://addons/godot-openvr/godot_openvr.gdnlib" type="GDNativeLibrary" id=1]
[resource]
resource_name = "OpenVRController"
class_name = "OpenVRController"
library = ExtResource( 1 )

View file

@ -0,0 +1,40 @@
tool
extends EditorExportPlugin
func _export_begin(features: PoolStringArray, is_debug: bool, path: String, flags: int ):
var dir = Directory.new()
# we just want the path
var export_to = path.get_base_dir() + "/actions/"
# now determine which action files to export
var export_from = ""
if dir.file_exists("res://actions/actions.json"):
export_from = "res://actions/"
elif dir.file_exists("res://addons/godot-openvr/actions/actions.json"):
export_from = "res://addons/godot-openvr/actions/"
else:
print("WARNING: Couldn't locate actions files to export")
return
# print("Exporting " + export_from +" to " + export_to)
if !dir.dir_exists(export_to):
dir.make_dir(export_to)
if dir.open(export_from) == OK:
dir.list_dir_begin(true, true)
var filename = dir.get_next()
while filename != "":
# print("Copy " + filename)
dir.copy(export_from + filename, export_to + filename)
filename = dir.get_next()
dir.list_dir_end()
#func _export_end():
# print("Export ended")
#func _export_file(path: String, type: String, features: PoolStringArray):
# print("Export " + path)

View file

@ -0,0 +1,8 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://addons/godot-openvr/godot_openvr.gdnlib" type="GDNativeLibrary" id=1]
[resource]
resource_name = "OpenVRHaptics"
class_name = "OpenVRHaptics"
library = ExtResource( 1 )

View file

@ -0,0 +1,8 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://addons/godot-openvr/godot_openvr.gdnlib" type="GDNativeLibrary" id=1]
[resource]
resource_name = "OpenVRPose"
class_name = "OpenVRPose"
library = ExtResource( 1 )

View file

@ -0,0 +1,10 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://addons/godot-openvr/godot_openvr.gdnlib" type="GDNativeLibrary" id=1]
[resource]
resource_name = "OpenVRSkeleton"
class_name = "OpenVRSkeleton"
library = ExtResource( 1 )
_sections_unfolded = [ "Resource" ]

View file

@ -1,40 +0,0 @@
# Godot OpenVR GDNative module
This module is provided as is, all files are contained within the addons/godot-openvr-asset folder
This module requires **Godot 3.1 or newer** to run, **Godot 3.2** is highly recommended.
The scenes subfolder contains a number of godot scenes that help you set up your project.
For basic functionality start with adding ovr_first_person.tcn to your project.
Also make sure that vsync is turned off in your project settings.
Source code for this module can be found here:
https://github.com/GodotVR/godot_openvr
Also note that we have a support asset containing a number of useful scenes to get you going building VR applications in Godot:
https://github.com/GodotVR/godot-vr-common
Documentation on using this asset can be found here:
https://github.com/GodotVR/godot-openvr-asset/wiki
HDR support
-----------
HDR support was added to OpenVR but requires the keep_3d_linear flag added to Godot 3.2. This will ensure rendering inside of the headset is correct. The preview on screen will look darker. You can solve this by using a separate viewport.
When using Godot 3.1 you need to either use the GLES2 renderer or turn HDR off on the viewport used to render to the HMD.
Licensing
---------
The Godot OpenVR module and the godot scenes in this add on are all supplied under an MIT License.
The dynamic libraries supplier by Valve fall under Valve's own license.
For more information about this license please visit https://github.com/ValveSoftware/openvr
About this repository
---------------------
This repository was created by and is maintained by Bastiaan Olij a.k.a. Mux213
You can follow me on twitter for regular updates here:
https://twitter.com/mux213
Videos about my work with Godot including tutorials on working with VR in Godot can by found on my youtube page:
https://www.youtube.com/BastiaanOlij

View file

@ -0,0 +1,107 @@
{
"action_set" : [
{
"name" : "/actions/godot",
"usage" : "leftright"
}
],
"actions" : [
{
"name" : "/actions/godot/in/trigger",
"requirement" : "mandatory",
"type" : "boolean"
},
{
"name" : "/actions/godot/in/analog_trigger",
"requirement" : "suggested",
"type" : "vector1"
},
{
"name" : "/actions/godot/in/grip",
"requirement" : "suggested",
"type" : "boolean"
},
{
"name" : "/actions/godot/in/analog_grip",
"requirement" : "suggested",
"type" : "vector1"
},
{
"name" : "/actions/godot/in/analog",
"requirement" : "suggested",
"type" : "vector2"
},
{
"name" : "/actions/godot/in/analog_click",
"requirement" : "suggested",
"type" : "boolean"
},
{
"name" : "/actions/godot/in/button_ax",
"requirement" : "optional",
"type" : "boolean"
},
{
"name" : "/actions/godot/in/button_by",
"requirement" : "optional",
"type" : "boolean"
},
{
"name" : "/actions/godot/out/haptic",
"requirement" : "optional",
"type" : "vibration"
},
{
"name": "/actions/godot/in/left_hand",
"type": "skeleton",
"skeleton": "/skeleton/hand/left"
},
{
"name": "/actions/godot/in/right_hand",
"type": "skeleton",
"skeleton": "/skeleton/hand/right"
} ],
"default_bindings" : [
{
"binding_url" : "bindings_index_controller.json",
"controller_type" : "knuckles"
},
{
"binding_url" : "bindings_oculus_touch.json",
"controller_type" : "oculus_touch"
},
{
"binding_url" : "bindings_vive_controller.json",
"controller_type" : "vive_controller"
},
{
"binding_url" : "bindings_holographic_controller.json",
"controller_type" : "holographic_controller"
},
{
"binding_url" : "bindings_generic.json",
"controller_type" : "generic"
},
{
"binding_url" : "bindings_gamepad.json",
"controller_type" : "gamepad"
}
],
"localization" : [
{
"/actions/godot" : "Godot actions",
"/actions/godot/in/analog" : "Analog Input",
"/actions/godot/in/analog_click" : "Analog Click",
"/actions/godot/in/analog_grip" : "Analog Grip",
"/actions/godot/in/analog_trigger" : "Analog Trigger",
"/actions/godot/in/button_ax" : "A/X Button",
"/actions/godot/in/button_by" : "B/Y Button",
"/actions/godot/in/grip" : "Grip",
"/actions/godot/in/trigger" : "Trigger",
"/actions/godot/out/haptic" : "Haptic Feedback",
"/actions/godot/in/left_hand" : "Left hand",
"/actions/godot/in/right_hand" : "Right hand",
"language_tag" : "en_US"
}
]
}

View file

@ -0,0 +1,112 @@
{
"action_manifest_version" : 0,
"alias_info" : {},
"bindings" : {
"/actions/godot" : {
"haptics" : [
{
"output" : "/actions/godot/out/haptic",
"path" : "/user/hand/left/output/haptic"
},
{
"output" : "/actions/godot/out/haptic",
"path" : "/user/hand/right/output/haptic"
}
],
"sources" : [
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/trigger"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/trigger"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/grip"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/grip"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/grip"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/grip"
},
{
"inputs" : {
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "trackpad",
"path" : "/user/hand/left/input/trackpad"
},
{
"inputs" : {
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "trackpad",
"path" : "/user/hand/right/input/trackpad"
},
{
"inputs" : {
"pull" : {
"output" : "/actions/godot/in/analog_trigger"
}
},
"mode" : "trigger",
"path" : "/user/gamepad/input/trigger_right"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/grip"
}
},
"mode" : "button",
"path" : "/user/gamepad/input/shoulder_right"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/analog_click"
},
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "joystick",
"path" : "/user/gamepad/input/joystick_right"
}
]
}
},
"category" : "steamvr_input",
"controller_type" : "gamepad",
"description" : "Bindings for the Godot OpenVR plugin for a generic controller",
"name" : "Godot bindings for Gamepad",
"options" : {
"returnBindingsWithRightHand" : true
},
"simulated_actions" : []
}

View file

@ -0,0 +1,75 @@
{
"bindings" : {
"/actions/godot" : {
"haptics" : [
{
"output" : "/actions/godot/out/haptic",
"path" : "/user/hand/left/output/haptic"
},
{
"output" : "/actions/godot/out/haptic",
"path" : "/user/hand/right/output/haptic"
}
],
"sources" : [
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/trigger"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/trigger"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/grip"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/grip"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/grip"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/grip"
},
{
"inputs" : {
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "trackpad",
"path" : "/user/hand/left/input/trackpad"
},
{
"inputs" : {
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "trackpad",
"path" : "/user/hand/right/input/trackpad"
}
]
}
},
"controller_type" : "generic",
"description" : "Bindings for the Godot OpenVR plugin for a generic controller",
"name" : "Godot bindings for a generic controller"
}

View file

@ -0,0 +1,132 @@
{
"action_manifest_version" : 0,
"alias_info" : {},
"bindings" : {
"/actions/godot" : {
"haptics" : [
{
"output" : "/actions/godot/out/haptic",
"path" : "/user/hand/left/output/haptic"
},
{
"output" : "/actions/godot/out/haptic",
"path" : "/user/hand/right/output/haptic"
}
],
"skeleton" : [
{
"output" : "/actions/godot/in/left_hand",
"path" : "/user/hand/left/input/skeleton/left"
},
{
"output" : "/actions/godot/in/right_hand",
"path" : "/user/hand/right/input/skeleton/right"
}
],
"sources" : [
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/grip"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/grip"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/grip"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/grip"
},
{
"inputs" : {
"pull" : {
"output" : "/actions/godot/in/analog_trigger"
}
},
"mode" : "trigger",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/trigger"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"pull" : {
"output" : "/actions/godot/in/analog_trigger"
}
},
"mode" : "trigger",
"path" : "/user/hand/right/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/trigger"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/trigger"
},
{
"inputs" : {
"value" : {
"output" : "/actions/godot/in/analog_grip"
}
},
"mode" : "scalar_constant",
"path" : "/user/hand/left/input/grip"
},
{
"inputs" : {
"value" : {
"output" : "/actions/godot/in/analog_grip"
}
},
"mode" : "scalar_constant",
"path" : "/user/hand/right/input/grip"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/analog_click"
},
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "joystick",
"path" : "/user/hand/left/input/joystick"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/analog_click"
},
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "joystick",
"path" : "/user/hand/right/input/joystick"
}
]
}
},
"category" : "steamvr_input",
"controller_type" : "holographic_controller",
"description" : "Bindings for the Godot OpenVR plugin for Windows Mixed Reality Controller",
"name" : "Godot bindings for Windows Mixed Reality Controller",
"options" : {},
"simulated_actions" : []
}

View file

@ -0,0 +1,144 @@
{
"action_manifest_version" : 0,
"alias_info" : {},
"bindings" : {
"/actions/godot" : {
"haptics" : [
{
"output" : "/actions/godot/out/haptic",
"path" : "/user/hand/left/output/haptic"
},
{
"output" : "/actions/godot/out/haptic",
"path" : "/user/hand/right/output/haptic"
}
],
"skeleton" : [
{
"output" : "/actions/godot/in/left_hand",
"path" : "/user/hand/left/input/skeleton/left"
},
{
"output" : "/actions/godot/in/right_hand",
"path" : "/user/hand/right/input/skeleton/right"
}
],
"sources" : [
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/trigger"
},
"pull" : {
"output" : "/actions/godot/in/analog_trigger"
}
},
"mode" : "trigger",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/trigger"
},
"pull" : {
"output" : "/actions/godot/in/analog_trigger"
}
},
"mode" : "trigger",
"path" : "/user/hand/right/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/analog_click"
},
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "joystick",
"path" : "/user/hand/left/input/thumbstick"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/analog_click"
},
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "joystick",
"path" : "/user/hand/right/input/thumbstick"
},
{
"inputs" : {
"pull" : {
"output" : "/actions/godot/in/analog_grip"
},
"touch" : {
"output" : "/actions/godot/in/grip"
}
},
"mode" : "trigger",
"path" : "/user/hand/left/input/grip"
},
{
"inputs" : {
"pull" : {
"output" : "/actions/godot/in/analog_grip"
},
"touch" : {
"output" : "/actions/godot/in/grip"
}
},
"mode" : "trigger",
"path" : "/user/hand/right/input/grip"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/button_by"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/b"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/button_by"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/b"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/button_ax"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/a"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/button_ax"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/a"
}
]
}
},
"category" : "steamvr_input",
"controller_type" : "knuckles",
"description" : "Bindings for the Godot OpenVR plugin for an index controller",
"name" : "Godot bindings for an index controller",
"options" : {},
"simulated_actions" : []
}

View file

@ -0,0 +1,144 @@
{
"action_manifest_version" : 0,
"alias_info" : {},
"bindings" : {
"/actions/godot" : {
"haptics" : [
{
"output" : "/actions/godot/out/haptic",
"path" : "/user/hand/left/output/haptic"
},
{
"output" : "/actions/godot/out/haptic",
"path" : "/user/hand/right/output/haptic"
}
],
"skeleton" : [
{
"output" : "/actions/godot/in/left_hand",
"path" : "/user/hand/left/input/skeleton/left"
},
{
"output" : "/actions/godot/in/right_hand",
"path" : "/user/hand/right/input/skeleton/right"
}
],
"sources" : [
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/analog_click"
},
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "joystick",
"path" : "/user/hand/left/input/joystick"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/button_ax"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/x"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/button_by"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/y"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/analog_click"
},
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "joystick",
"path" : "/user/hand/right/input/joystick"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/button_ax"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/a"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/button_by"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/b"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/trigger"
},
"pull" : {
"output" : "/actions/godot/in/analog_trigger"
}
},
"mode" : "trigger",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/trigger"
},
"pull" : {
"output" : "/actions/godot/in/analog_trigger"
}
},
"mode" : "trigger",
"path" : "/user/hand/right/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/grip"
},
"pull" : {
"output" : "/actions/godot/in/analog_grip"
}
},
"mode" : "trigger",
"path" : "/user/hand/left/input/grip"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/grip"
},
"pull" : {
"output" : "/actions/godot/in/analog_grip"
}
},
"mode" : "trigger",
"path" : "/user/hand/right/input/grip"
}
]
}
},
"category" : "steamvr_input",
"controller_type" : "oculus_touch",
"description" : "Bindings for the Godot OpenVR SDK plugin for the Oculus Touch",
"name" : "Godot bindings for Oculus Touch",
"options" : {},
"simulated_actions" : []
}

View file

@ -0,0 +1,120 @@
{
"action_manifest_version" : 0,
"alias_info" : {},
"bindings" : {
"/actions/godot" : {
"haptics" : [
{
"output" : "/actions/godot/out/haptic",
"path" : "/user/hand/left/output/haptic"
},
{
"output" : "/actions/godot/out/haptic",
"path" : "/user/hand/right/output/haptic"
}
],
"skeleton" : [
{
"output" : "/actions/godot/in/left_hand",
"path" : "/user/hand/left/input/skeleton/left"
},
{
"output" : "/actions/godot/in/right_hand",
"path" : "/user/hand/right/input/skeleton/right"
}
],
"sources" : [
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/analog_click"
},
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "trackpad",
"path" : "/user/hand/left/input/trackpad"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/analog_click"
},
"position" : {
"output" : "/actions/godot/in/analog"
}
},
"mode" : "trackpad",
"path" : "/user/hand/right/input/trackpad"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/grip"
}
},
"mode" : "button",
"path" : "/user/hand/left/input/grip"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/grip"
}
},
"mode" : "button",
"path" : "/user/hand/right/input/grip"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/trigger"
},
"pull" : {
"output" : "/actions/godot/in/analog_trigger"
}
},
"mode" : "trigger",
"path" : "/user/hand/left/input/trigger"
},
{
"inputs" : {
"click" : {
"output" : "/actions/godot/in/trigger"
},
"pull" : {
"output" : "/actions/godot/in/analog_trigger"
}
},
"mode" : "trigger",
"path" : "/user/hand/right/input/trigger"
},
{
"inputs" : {
"value" : {
"output" : "/actions/godot/in/analog_grip"
}
},
"mode" : "scalar_constant",
"path" : "/user/hand/left/input/grip"
},
{
"inputs" : {
"value" : {
"output" : "/actions/godot/in/analog_grip"
}
},
"mode" : "scalar_constant",
"path" : "/user/hand/right/input/grip"
}
]
}
},
"category" : "steamvr_input",
"controller_type" : "vive_controller",
"description" : "Bindings for the Godot OpenVR SDK plugin for the Vive controller",
"name" : "Godot bindings for Vive Controller",
"options" : {},
"simulated_actions" : []
}

View file

@ -1 +0,0 @@
Versions/Current/Headers

View file

@ -0,0 +1 @@
Versions/Current/Headers

View file

@ -1 +0,0 @@
Versions/Current/OpenVR

View file

@ -0,0 +1 @@
Versions/Current/OpenVR

View file

@ -1 +0,0 @@
Versions/Current/Resources

View file

@ -0,0 +1 @@
Versions/Current/Resources

View file

BIN
ovr-utils/addons/godot-openvr/bin/x11/libgodot_openvr.so Normal file → Executable file

Binary file not shown.

View file

@ -0,0 +1,5 @@
The resources here are taken from: `Steam\steamapps\common\SteamVR\resources\rendermodels\vr_glove\`
To save space in the repository only the slim models are included while the texture maps have been taken from the full versions.
See `../scenes/ovr_left_hand.tscn` and `../scenes/ovr_right_hand.tscn` for implementation details

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 MiB

View file

@ -0,0 +1,36 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/hands_albedo.png-149a10baba7906560a9f9eab8fadf1d8.s3tc.stex"
path.etc2="res://.import/hands_albedo.png-149a10baba7906560a9f9eab8fadf1d8.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}
[deps]
source_file="res://addons/godot-openvr/meshes/hands_albedo.png"
dest_files=[ "res://.import/hands_albedo.png-149a10baba7906560a9f9eab8fadf1d8.s3tc.stex", "res://.import/hands_albedo.png-149a10baba7906560a9f9eab8fadf1d8.etc2.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=1
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 MiB

View file

@ -0,0 +1,36 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/hands_normal.png-eab7a86e959f13e1294e8f67904a8873.s3tc.stex"
path.etc2="res://.import/hands_normal.png-eab7a86e959f13e1294e8f67904a8873.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}
[deps]
source_file="res://addons/godot-openvr/meshes/hands_normal.png"
dest_files=[ "res://.import/hands_normal.png-eab7a86e959f13e1294e8f67904a8873.s3tc.stex", "res://.import/hands_normal.png-eab7a86e959f13e1294e8f67904a8873.etc2.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=1
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
[plugin]
name="Godot OpenVR"
description="Godot OpenVR plugin"
author="Bastiaan Olij and contributors"
version="1.1.0"
script="EditorPlugin.gd"

View file

@ -1,112 +1,61 @@
[gd_scene load_steps=5 format=2] [gd_scene load_steps=5 format=2]
[sub_resource type="PlaneMesh" id=1] [sub_resource type="PlaneMesh" id=1]
size = Vector2( 0.3, 0.15 ) size = Vector2( 0.3, 0.15 )
subdivide_width = 10 subdivide_width = 10
subdivide_depth = 10 subdivide_depth = 10
[sub_resource type="Shader" id=2] [sub_resource type="Shader" id=2]
code = "shader_type spatial; code = "shader_type spatial;
render_mode unshaded; render_mode unshaded;
uniform sampler2D viewport_texture : hint_albedo; uniform sampler2D viewport_texture : hint_albedo;
void vertex() { void vertex() {
VERTEX.y = 1.0 - cos(VERTEX.x + 0.3) * 0.5 - cos(VERTEX.z + 0.15) * 0.5; VERTEX.y = 1.0 - cos(VERTEX.x) * 0.5 - cos(VERTEX.z) * 0.5;
} }
void fragment() { void fragment() {
vec4 col = texture(viewport_texture, vec2(1.0 - UV.x, UV.y)); vec4 col = texture(viewport_texture, vec2(1.0 - UV.x, UV.y));
ALBEDO = col.rgb; ALBEDO = col.rgb;
ALPHA = col.a; ALPHA = col.a;
}" }
"
[sub_resource type="ShaderMaterial" id=3] [sub_resource type="ShaderMaterial" id=3]
render_priority = 0
shader = SubResource( 2 ) shader = SubResource( 2 )
_sections_unfolded = [ "Resource", "shader_param" ]
[sub_resource type="GDScript" id=4] [sub_resource type="GDScript" id=4]
script/source = "extends MeshInstance script/source = "extends MeshInstance
func _ready(): func _ready():
get_surface_material(0).set_shader_param(\"viewport_texture\", $Viewport.get_texture()) get_surface_material(0).set_shader_param(\"viewport_texture\", $Viewport.get_texture())
func _process(delta): func _process(delta):
$Viewport/World/Label.text = str(Engine.get_frames_per_second()) + \" FPS\"" $Viewport/Label.text = str(Engine.get_frames_per_second()) + \" FPS\"
"
[node name="FPS" type="MeshInstance" index="0"] [node name="FPS" type="MeshInstance"]
transform = Transform( 1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0 )
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0 )
layers = 1
material_override = null
cast_shadow = 1
extra_cull_margin = 0.0
use_in_baked_light = false
lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
mesh = SubResource( 1 ) mesh = SubResource( 1 )
skeleton = NodePath("..")
material/0 = SubResource( 3 ) material/0 = SubResource( 3 )
script = SubResource( 4 ) script = SubResource( 4 )
_sections_unfolded = [ "Transform", "material" ]
[node name="Viewport" type="Viewport" parent="." index="0"] [node name="Viewport" type="Viewport" parent="."]
arvr = false
size = Vector2( 200, 100 ) size = Vector2( 200, 100 )
own_world = false
world = null
transparent_bg = true transparent_bg = true
msaa = 0
hdr = false hdr = false
disable_3d = false
usage = 0 usage = 0
debug_draw = 0
render_target_v_flip = false
render_target_clear_mode = 0
render_target_update_mode = 3 render_target_update_mode = 3
audio_listener_enable_2d = false
audio_listener_enable_3d = false
physics_object_picking = false
gui_disable_input = false
gui_snap_controls_to_pixels = true
shadow_atlas_size = 0
shadow_atlas_quad_0 = 2
shadow_atlas_quad_1 = 2
shadow_atlas_quad_2 = 3
shadow_atlas_quad_3 = 4
_sections_unfolded = [ "Render Target", "Rendering" ]
[node name="World" type="Node2D" parent="Viewport" index="0"] [node name="Label" type="Label" parent="Viewport"]
anchor_right = 1.0
_sections_unfolded = [ "Transform", "Z" ] anchor_bottom = 1.0
[node name="Label" type="Label" parent="Viewport/World" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 200.0
margin_bottom = 100.0
rect_scale = Vector2( 3, 3 ) rect_scale = Vector2( 3, 3 )
rect_pivot_offset = Vector2( 0, 0 )
mouse_filter = 2
size_flags_horizontal = 1
size_flags_vertical = 4
custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 ) custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
text = "FPS" text = "FPS"
percent_visible = 1.0 __meta__ = {
lines_skipped = 0 "_edit_use_anchors_": false
max_lines_visible = -1 }
_sections_unfolded = [ "Anchor", "Grow Direction", "Margin", "Material", "Rect", "Visibility", "custom_colors" ]

View file

@ -6,59 +6,27 @@ export var show_controller_mesh = true setget set_show_controller_mesh, get_show
func set_show_controller_mesh(p_show): func set_show_controller_mesh(p_show):
show_controller_mesh = p_show show_controller_mesh = p_show
if $Controller_mesh: if $OVRRenderModel:
$Controller_mesh.visible = p_show $OVRRenderModel.visible = p_show
func get_show_controller_mesh(): func get_show_controller_mesh():
return show_controller_mesh return show_controller_mesh
var ovr_render_model
var components = Array()
var ws = 0
func _ready(): func _ready():
# instance our render model object
ovr_render_model = preload("res://addons/godot-openvr/OpenVRRenderModel.gdns").new()
# set our starting vaule # set our starting vaule
$Controller_mesh.visible = show_controller_mesh $OVRRenderModel.visible = show_controller_mesh
# hide to begin with # hide to begin with
visible = false visible = false
func apply_world_scale():
var new_ws = ARVRServer.world_scale
if (ws != new_ws):
ws = new_ws
$Controller_mesh.scale = Vector3(ws, ws, ws)
func load_controller_mesh(controller_name):
if ovr_render_model.load_model(controller_name.substr(0, controller_name.length()-2)):
return ovr_render_model
if ovr_render_model.load_model("generic_controller"):
return ovr_render_model
return Mesh.new()
func _process(delta): func _process(delta):
if !get_is_active(): if !get_is_active():
visible = false visible = false
return return
# always set our world scale, user may end up changing this
apply_world_scale()
if visible: if visible:
return return
# became active? lets handle it...
var controller_name = get_controller_name()
print("Controller " + controller_name + " became active")
# attempt to load a mesh for this
$Controller_mesh.mesh = load_controller_mesh(controller_name)
# make it visible # make it visible
visible = true visible = true
emit_signal("controller_activated", self) emit_signal("controller_activated", self)

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=2 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://addons/godot-openvr/scenes/ovr_controller.gd" type="Script" id=1] [ext_resource path="res://addons/godot-openvr/scenes/ovr_controller.gd" type="Script" id=1]
[ext_resource path="res://addons/godot-openvr/scenes/ovr_render_model.tscn" type="PackedScene" id=2]
[node name="OVRController" type="ARVRController"] [node name="OVRController" type="ARVRController"]
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="Controller_mesh" type="MeshInstance" parent="."] [node name="OVRRenderModel" parent="." instance=ExtResource( 2 )]

View file

@ -1,14 +1,10 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=5 format=2]
[ext_resource path="res://addons/vr-common/misc/VR_Common_Shader_Cache.tscn" type="PackedScene" id=1] [ext_resource path="res://addons/godot-openvr/scenes/ovr_shader_cache.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/godot-openvr/scenes/ovr_controller.tscn" type="PackedScene" id=2] [ext_resource path="res://addons/godot-openvr/scenes/ovr_controller.tscn" type="PackedScene" id=2]
[ext_resource path="res://addons/godot-openvr/scenes/ovr_main.gd" type="Script" id=3]
[sub_resource type="PlaneMesh" id=1] [sub_resource type="GDScript" id=1]
size = Vector2( 0.001, 0.001 )
[sub_resource type="SpatialMaterial" id=2]
[sub_resource type="GDScript" id=3]
script/source = "extends Spatial script/source = "extends Spatial
func _physics_process(delta): func _physics_process(delta):
@ -28,6 +24,7 @@ func _physics_process(delta):
pass" pass"
[node name="OVRFirstPerson" type="ARVROrigin"] [node name="OVRFirstPerson" type="ARVROrigin"]
script = ExtResource( 3 )
[node name="ARVRCamera" type="ARVRCamera" parent="."] [node name="ARVRCamera" type="ARVRCamera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.85, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.85, 0 )
@ -35,16 +32,11 @@ fov = 65.0
near = 0.01 near = 0.01
far = 1000.01 far = 1000.01
[node name="shader_cache" parent="ARVRCamera" instance=ExtResource( 1 )] [node name="ovr_shader_cache" parent="ARVRCamera" instance=ExtResource( 1 )]
[node name="Controller" type="MeshInstance" parent="ARVRCamera/shader_cache"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
[node name="HUD_Anchor" type="Spatial" parent="."] [node name="HUD_Anchor" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.85, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.85, 0 )
script = SubResource( 3 ) script = SubResource( 1 )
[node name="Left_Hand" parent="." instance=ExtResource( 2 )] [node name="Left_Hand" parent="." instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 1.25, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 1.25, 0 )
@ -52,4 +44,3 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 1.25, 0 )
[node name="Right_Hand" parent="." instance=ExtResource( 2 )] [node name="Right_Hand" parent="." instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 1.25, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 1.25, 0 )
controller_id = 2 controller_id = 2

View file

@ -0,0 +1,42 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://addons/godot-openvr/meshes/vr_glove_left_model_slim.glb" type="PackedScene" id=1]
[ext_resource path="res://addons/godot-openvr/meshes/models_hands_vr_glove_vmat.material" type="Material" id=2]
[ext_resource path="res://addons/godot-openvr/OpenVRPose.gdns" type="Script" id=3]
[ext_resource path="res://addons/godot-openvr/OpenVRSkeleton.gdns" type="Script" id=4]
[node name="ovr_left_hand" instance=ExtResource( 1 )]
script = ExtResource( 3 )
action = "/actions/godot/in/left_hand"
[node name="Skeleton" parent="RootNode" index="0"]
bones/5/bound_children = [ NodePath("Thumb") ]
bones/10/bound_children = [ NodePath("Index") ]
bones/15/bound_children = [ NodePath("Middle") ]
bones/20/bound_children = [ NodePath("Ring") ]
bones/25/bound_children = [ NodePath("Pinky") ]
script = ExtResource( 4 )
action = "/actions/godot/in/left_hand"
[node name="vr_glove_left_slim" parent="RootNode/Skeleton" index="0"]
material/0 = ExtResource( 2 )
[node name="Thumb" type="BoneAttachment" parent="RootNode/Skeleton" index="1"]
transform = Transform( -0.347509, 0.0284256, 0.937246, -0.13095, -0.991217, -0.0184906, 0.928488, -0.129158, 0.348178, -0.0498674, 0.056092, 0.112777 )
bone_name = "finger_thumb_l_end"
[node name="Index" type="BoneAttachment" parent="RootNode/Skeleton" index="2"]
transform = Transform( -0.717079, -0.669965, 0.19221, -0.076153, -0.19881, -0.977075, 0.69282, -0.715277, 0.0915429, -0.0345977, 0.0355404, 0.164767 )
bone_name = "finger_index_l_end"
[node name="Middle" type="BoneAttachment" parent="RootNode/Skeleton" index="3"]
transform = Transform( -0.755126, -0.650532, 0.0812012, -0.0513261, -0.064817, -0.996576, 0.653568, -0.756708, 0.0155557, -0.0321126, 0.00654218, 0.171613 )
bone_name = "finger_middle_l_end"
[node name="Ring" type="BoneAttachment" parent="RootNode/Skeleton" index="4"]
transform = Transform( -0.749612, -0.661178, -0.0304372, -0.0961052, 0.154228, -0.98335, 0.654864, -0.734206, -0.179154, -0.0346831, -0.0253934, 0.156924 )
bone_name = "finger_ring_l_end"
[node name="Pinky" type="BoneAttachment" parent="RootNode/Skeleton" index="5"]
transform = Transform( -0.615435, -0.749373, -0.244295, -0.0354297, 0.335934, -0.941219, 0.787391, -0.570604, -0.233296, -0.0270969, -0.0462902, 0.133467 )
bone_name = "finger_pinky_l_end"

View file

@ -0,0 +1,68 @@
extends ARVROrigin
# Add this script to your ARVROrigin node and it will initialise OpenVR for you automatically.
# Our plugin will now use the first actions.json found in the following locations
# 1) in the actions folder alongside the executable
# 2) in the actions folder within your project folder (i.e. "res://actions/actions.json")
# 3) in the actions folder within the plugin (i.e. "res://addons/godot-openvr/actions/actions.json")
# OpenVR can't read actions files within the exported datapack.
# The plugin always registers atleast one action set.
# If you have renamed this action set you can specify the name here
export (String) var default_action_set = "/actions/godot"
# If we render to a custom viewport give our node path here.
export (NodePath) var viewport = null
# Convenience setting for setting physics update rate to a multiple of our HMDs frame rate (set to 0 to ignore)
export var physics_factor = 2
var arvr_interface : ARVRInterface = null
var openvr_config = null
func get_openvr_config():
return openvr_config
func _ready():
# Load our config before we initialise
openvr_config = preload("res://addons/godot-openvr/OpenVRConfig.gdns");
if openvr_config:
print("Setup configuration")
openvr_config = openvr_config.new()
openvr_config.default_action_set = default_action_set
# Find the interface and initialise
arvr_interface = ARVRServer.find_interface("OpenVR")
if arvr_interface and arvr_interface.initialize():
# We can't query our HMDs refresh rate just yet so we hardcode this to 90
var refresh_rate = 90
# check our viewport
var vp : Viewport = null
if viewport:
vp = get_node(viewport)
if vp:
# We copy this, while the ARVRServer will resize the size of the viewport automatically
# it can't feed it back into the node.
vp.size = arvr_interface.get_render_targetsize()
# No viewport? get our main viewport
if !vp:
vp = get_viewport()
# switch to ARVR mode
vp.arvr = true
# keep linear color space, not needed and thus ignored with the GLES2 renderer
vp.keep_3d_linear = true
# make sure vsync is disabled or we'll be limited to 60fps
OS.vsync_enabled = false
if physics_factor > 0:
# Set our physics to a multiple of our refresh rate to get in sync with our rendering
Engine.iterations_per_second = refresh_rate * physics_factor

View file

@ -0,0 +1,53 @@
extends MeshInstance
var ovr_render_model
var ws = 0
var controller_is_loaded = false
func apply_world_scale():
var new_ws = ARVRServer.world_scale
if (ws != new_ws):
ws = new_ws
scale = Vector3(ws, ws, ws)
func _load_controller_mesh(controller_name):
if ovr_render_model.load_model(controller_name.substr(0, controller_name.length()-2)):
return ovr_render_model
if ovr_render_model.load_model("generic_controller"):
return ovr_render_model
return Mesh.new()
# Called when the node enters the scene tree for the first time.
func _ready():
# instance our render model object
ovr_render_model = preload("res://addons/godot-openvr/OpenVRRenderModel.gdns").new()
# we haven't loaded it
controller_is_loaded = false
func _process(delta):
var controller = get_parent();
if !controller is ARVRController:
return
if !controller.get_is_active():
if controller_is_loaded:
mesh = Mesh.new()
controller_is_loaded = false
return
# always set our world scale, user may end up changing this
apply_world_scale()
if controller_is_loaded:
return
# became active? lets handle it...
var controller_name = controller.get_controller_name()
print("Controller " + controller_name + " became active")
# attempt to load a mesh for this
mesh = _load_controller_mesh(controller_name)
controller_is_loaded = true

View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/godot-openvr/scenes/ovr_render_model.gd" type="Script" id=1]
[node name="OVRRenderModel" type="MeshInstance"]
script = ExtResource( 1 )

View file

@ -0,0 +1,42 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://addons/godot-openvr/meshes/vr_glove_right_model_slim.glb" type="PackedScene" id=1]
[ext_resource path="res://addons/godot-openvr/meshes/models_hands_vr_glove_vmat.material" type="Material" id=2]
[ext_resource path="res://addons/godot-openvr/OpenVRPose.gdns" type="Script" id=3]
[ext_resource path="res://addons/godot-openvr/OpenVRSkeleton.gdns" type="Script" id=4]
[node name="ovr_right_hand" instance=ExtResource( 1 )]
script = ExtResource( 3 )
action = "/actions/godot/in/right_hand"
[node name="Skeleton" parent="RootNode" index="0"]
bones/5/bound_children = [ NodePath("Thumb") ]
bones/10/bound_children = [ NodePath("Index") ]
bones/15/bound_children = [ NodePath("Middle") ]
bones/20/bound_children = [ NodePath("Ring") ]
bones/25/bound_children = [ NodePath("Pinky") ]
script = ExtResource( 4 )
action = "/actions/godot/in/right_hand"
[node name="vr_glove_right_slim" parent="RootNode/Skeleton" index="0"]
material/0 = ExtResource( 2 )
[node name="Thumb" type="BoneAttachment" parent="RootNode/Skeleton" index="1"]
transform = Transform( -0.347509, 0.0284256, 0.937246, 0.130949, 0.991217, 0.0184906, -0.928488, 0.129158, -0.348179, 0.0498674, 0.0560921, 0.112777 )
bone_name = "finger_thumb_r_end"
[node name="Index" type="BoneAttachment" parent="RootNode/Skeleton" index="2"]
transform = Transform( -0.717079, -0.669965, 0.19221, 0.0761528, 0.19881, 0.977075, -0.69282, 0.715277, -0.0915429, 0.0345977, 0.0355405, 0.164767 )
bone_name = "finger_index_r_end"
[node name="Middle" type="BoneAttachment" parent="RootNode/Skeleton" index="3"]
transform = Transform( -0.755126, -0.650532, 0.0812013, 0.0513261, 0.064817, 0.996577, -0.653568, 0.756708, -0.0155557, 0.0321126, 0.00654219, 0.171613 )
bone_name = "finger_middle_r_end"
[node name="Ring" type="BoneAttachment" parent="RootNode/Skeleton" index="4"]
transform = Transform( -0.749612, -0.661178, -0.0304372, 0.0961052, -0.154228, 0.98335, -0.654864, 0.734206, 0.179154, 0.0346831, -0.0253934, 0.156924 )
bone_name = "finger_ring_r_end"
[node name="Pinky" type="BoneAttachment" parent="RootNode/Skeleton" index="5"]
transform = Transform( -0.615435, -0.749373, -0.244295, 0.0354297, -0.335934, 0.941219, -0.787391, 0.570604, 0.233296, 0.0270969, -0.0462902, 0.133467 )
bone_name = "finger_pinky_r_end"

View file

@ -0,0 +1,10 @@
extends Spatial
var countdown = 2
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
countdown = countdown - 1
if countdown == 0:
visible = false
set_process(false)

View file

@ -0,0 +1,16 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://addons/godot-openvr/scenes/ovr_shader_cache.gd" type="Script" id=1]
[sub_resource type="PlaneMesh" id=1]
size = Vector2( 0.001, 0.001 )
[sub_resource type="SpatialMaterial" id=2]
[node name="ovr_shader_cache" type="Spatial"]
script = ExtResource( 1 )
[node name="Controller" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )

View file

@ -25,8 +25,4 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
theme = ExtResource( 5 ) theme = ExtResource( 5 )
[node name="Offset" type="Spatial" parent="."] [node name="Offset" type="RemoteTransform" parent="."]
[node name="OffsetInv" type="RemoteTransform" parent="."]
use_global_coordinates = false
update_scale = false

View file

@ -22,7 +22,7 @@ func _ready() -> void:
get_parent().connect("width_changed", self, "_on_width_changed") get_parent().connect("width_changed", self, "_on_width_changed")
_on_width_changed(get_parent().width_meters) _on_width_changed(get_parent().width_meters)
get_node("../OffsetInv").remote_path = $Offset.get_path() get_node("../Offset").remote_path = $Offset.get_path()
$Offset.remote_path = $LeftHand/Area.get_path() $Offset.remote_path = $LeftHand/Area.get_path()

View file

@ -1,10 +1,13 @@
extends Node extends Node
var ovr_interface: ARVRInterface var ovr_interface: ARVRInterface
var ovr_config := preload("res://addons/godot-openvr/OpenVRConfig.gdns").new()
var left_id = 0
var right_id = 0
func _init() -> void: func _init() -> void:
var ovr_config = preload("res://addons/godot-openvr/OpenVRConfig.gdns").new() ovr_config = preload("res://addons/godot-openvr/OpenVRConfig.gdns").new()
ovr_config.set_application_type(2) # Set to OVERLAY MODE = 2, NORMAL MODE = 1 ovr_config.set_application_type(2) # Set to OVERLAY MODE = 2, NORMAL MODE = 1
ovr_config.set_tracking_universe(1) # Set to SEATED MODE = 0, STANDING MODE = 1, RAW MODE = 2 ovr_config.set_tracking_universe(1) # Set to SEATED MODE = 0, STANDING MODE = 1, RAW MODE = 2
@ -15,7 +18,20 @@ func _init() -> void:
func _ready() -> void: func _ready() -> void:
ARVRServer.connect("tracker_added", self, "_tracker_changed")
ARVRServer.connect("tracker_removed", self, "_tracker_changed")
update_hand_ids()
func _tracker_changed(tracker_name: String, type: int, id: int):
update_hand_ids()
func update_hand_ids():
for i in ARVRServer.get_tracker_count(): for i in ARVRServer.get_tracker_count():
var tracker = ARVRServer.get_tracker(i) var tracker = ARVRServer.get_tracker(i)
print(tracker.get_name(), ": hand ", tracker.get_hand()) print(tracker.get_name(), ": hand ", tracker.get_hand())
var tracking_id = tracker.get_name().split("_")[-1]
if tracker.get_hand() == 1:
left_id = tracking_id
elif tracker.get_hand() == 2:
right_id = tracking_id

View file

@ -48,12 +48,7 @@ func update_tracker_id() -> void:
func update_offset() -> void: func update_offset() -> void:
$Offset.translation = offset_pos $Offset.translation = offset_pos
$OffsetInv.translation = offset_pos
$Offset.rotation_degrees = offset_rot $Offset.rotation_degrees = offset_rot
$OffsetInv.rotation_degrees = offset_rot
$OffsetInv.rotation_degrees.x *= -1
$OffsetInv.rotation_degrees.y *= -1
$OffsetInv.rotation_degrees.z *= -1
# print(_tracker_id) # print(_tracker_id)
match target: match target:
@ -66,7 +61,7 @@ func update_offset() -> void:
func _tracker_changed(tracker_name: String, type: int, id: int): func _tracker_changed(tracker_name: String, type: int, id: int):
print("tracker changed: ", tracker_name) # print("tracker changed: ", tracker_name)
update_tracker_id() update_tracker_id()
update_offset() update_offset()

View file

@ -0,0 +1,50 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://overlays/battery.gd" type="Script" id=1]
[ext_resource path="res://fonts/OpenSans-Regular.ttf" type="DynamicFontData" id=2]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0, 0, 0, 0.705882 )
expand_margin_left = 8.0
expand_margin_right = 8.0
expand_margin_top = 8.0
expand_margin_bottom = 8.0
[sub_resource type="DynamicFont" id=2]
size = 128
font_data = ExtResource( 2 )
[node name="Overlay" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ColorRect" type="PanelContainer" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -673.0
margin_top = -87.5
margin_right = 673.0
margin_bottom = 87.5
size_flags_horizontal = 0
custom_styles/panel = SubResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="ColorRect"]
margin_right = 1346.0
margin_bottom = 175.0
custom_fonts/font = SubResource( 2 )
text = "Left: 100% Right: 100%"
align = 1
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

View file

@ -0,0 +1,26 @@
extends Label
var _delay = 0
func _ready() -> void:
pass
func _process(delta: float) -> void:
_delay += delta
if _delay > 1:
update_text()
_delay = 0
func update_text():
var l = "NaN"
var r = "NaN"
if OverlayInit.left_id:
l = OverlayInit.ovr_config.get_device_battery_percentage(OverlayInit.left_id)*100
l = str(int(l))
if OverlayInit.right_id:
r = OverlayInit.ovr_config.get_device_battery_percentage(OverlayInit.right_id)*100
r = str(int(r))
if OverlayInit.ovr_config.is_device_charging(OverlayInit.right_id):
r += "+"
text = "Left: " + l + "% Right: " + r + "%"