mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-22 23:50:25 +01:00
touch triggers work but hard-wired to left hand
This commit is contained in:
parent
b54df3f689
commit
0407fd297a
11 changed files with 157 additions and 15 deletions
|
@ -1,7 +1,6 @@
|
||||||
[gd_scene load_steps=7 format=2]
|
[gd_scene load_steps=6 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://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]
|
||||||
|
@ -10,18 +9,13 @@
|
||||||
[node name="Overlays" type="Node"]
|
[node name="Overlays" type="Node"]
|
||||||
script = ExtResource( 4 )
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
[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( 0, -90, -135 )
|
|
||||||
|
|
||||||
[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( 0, -90, -135 )
|
||||||
width_meters = 0.1
|
width_meters = 0.1
|
||||||
|
fallback_to_hmd = true
|
||||||
|
|
||||||
[node name="XYZ Widget" type="Node" parent="."]
|
[node name="XYZ Widget" type="Node" parent="."]
|
||||||
|
|
||||||
|
@ -36,3 +30,7 @@ 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 )]
|
||||||
|
target = 3
|
||||||
|
offset_pos = Vector3( 0.397, 0.295, -0.772 )
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
[gd_scene load_steps=3 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://addons/openvr_overlay/overlay_instance.gd" type="Script" id=1]
|
[ext_resource path="res://addons/openvr_overlay/overlay_instance.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://addons/openvr_overlay/interaction/OverlayInteraction.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://addons/godot-openvr/OpenVROverlay.gdns" type="Script" id=3]
|
[ext_resource path="res://addons/godot-openvr/OpenVROverlay.gdns" type="Script" id=3]
|
||||||
|
[ext_resource path="res://addons/openvr_overlay/styles/normal.theme" type="Theme" id=5]
|
||||||
|
|
||||||
[node name="OverlayInstance" type="Node"]
|
[node name="OverlayInstance" type="Node"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
@ -12,6 +14,9 @@ transparent_bg = true
|
||||||
handle_input_locally = false
|
handle_input_locally = false
|
||||||
msaa = 3
|
msaa = 3
|
||||||
hdr = false
|
hdr = false
|
||||||
|
disable_3d = true
|
||||||
|
keep_3d_linear = true
|
||||||
|
usage = 0
|
||||||
render_target_update_mode = 3
|
render_target_update_mode = 3
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
overlay_width_in_meters = 0.4
|
overlay_width_in_meters = 0.4
|
||||||
|
@ -19,5 +24,11 @@ overlay_width_in_meters = 0.4
|
||||||
[node name="PanelContainer" type="PanelContainer" parent="OverlayViewport"]
|
[node name="PanelContainer" type="PanelContainer" parent="OverlayViewport"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
theme = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="Offset" type="Spatial" parent="."]
|
[node name="Offset" type="RemoteTransform" parent="."]
|
||||||
|
remote_path = NodePath("../ARVROrigin/LeftHand/Area")
|
||||||
|
use_global_coordinates = false
|
||||||
|
update_scale = false
|
||||||
|
|
||||||
|
[node name="OverlayInteraction" parent="." instance=ExtResource( 2 )]
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://addons/openvr_overlay/interaction/overlay_interaction.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://addons/openvr_overlay/styles/active.theme" type="Theme" id=2]
|
||||||
|
[ext_resource path="res://addons/openvr_overlay/styles/normal.theme" type="Theme" id=3]
|
||||||
|
[ext_resource path="res://addons/openvr_overlay/styles/touching.theme" type="Theme" id=4]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape" id=1]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
extents = Vector3( 0.2, 0.2, 0.01 )
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape" id=2]
|
||||||
|
radius = 0.03
|
||||||
|
|
||||||
|
[node name="OverlayInteraction" type="ARVROrigin"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
active_theme = ExtResource( 2 )
|
||||||
|
normal_theme = ExtResource( 3 )
|
||||||
|
touching_theme = ExtResource( 4 )
|
||||||
|
|
||||||
|
[node name="LeftHand" type="ARVRController" parent="."]
|
||||||
|
|
||||||
|
[node name="Area" type="Area" parent="LeftHand"]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="LeftHand/Area"]
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="RightHand" type="ARVRController" parent="."]
|
||||||
|
controller_id = 2
|
||||||
|
|
||||||
|
[node name="StaticBody" type="StaticBody" parent="RightHand"]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="RightHand/StaticBody"]
|
||||||
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="ARVRCamera" type="ARVRCamera" parent="."]
|
||||||
|
|
||||||
|
[node name="Offset" type="RemoteTransform" parent="."]
|
||||||
|
update_scale = false
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="LeftHand/Area" to="." method="_on_Area_body_entered"]
|
||||||
|
[connection signal="body_exited" from="LeftHand/Area" to="." method="_on_Area_body_exited"]
|
|
@ -0,0 +1,82 @@
|
||||||
|
extends ARVROrigin
|
||||||
|
|
||||||
|
signal touch_on # a controller entered
|
||||||
|
signal touch_off # a controller exited
|
||||||
|
signal trigger_on # trigger pushed while touching
|
||||||
|
signal trigger_off # trigger released
|
||||||
|
|
||||||
|
export var active_theme: Theme
|
||||||
|
export var normal_theme: Theme
|
||||||
|
export var touching_theme: Theme
|
||||||
|
|
||||||
|
var active_controllers = []
|
||||||
|
|
||||||
|
var _touch_state = false setget ,get_touch_state
|
||||||
|
var _trigger_state = false setget ,get_trigger_state
|
||||||
|
var _active_controller: ARVRController = null setget ,get_active_controller
|
||||||
|
|
||||||
|
onready var panel = get_node("../OverlayViewport/PanelContainer")
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
get_parent().connect("width_changed", self, "_on_width_changed")
|
||||||
|
_on_width_changed(get_parent().width_meters)
|
||||||
|
|
||||||
|
get_node("../Offset").remote_path = $Offset.get_path()
|
||||||
|
$Offset.remote_path = "../LeftHand/Area"
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if _touch_state:
|
||||||
|
if not _trigger_state:
|
||||||
|
_get_trigger_down()
|
||||||
|
else:
|
||||||
|
_get_trigger_up()
|
||||||
|
|
||||||
|
|
||||||
|
func _get_trigger_down():
|
||||||
|
for c in active_controllers:
|
||||||
|
if c.is_button_pressed(JOY_VR_TRIGGER):
|
||||||
|
_active_controller = c
|
||||||
|
emit_signal("trigger_on")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
func _get_trigger_up():
|
||||||
|
if not _active_controller.is_button_pressed(JOY_VR_TRIGGER):
|
||||||
|
_active_controller = null
|
||||||
|
emit_signal("trigger_off")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Area_body_entered(body: Node) -> void:
|
||||||
|
if body.get_parent().get_parent() != self:
|
||||||
|
return
|
||||||
|
panel.theme = active_theme
|
||||||
|
_touch_state = true
|
||||||
|
emit_signal("touch_on")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Area_body_exited(body: Node) -> void:
|
||||||
|
if body.get_parent().get_parent() != self:
|
||||||
|
return
|
||||||
|
panel.theme = normal_theme
|
||||||
|
_touch_state = false
|
||||||
|
emit_signal("touch_off")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_width_changed(width):
|
||||||
|
var ratio = OverlayInit.ovr_interface.get_render_targetsize()
|
||||||
|
$LeftHand/Area/CollisionShape.shape.set_extents(Vector3(0.5*width, 0.5*width * ratio.y/ratio.x, 0.01))
|
||||||
|
|
||||||
|
|
||||||
|
func get_touch_state():
|
||||||
|
return _touch_state
|
||||||
|
|
||||||
|
|
||||||
|
func get_trigger_state():
|
||||||
|
return _trigger_state
|
||||||
|
|
||||||
|
|
||||||
|
func get_active_controller():
|
||||||
|
return _active_controller
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
signal width_changed
|
||||||
|
|
||||||
enum TARGETS { head, left, right, world }
|
enum TARGETS { head, left, right, world }
|
||||||
export (TARGETS) var target = TARGETS.head setget _set_target
|
export (TARGETS) var target = TARGETS.head setget _set_target
|
||||||
export var overlay_scene = preload("res://addons/openvr_overlay/MissingOverlay.tscn") setget _set_overlay_scene
|
export var overlay_scene = preload("res://addons/openvr_overlay/MissingOverlay.tscn") setget _set_overlay_scene
|
||||||
|
@ -10,6 +12,8 @@ export var fallback_to_hmd = false # fallback is only applied if tracker is not
|
||||||
|
|
||||||
var _tracker_id: int = 0 setget ,get_tracker_id
|
var _tracker_id: int = 0 setget ,get_tracker_id
|
||||||
|
|
||||||
|
onready var container = $OverlayViewport/PanelContainer
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
ARVRServer.connect("tracker_added", self, "_tracker_changed")
|
ARVRServer.connect("tracker_added", self, "_tracker_changed")
|
||||||
|
@ -18,7 +22,7 @@ func _ready() -> void:
|
||||||
$OverlayViewport.overlay_width_in_meters = width_meters
|
$OverlayViewport.overlay_width_in_meters = width_meters
|
||||||
$OverlayViewport.size = OverlayInit.ovr_interface.get_render_targetsize()
|
$OverlayViewport.size = OverlayInit.ovr_interface.get_render_targetsize()
|
||||||
if overlay_scene:
|
if overlay_scene:
|
||||||
$OverlayViewport/PanelContainer.add_child(overlay_scene.instance())
|
container.add_child(overlay_scene.instance())
|
||||||
|
|
||||||
update_tracker_id()
|
update_tracker_id()
|
||||||
update_offset()
|
update_offset()
|
||||||
|
@ -84,11 +88,15 @@ func _set_offset_rot(rot: Vector3):
|
||||||
func _set_width_meters(width: float):
|
func _set_width_meters(width: float):
|
||||||
width_meters = width
|
width_meters = width
|
||||||
$OverlayViewport.overlay_width_in_meters = width_meters
|
$OverlayViewport.overlay_width_in_meters = width_meters
|
||||||
|
emit_signal("width_changed", width)
|
||||||
|
|
||||||
|
|
||||||
func _set_overlay_scene(scene: PackedScene):
|
func _set_overlay_scene(scene: PackedScene):
|
||||||
overlay_scene = scene
|
overlay_scene = scene
|
||||||
if $OverlayViewport/PanelContainer.get_children():
|
if not container:
|
||||||
$OverlayViewport/PanelContainer.get_child(0).queue_free()
|
print("container missing")
|
||||||
$OverlayViewport/PanelContainer.add_child(overlay_scene.instance())
|
return
|
||||||
|
if container.get_child_count() > 0:
|
||||||
|
container.get_child(0).queue_free()
|
||||||
|
container.add_child(overlay_scene.instance())
|
||||||
|
|
||||||
|
|
Binary file not shown.
BIN
ovr-utils/addons/openvr_overlay/styles/active.theme
Normal file
BIN
ovr-utils/addons/openvr_overlay/styles/active.theme
Normal file
Binary file not shown.
BIN
ovr-utils/addons/openvr_overlay/styles/normal.theme
Normal file
BIN
ovr-utils/addons/openvr_overlay/styles/normal.theme
Normal file
Binary file not shown.
Binary file not shown.
BIN
ovr-utils/addons/openvr_overlay/styles/touching.theme
Normal file
BIN
ovr-utils/addons/openvr_overlay/styles/touching.theme
Normal file
Binary file not shown.
|
@ -2,4 +2,5 @@ extends Node
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
OS.window_size = Vector2(16, 16)
|
# OS.window_size = Vector2(16, 16)
|
||||||
|
return
|
||||||
|
|
Loading…
Reference in a new issue