mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-22 15:40:25 +01:00
grab translation works but not rotation
This commit is contained in:
parent
9f74010bc9
commit
37d982458a
4 changed files with 73 additions and 12 deletions
|
@ -21,18 +21,19 @@ target = 1
|
|||
overlay_scene = ExtResource( 3 )
|
||||
width_meters = 0.1
|
||||
|
||||
[node name="OverlayInteraction" parent="OverlayInstance Time" instance=ExtResource( 8 )]
|
||||
|
||||
[node name="OverlayInstance Battery" parent="." instance=ExtResource( 1 )]
|
||||
transform = Transform( -4.37114e-08, -0.707107, -0.707107, 0, -0.707107, 0.707107, -1, 3.09086e-08, 3.09086e-08, -0.12, 0, 0.1 )
|
||||
target = 1
|
||||
overlay_scene = ExtResource( 7 )
|
||||
|
||||
[node name="OverlayInstance UI demo" parent="." instance=ExtResource( 1 )]
|
||||
transform = Transform( -4.37114e-08, -1, -4.37114e-08, 0, -4.37114e-08, 1, -1, 4.37114e-08, 1.91069e-15, 0, 0, -0.25 )
|
||||
target = 1
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.25 )
|
||||
target = 3
|
||||
overlay_scene = ExtResource( 5 )
|
||||
|
||||
[node name="OverlayInteraction" parent="OverlayInstance UI demo" instance=ExtResource( 8 )]
|
||||
|
||||
[node name="XYZ Widget" parent="." instance=ExtResource( 4 )]
|
||||
|
||||
[editable path="OverlayInstance UI demo"]
|
||||
[editable path="OverlayInstance UI demo/OverlayInteraction"]
|
||||
|
|
|
@ -16,6 +16,10 @@ var _cursor_node = preload("res://addons/openvr_overlay/interaction/Cursor.tscn"
|
|||
var _right_is_activator = false
|
||||
var _left_is_activator = false
|
||||
|
||||
var is_moving := false
|
||||
var move_grab_pos: Vector3
|
||||
var move_grab_rot: Vector3
|
||||
|
||||
onready var viewport: Viewport = get_node("../OverlayViewport")
|
||||
|
||||
|
||||
|
@ -34,8 +38,29 @@ func _ready() -> void:
|
|||
_update_target()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
func _process(_delta: float) -> void:
|
||||
_update_cursor()
|
||||
if is_moving:
|
||||
# var controller_new = _overlay_area.global_transform.inverse() * _active_controller.global_transform
|
||||
# var controller_delta = move_grab_offset.inverse() * controller_new
|
||||
# get_parent().transform = move_start_offset * controller_delta
|
||||
var global_target = move_grab_pos + _active_controller.translation
|
||||
get_parent().translation = global_target - _overlay_area.get_parent().translation
|
||||
|
||||
|
||||
func begin_move():
|
||||
if not _active_controller:
|
||||
print("Could not begin moving overlay, no controller active. ", get_parent().name)
|
||||
return
|
||||
is_moving = true
|
||||
# offset from active controller to overlay
|
||||
# move_grab_pos = _active_controller.transform.xform_inv(_overlay_area.global_transform.origin)
|
||||
move_grab_pos = _overlay_area.global_transform.origin - _active_controller.translation
|
||||
move_grab_rot = Vector3()
|
||||
|
||||
|
||||
func finish_move():
|
||||
is_moving = false
|
||||
|
||||
|
||||
#get canvas position of active controller
|
||||
|
@ -94,6 +119,8 @@ func _on_OverlayArea_entered(body: Node) -> void:
|
|||
func _on_OverlayArea_exited(body: Node) -> void:
|
||||
if body.get_node("../../..") != self:
|
||||
return
|
||||
# TEMP
|
||||
if not is_moving:
|
||||
_active_controller = null # TODO revert to other controller if both were touching (edge case)
|
||||
_touch_state = false
|
||||
emit_signal("touch_off")
|
||||
|
|
17
ovr-utils/addons/openvr_overlay/move_overlay.gd
Normal file
17
ovr-utils/addons/openvr_overlay/move_overlay.gd
Normal file
|
@ -0,0 +1,17 @@
|
|||
extends Control
|
||||
|
||||
|
||||
var ihandler
|
||||
|
||||
func _ready() -> void:
|
||||
ihandler = get_viewport().get_node("../OverlayInteraction")
|
||||
|
||||
|
||||
func _on_DragButton_button_down() -> void:
|
||||
if ihandler:
|
||||
ihandler.begin_move()
|
||||
|
||||
|
||||
func _on_DragButton_button_up() -> void:
|
||||
if ihandler:
|
||||
ihandler.finish_move()
|
|
@ -1,6 +1,8 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://addons/openvr_overlay/move_overlay.gd" type="Script" id=1]
|
||||
[ext_resource path="res://fonts/OpenSans-Regular.ttf" type="DynamicFontData" id=2]
|
||||
[ext_resource path="res://fonts/OpenSans-Bold.ttf" type="DynamicFontData" id=3]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 100
|
||||
|
@ -10,6 +12,7 @@ font_data = ExtResource( 2 )
|
|||
default_font = SubResource( 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
bg_color = Color( 0.419608, 0.419608, 0.419608, 1 )
|
||||
border_width_left = 16
|
||||
border_width_top = 16
|
||||
border_width_right = 16
|
||||
|
@ -17,9 +20,16 @@ border_width_bottom = 16
|
|||
border_color = Color( 0, 0.505882, 1, 1 )
|
||||
corner_detail = 1
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=4]
|
||||
|
||||
[sub_resource type="DynamicFont" id=5]
|
||||
size = 64
|
||||
font_data = ExtResource( 3 )
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
@ -35,12 +45,18 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
margin_top = 600.0
|
||||
margin_right = 315.0
|
||||
margin_bottom = 778.0
|
||||
[node name="DragButton" type="Button" parent="."]
|
||||
margin_left = 335.0
|
||||
margin_right = 650.0
|
||||
margin_bottom = 143.0
|
||||
custom_styles/pressed = SubResource( 3 )
|
||||
toggle_mode = true
|
||||
custom_styles/normal = SubResource( 4 )
|
||||
custom_fonts/font = SubResource( 5 )
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
text = "Drag"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[connection signal="button_down" from="DragButton" to="." method="_on_DragButton_button_down"]
|
||||
[connection signal="button_up" from="DragButton" to="." method="_on_DragButton_button_up"]
|
||||
|
|
Loading…
Reference in a new issue