-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added hand-pose stack to XRToolsHand. Added XRToolsFunctionPoseArea to detect hand pose areas and control the hand poses. Added XRToolsHandPoseArea to define hand poses within an area. Modified interactables to have hand poses. Modified poke demo to have a hand pose for touching the screen. * Updated Sign Point hand-pose (provided by DigitalN8m4r3) Added pointing to main menu settings UI * Added XRToolsHandPoseSettings resource to contain all the hand-pose settings (currently just open/close animations) Created standard XRToolsHandPoseSettings for standard poses (default and point) Modified XRToolsHand to set default pose as XRToolsHandPoseSettings Modified XRToolsHand to maintain priority-sorted list of pose overrides Modified all hand scenes to use default pose settings Modified XRToolsHandPoseArea to set pose as XRToolsHandPoseSettings Modified demo scenes and interactables to use appropriate pose settings * Renamed XRToolsFunctionPoseArea to XRToolsFunctionPoseDetector
- Loading branch information
1 parent
5f167a0
commit d33f5bc
Showing
48 changed files
with
1,276 additions
and
384 deletions.
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
addons/godot-xr-tools/functions/function_pose_detector.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
class_name XRToolsFunctionPoseArea, "res://addons/godot-xr-tools/editor/icons/hand.svg" | ||
extends Spatial | ||
|
||
|
||
## XR Tools Function Pose Area | ||
## | ||
## This area works with the XRToolsHandPoseArea to control the pose | ||
## of the VR hands. | ||
|
||
|
||
## Collision mask to detect hand pose areas | ||
export (int, LAYERS_3D_PHYSICS) var collision_mask : int = 1 << 21 setget set_collision_mask | ||
|
||
|
||
## Hand controller | ||
var _controller : ARVRController | ||
|
||
## Hand to control | ||
var _hand : XRToolsHand | ||
|
||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
# Find controller and hand | ||
_controller = get_parent() as ARVRController | ||
_hand = _find_hand() | ||
|
||
# Connect signals (if controller and hand are valid) | ||
if _controller and _hand: | ||
if $SenseArea.connect("area_entered", self, "_on_area_entered"): | ||
push_error("Unable to connect area_entered signal") | ||
if $SenseArea.connect("area_exited", self, "_on_area_exited"): | ||
push_error("Unable to connect area_exited signal") | ||
|
||
# Update collision mask | ||
_update_collision_mask() | ||
|
||
|
||
# This method verifies the pose area has a valid configuration. | ||
func _get_configuration_warning(): | ||
# Verify hand can be found | ||
if !_find_hand(): | ||
return "Node must be a child of an ARVRController with a hand" | ||
|
||
# Pass basic validation | ||
return "" | ||
|
||
|
||
func set_collision_mask(mask : int) -> void: | ||
collision_mask = mask | ||
if is_inside_tree(): | ||
_update_collision_mask() | ||
|
||
|
||
func _update_collision_mask() -> void: | ||
$SenseArea.collision_mask = collision_mask | ||
|
||
|
||
## Signal handler called when this XRToolsFunctionPoseArea enters an area | ||
func _on_area_entered(area : Area) -> void: | ||
# Igjnore if the area is not a hand-pose area | ||
var pose_area := area as XRToolsHandPoseArea | ||
if !pose_area: | ||
return | ||
|
||
# Set the appropriate poses | ||
if _controller.controller_id == 1 and pose_area.left_pose: | ||
_hand.add_pose_override( | ||
pose_area, | ||
pose_area.pose_priority, | ||
pose_area.left_pose) | ||
elif _controller.controller_id == 2 and pose_area.right_pose: | ||
_hand.add_pose_override( | ||
pose_area, | ||
pose_area.pose_priority, | ||
pose_area.right_pose) | ||
|
||
|
||
## Signal handler called when this XRToolsFunctionPoseArea leaves an area | ||
func _on_area_exited(area : Area) -> void: | ||
# Ignore if the area is not a hand-pose area | ||
var pose_area := area as XRToolsHandPoseArea | ||
if !pose_area: | ||
return | ||
|
||
# Remove any overrides set from this hand-pose area | ||
_hand.remove_pose_override(pose_area) | ||
|
||
|
||
func _find_hand() -> XRToolsHand: | ||
# Get the parent | ||
var parent := get_parent() | ||
if !parent: | ||
return null | ||
|
||
# Make sure it's a controller | ||
var controller := parent as ARVRController | ||
if !controller: | ||
return null | ||
|
||
# Look for hands under the controller | ||
for child in controller.get_children(): | ||
var hand := child as XRToolsHand | ||
if hand: | ||
return hand | ||
|
||
# No hand found | ||
return null |
19 changes: 19 additions & 0 deletions
19
addons/godot-xr-tools/functions/function_pose_detector.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[gd_scene load_steps=3 format=2] | ||
|
||
[ext_resource path="res://addons/godot-xr-tools/functions/function_pose_detector.gd" type="Script" id=1] | ||
|
||
[sub_resource type="CapsuleShape" id=1] | ||
radius = 0.08 | ||
height = 0.08 | ||
|
||
[node name="FunctionPoseDetector" type="Spatial"] | ||
script = ExtResource( 1 ) | ||
|
||
[node name="SenseArea" type="Area" parent="."] | ||
collision_layer = 0 | ||
collision_mask = 2097152 | ||
monitorable = false | ||
|
||
[node name="CollisionShape" type="CollisionShape" parent="SenseArea"] | ||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.04, 0.08 ) | ||
shape = SubResource( 1 ) |
Binary file modified
BIN
-44 Bytes
(100%)
addons/godot-xr-tools/hands/animations/left/Sign_Point.anim
Binary file not shown.
Binary file modified
BIN
-45 Bytes
(100%)
addons/godot-xr-tools/hands/animations/right/Sign_Point.anim
Binary file not shown.
Oops, something went wrong.