mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-26 09:00:24 +01:00
dragging position offsets work, rotations are scuffed
This commit is contained in:
parent
52a5e346f9
commit
1cca61aac2
2 changed files with 20 additions and 15 deletions
|
@ -57,17 +57,14 @@ func begin_move():
|
||||||
_pre_move_target = get_parent().current_target
|
_pre_move_target = get_parent().current_target
|
||||||
_mover_hand_name = _active_controller.name
|
_mover_hand_name = _active_controller.name
|
||||||
_mover_hand_offsets.pos = get_parent().translation
|
_mover_hand_offsets.pos = get_parent().translation
|
||||||
_mover_hand_offsets.rot = get_parent().rotation_degrees
|
_mover_hand_offsets.rot = get_parent().rotation
|
||||||
|
|
||||||
# offset from active controller to overlay
|
# offset from active controller to overlay
|
||||||
var rel_t = _active_controller.transform * _overlay_area.global_transform.inverse()
|
|
||||||
# get_parent().offsets[_mover_hand_name].rot = (_overlay_area.global_transform.basis * _active_controller.transform.basis).get_euler() * 57.295
|
|
||||||
get_parent().offsets[_mover_hand_name].rot = _active_controller.transform.xform_inv(_overlay_area.global_transform.basis.get_euler())*57
|
|
||||||
|
|
||||||
|
var global_rot = _overlay_area.global_transform.basis.get_euler()
|
||||||
|
get_parent().offsets[_mover_hand_name].rot = global_rot - _active_controller.rotation
|
||||||
|
|
||||||
get_parent().offsets[_mover_hand_name].pos = _active_controller.transform.xform_inv(_overlay_area.global_transform.origin)
|
get_parent().offsets[_mover_hand_name].pos = _active_controller.transform.xform_inv(_overlay_area.global_transform.origin)
|
||||||
# get_parent().offsets[_mover_hand_name].pos = _active_controller.transform.xform_inv(_overlay_area.global_transform.origin)
|
|
||||||
# get_parent().offsets[_mover_hand_name].rot = _overlay_area.get_parent().rotation_degrees + _overlay_area.rotation_degrees - _active_controller.rotation_degrees
|
|
||||||
|
|
||||||
get_parent().current_target = _mover_hand_name
|
get_parent().current_target = _mover_hand_name
|
||||||
get_parent().update_tracker_id()
|
get_parent().update_tracker_id()
|
||||||
|
@ -78,12 +75,13 @@ func finish_move():
|
||||||
is_moving = false
|
is_moving = false
|
||||||
var new_pos = tracker_nodes[_pre_move_target].transform.xform_inv(_overlay_area.global_transform.origin)
|
var new_pos = tracker_nodes[_pre_move_target].transform.xform_inv(_overlay_area.global_transform.origin)
|
||||||
# this is only local rotations??
|
# this is only local rotations??
|
||||||
var new_rot = _overlay_area.get_parent().rotation_degrees + _overlay_area.rotation_degrees - tracker_nodes[_pre_move_target].rotation_degrees
|
var new_rot = _overlay_area.get_parent().rotation + _overlay_area.rotation - tracker_nodes[_pre_move_target].rotation
|
||||||
get_parent().update_current_target()
|
get_parent().update_current_target()
|
||||||
get_parent().update_tracker_id()
|
get_parent().update_tracker_id()
|
||||||
get_parent().offsets[get_parent().current_target].pos = new_pos
|
get_parent().offsets[get_parent().current_target].pos = new_pos
|
||||||
get_parent().offsets[get_parent().current_target].rot = new_rot
|
get_parent().offsets[get_parent().current_target].rot = new_rot
|
||||||
get_parent().update_offset()
|
get_parent().update_offset()
|
||||||
|
_update_target()
|
||||||
|
|
||||||
|
|
||||||
#get canvas position of active controller
|
#get canvas position of active controller
|
||||||
|
@ -132,7 +130,7 @@ func _trigger_off():
|
||||||
|
|
||||||
|
|
||||||
func _on_OverlayArea_entered(body: Node) -> void:
|
func _on_OverlayArea_entered(body: Node) -> void:
|
||||||
if body.get_node("../../..") != self:
|
if body.get_node("../../..") != self or is_moving:
|
||||||
return
|
return
|
||||||
_touch_state = true
|
_touch_state = true
|
||||||
_active_controller = body.get_parent()
|
_active_controller = body.get_parent()
|
||||||
|
@ -157,7 +155,7 @@ func _update_width():
|
||||||
|
|
||||||
func _update_offset():
|
func _update_offset():
|
||||||
_overlay_area.translation = get_parent().translation
|
_overlay_area.translation = get_parent().translation
|
||||||
_overlay_area.rotation_degrees = get_parent().rotation_degrees
|
_overlay_area.rotation = get_parent().rotation
|
||||||
|
|
||||||
|
|
||||||
func _update_target():
|
func _update_target():
|
||||||
|
@ -174,8 +172,8 @@ func _update_target():
|
||||||
# "world":
|
# "world":
|
||||||
# $VR.add_child(_overlay_area)
|
# $VR.add_child(_overlay_area)
|
||||||
|
|
||||||
if is_moving:
|
# if is_moving:
|
||||||
return
|
# return
|
||||||
|
|
||||||
_left_is_activator = get_parent().current_target != "left"
|
_left_is_activator = get_parent().current_target != "left"
|
||||||
_right_is_activator = get_parent().current_target != "right"
|
_right_is_activator = get_parent().current_target != "right"
|
||||||
|
|
|
@ -16,10 +16,11 @@ export var offsets:Dictionary = {
|
||||||
"left": {"pos": Vector3(), "rot": Vector3()},
|
"left": {"pos": Vector3(), "rot": Vector3()},
|
||||||
"right": {"pos": Vector3(), "rot": Vector3()},
|
"right": {"pos": Vector3(), "rot": Vector3()},
|
||||||
"world": {"pos": Vector3(), "rot": Vector3()}
|
"world": {"pos": Vector3(), "rot": Vector3()}
|
||||||
}# also contains temp offset that is created when dragged
|
}
|
||||||
|
# also contains temp offset that is created when dragged
|
||||||
|
|
||||||
# what's actually tracking
|
# what's actually tracking
|
||||||
var current_target = target# most of the time the actual target, but will fall back
|
var current_target = target setget _set_current_target# most of the time the actual target, but will fall back
|
||||||
|
|
||||||
var _tracker_id: int = 0
|
var _tracker_id: int = 0
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ onready var container = $OverlayViewport/Container
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
# TEMP
|
# TEMP
|
||||||
offsets.left.pos = translation
|
offsets.left.pos = translation
|
||||||
offsets.left.rot = rotation_degrees
|
offsets.left.rot = rotation
|
||||||
###
|
###
|
||||||
|
|
||||||
ARVRServer.connect("tracker_added", self, "_tracker_changed")
|
ARVRServer.connect("tracker_added", self, "_tracker_changed")
|
||||||
|
@ -62,7 +63,7 @@ func update_tracker_id() -> void:
|
||||||
|
|
||||||
func update_offset() -> void:
|
func update_offset() -> void:
|
||||||
translation = offsets[current_target].pos
|
translation = offsets[current_target].pos
|
||||||
rotation_degrees = offsets[current_target].rot
|
rotation = offsets[current_target].rot
|
||||||
|
|
||||||
match current_target:
|
match current_target:
|
||||||
"head":
|
"head":
|
||||||
|
@ -94,6 +95,12 @@ func set_target(new: String):
|
||||||
emit_signal("target_changed")
|
emit_signal("target_changed")
|
||||||
|
|
||||||
|
|
||||||
|
func _set_current_target(new: String): # overrides target
|
||||||
|
current_target = new
|
||||||
|
update_offset()
|
||||||
|
emit_signal("target_changed")
|
||||||
|
|
||||||
|
|
||||||
func set_width_in_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
|
||||||
|
|
Loading…
Reference in a new issue