mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-14 04:20:25 +01:00
plugin: cleanup
This commit is contained in:
parent
900fc0809c
commit
34bf10eb18
5 changed files with 34 additions and 69 deletions
|
@ -1,9 +1,8 @@
|
||||||
[gd_scene load_steps=9 format=2]
|
[gd_scene load_steps=8 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/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://overlays/UI_demo.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://overlays/UI_demo.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://overlays/BatteryOverlay.tscn" type="PackedScene" id=7]
|
[ext_resource path="res://overlays/BatteryOverlay.tscn" type="PackedScene" id=7]
|
||||||
[ext_resource path="res://addons/openvr_overlay/OverlayInteraction.tscn" type="PackedScene" id=8]
|
[ext_resource path="res://addons/openvr_overlay/OverlayInteraction.tscn" type="PackedScene" id=8]
|
||||||
|
@ -13,15 +12,6 @@ background_mode = 1
|
||||||
background_color = Color( 0.113725, 0.0705882, 0.196078, 1 )
|
background_color = Color( 0.113725, 0.0705882, 0.196078, 1 )
|
||||||
|
|
||||||
[node name="Overlays" type="Node"]
|
[node name="Overlays" type="Node"]
|
||||||
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 )]
|
[node name="OverlayInstance FPS" parent="." instance=ExtResource( 1 )]
|
||||||
target = 1
|
target = 1
|
||||||
|
@ -30,7 +20,7 @@ offset_pos = Vector3( 0.05, -0.01, 0.15 )
|
||||||
offset_rot = Vector3( -135, 90, 0 )
|
offset_rot = Vector3( -135, 90, 0 )
|
||||||
|
|
||||||
[node name="OverlayInstance Time" parent="." instance=ExtResource( 1 )]
|
[node name="OverlayInstance Time" parent="." instance=ExtResource( 1 )]
|
||||||
target = 3
|
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( -135, 90, 0 )
|
offset_rot = Vector3( -135, 90, 0 )
|
||||||
|
@ -43,10 +33,16 @@ width_meters = 0.1
|
||||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
environment = SubResource( 1 )
|
environment = SubResource( 1 )
|
||||||
|
|
||||||
[node name="OverlayInstance" parent="." instance=ExtResource( 1 )]
|
[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="OverlayInstance UI demo" parent="." instance=ExtResource( 1 )]
|
||||||
target = 1
|
target = 1
|
||||||
overlay_scene = ExtResource( 5 )
|
overlay_scene = ExtResource( 5 )
|
||||||
offset_pos = Vector3( 0, 0, -0.2 )
|
offset_pos = Vector3( 0, 0, -0.2 )
|
||||||
offset_rot = Vector3( 0, 90, 0 )
|
offset_rot = Vector3( 0, 90, 0 )
|
||||||
|
|
||||||
[node name="OverlayInteraction" parent="OverlayInstance" instance=ExtResource( 8 )]
|
[node name="OverlayInteraction" parent="OverlayInstance UI demo" instance=ExtResource( 8 )]
|
||||||
|
|
|
@ -5,10 +5,6 @@ signal touch_off # a controller exited
|
||||||
signal trigger_on # trigger pushed while touching
|
signal trigger_on # trigger pushed while touching
|
||||||
signal trigger_off # trigger released
|
signal trigger_off # trigger released
|
||||||
|
|
||||||
export var active_theme: Theme
|
|
||||||
export var normal_theme: Theme
|
|
||||||
export var touching_theme: Theme
|
|
||||||
|
|
||||||
var _touch_state = false setget ,get_touch_state
|
var _touch_state = false setget ,get_touch_state
|
||||||
var _trigger_state = false setget ,get_trigger_state
|
var _trigger_state = false setget ,get_trigger_state
|
||||||
|
|
||||||
|
@ -79,13 +75,11 @@ func _trigger_on(controller):
|
||||||
_active_controller = controller
|
_active_controller = controller
|
||||||
_trigger_state = true
|
_trigger_state = true
|
||||||
_send_click_event(true)
|
_send_click_event(true)
|
||||||
_update_selection()
|
|
||||||
emit_signal("trigger_on")
|
emit_signal("trigger_on")
|
||||||
|
|
||||||
|
|
||||||
func _trigger_off():
|
func _trigger_off():
|
||||||
_trigger_state = false
|
_trigger_state = false
|
||||||
_update_selection()
|
|
||||||
_send_click_event(false)
|
_send_click_event(false)
|
||||||
emit_signal("trigger_off")
|
emit_signal("trigger_off")
|
||||||
|
|
||||||
|
@ -95,8 +89,6 @@ func _on_OverlayArea_entered(body: Node) -> void:
|
||||||
return
|
return
|
||||||
_touch_state = true
|
_touch_state = true
|
||||||
_active_controller = body.get_parent()
|
_active_controller = body.get_parent()
|
||||||
_update_selection()
|
|
||||||
_update_cursor()
|
|
||||||
emit_signal("touch_on")
|
emit_signal("touch_on")
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,24 +97,13 @@ func _on_OverlayArea_exited(body: Node) -> void:
|
||||||
return
|
return
|
||||||
_active_controller = null # TODO revert to other controller if both were touching (edge case)
|
_active_controller = null # TODO revert to other controller if both were touching (edge case)
|
||||||
_touch_state = false
|
_touch_state = false
|
||||||
_update_selection()
|
|
||||||
emit_signal("touch_off")
|
emit_signal("touch_off")
|
||||||
|
|
||||||
|
|
||||||
func _update_selection():
|
|
||||||
return
|
|
||||||
if _trigger_state:
|
|
||||||
panel.theme = active_theme
|
|
||||||
elif _touch_state:
|
|
||||||
panel.theme = touching_theme
|
|
||||||
else:
|
|
||||||
panel.theme = normal_theme
|
|
||||||
|
|
||||||
|
|
||||||
func _update_width():
|
func _update_width():
|
||||||
var ratio = OverlayInit.ovr_interface.get_render_targetsize()
|
var ratio = OverlayInit.ovr_interface.get_render_targetsize()
|
||||||
var extents = get_parent().width_meters * 0.5
|
var extents = get_parent().width_meters * 0.5
|
||||||
_overlay_area.get_child(0).shape.set_extents(Vector3(extents, extents * ratio.y/ratio.x, 0.01))
|
_overlay_area.get_child(0).shape.set_extents(Vector3(extents, extents * ratio.y/ratio.x, 0.1))
|
||||||
|
|
||||||
|
|
||||||
func _update_offset():
|
func _update_offset():
|
||||||
|
|
|
@ -8,13 +8,14 @@ signal target_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")\
|
export var overlay_scene = preload("res://addons/openvr_overlay/MissingOverlay.tscn")\
|
||||||
setget _set_overlay_scene
|
setget set_overlay_scene
|
||||||
export var offset_pos := Vector3(0, 0, -1) setget _set_offset_pos
|
export var offset_pos := Vector3(0, 0, -1) setget set_offset_pos
|
||||||
export var offset_rot: Vector3 setget _set_offset_rot
|
export var offset_rot: Vector3 setget set_offset_rot
|
||||||
export var width_meters = 0.4 setget _set_width_meters
|
export var width_meters = 0.4 setget set_width_in_meters
|
||||||
export var fallback_to_hmd = false # fallback is only applied if tracker is not present at startup
|
export var fallback_to_hmd = false # fallback is only applied if tracker is not present at startup
|
||||||
|
# so this is not fully implemented
|
||||||
|
|
||||||
var _tracker_id: int = 0 setget ,get_tracker_id
|
var _tracker_id: int = 0
|
||||||
|
|
||||||
onready var container = $OverlayViewport/PanelContainer
|
onready var container = $OverlayViewport/PanelContainer
|
||||||
|
|
||||||
|
@ -54,7 +55,6 @@ func update_offset() -> void:
|
||||||
$Offset.translation = offset_pos
|
$Offset.translation = offset_pos
|
||||||
$Offset.rotation_degrees = offset_rot
|
$Offset.rotation_degrees = offset_rot
|
||||||
|
|
||||||
# print(_tracker_id)
|
|
||||||
match target:
|
match target:
|
||||||
TARGETS.head:
|
TARGETS.head:
|
||||||
$OverlayViewport.track_relative_to_device(0, $Offset.transform)
|
$OverlayViewport.track_relative_to_device(0, $Offset.transform)
|
||||||
|
@ -80,25 +80,25 @@ func _set_target(new: int):
|
||||||
emit_signal("target_changed")
|
emit_signal("target_changed")
|
||||||
|
|
||||||
|
|
||||||
func _set_offset_pos(pos: Vector3):
|
func set_offset_pos(pos: Vector3):
|
||||||
offset_pos = pos
|
offset_pos = pos
|
||||||
update_offset()
|
update_offset()
|
||||||
emit_signal("offset_changed")
|
emit_signal("offset_changed")
|
||||||
|
|
||||||
|
|
||||||
func _set_offset_rot(rot: Vector3):
|
func set_offset_rot(rot: Vector3):
|
||||||
offset_rot = rot
|
offset_rot = rot
|
||||||
update_offset()
|
update_offset()
|
||||||
emit_signal("offset_changed")
|
emit_signal("offset_changed")
|
||||||
|
|
||||||
|
|
||||||
func _set_width_meters(width: float):
|
func set_width_in_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")
|
emit_signal("width_changed")
|
||||||
|
|
||||||
|
|
||||||
func _set_overlay_scene(scene: PackedScene):
|
func set_overlay_scene(scene: PackedScene):
|
||||||
overlay_scene = scene
|
overlay_scene = scene
|
||||||
if not container:
|
if not container:
|
||||||
# print("container does not exist yet [overlay_instance.set_overlay_scene]")
|
# print("container does not exist yet [overlay_instance.set_overlay_scene]")
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://fonts/OpenSans-Bold.ttf" type="DynamicFontData" id=1]
|
[ext_resource path="res://fonts/OpenSans-Regular.ttf" type="DynamicFontData" id=2]
|
||||||
[ext_resource path="res://addons/openvr_overlay/styles/active.stylebox" type="StyleBox" id=3]
|
[ext_resource path="res://addons/openvr_overlay/styles/active.stylebox" type="StyleBox" id=3]
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=1]
|
[sub_resource type="DynamicFont" id=2]
|
||||||
size = 100
|
size = 100
|
||||||
font_data = ExtResource( 1 )
|
font_data = ExtResource( 2 )
|
||||||
|
|
||||||
|
[sub_resource type="Theme" id=3]
|
||||||
|
default_font = SubResource( 2 )
|
||||||
|
|
||||||
[node name="Control" type="Control"]
|
[node name="Control" type="Control"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
@ -15,17 +18,9 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="OptionButton" type="OptionButton" parent="."]
|
[node name="OptionButton" type="OptionButton" parent="."]
|
||||||
anchor_left = 0.144
|
margin_right = 111.0
|
||||||
anchor_top = 0.483
|
margin_bottom = 41.0
|
||||||
anchor_right = 0.856
|
theme = SubResource( 3 )
|
||||||
anchor_bottom = 0.517
|
|
||||||
margin_left = -0.456009
|
|
||||||
margin_top = -17.8
|
|
||||||
margin_right = 0.455933
|
|
||||||
margin_bottom = 16.8
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
size_flags_vertical = 3
|
|
||||||
custom_fonts/font = SubResource( 1 )
|
|
||||||
text = "Item 0"
|
text = "Item 0"
|
||||||
items = [ "Item 0", null, false, 0, null, "Item 1", null, false, 1, null, "Item 2", null, false, 2, null, "Item 3", null, false, 3, null ]
|
items = [ "Item 0", null, false, 0, null, "Item 1", null, false, 1, null, "Item 2", null, false, 2, null, "Item 3", null, false, 3, null ]
|
||||||
selected = 0
|
selected = 0
|
||||||
|
@ -34,10 +29,9 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Button" type="Button" parent="."]
|
[node name="Button" type="Button" parent="."]
|
||||||
margin_left = 158.089
|
margin_top = 600.0
|
||||||
margin_top = 45.4084
|
margin_right = 315.0
|
||||||
margin_right = 473.089
|
margin_bottom = 778.0
|
||||||
margin_bottom = 223.408
|
|
||||||
custom_styles/pressed = ExtResource( 3 )
|
custom_styles/pressed = ExtResource( 3 )
|
||||||
toggle_mode = true
|
toggle_mode = true
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
extends Node
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
# OS.window_size = Vector2(16, 16)
|
|
||||||
return
|
|
Loading…
Reference in a new issue