Skip to content

Commit

Permalink
Added basic swim demo from work performed by pietru2004.
Browse files Browse the repository at this point in the history
  • Loading branch information
Malcolmnixon committed Apr 2, 2023
1 parent 63f75a7 commit f0ad7c8
Show file tree
Hide file tree
Showing 9 changed files with 416 additions and 36 deletions.
79 changes: 43 additions & 36 deletions scenes/main_menu/main_menu_level.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=38 format=3 uid="uid://utga61rlgb3t"]
[gd_scene load_steps=39 format=3 uid="uid://utga61rlgb3t"]

[ext_resource type="PackedScene" uid="uid://qbmx03iibuuu" path="res://addons/godot-xr-tools/staging/scene_base.tscn" id="1"]
[ext_resource type="Script" path="res://scenes/main_menu/main_menu_level.gd" id="2_taoax"]
Expand All @@ -19,72 +19,73 @@
[ext_resource type="Texture2D" uid="uid://ny4n43p3e3du" path="res://scenes/pickable_demo/pickable_demo.png" id="22"]
[ext_resource type="PackedScene" uid="uid://bq86r4yll8po" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/left_fullglove_low.tscn" id="23_pr05t"]
[ext_resource type="PackedScene" uid="uid://xqimcf20s2jp" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/right_fullglove_low.tscn" id="25_2b81d"]
[ext_resource type="Texture2D" uid="uid://dd2u7l7q2de65" path="res://scenes/swim_demo/swim demo.png" id="25_axwbd"]
[ext_resource type="Texture2D" uid="uid://bbe7o7pdq38m2" path="res://scenes/poke_demo/poke_demo.png" id="25_rg3rn"]
[ext_resource type="PackedScene" uid="uid://3bsyhd7ehoa1" path="res://scenes/main_menu/objects/settings_ui.tscn" id="26_0uyxa"]
[ext_resource type="Material" uid="uid://bhiiya7ow6h8v" path="res://addons/godot-xr-tools/hands/materials/labglove.material" id="26_id1x7"]
[ext_resource type="Texture2D" uid="uid://v4807nasx1dc" path="res://scenes/sprinting_demo/sprinting_demo.png" id="29_h1jn0"]
[ext_resource type="Texture2D" uid="uid://cr1l4g7btdyht" path="res://scenes/origin_gravity_demo/origin_gravity_demo.png" id="32_c4n1q"]
[ext_resource type="Texture2D" uid="uid://dhd30j0xpcxoi" path="res://scenes/sphere_world_demo/sphere_world_demo.png" id="34_xw8ig"]

[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_a53jr"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_dq1db"]
animation = &"Grip"

[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_no2j2"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_iolra"]
animation = &"Grip"

[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_pj3so"]
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_xtp1x"]
filter_enabled = true
filters = ["Armature/Skeleton3D:Little_Distal_L", "Armature/Skeleton3D:Little_Intermediate_L", "Armature/Skeleton3D:Little_Metacarpal_L", "Armature/Skeleton3D:Little_Proximal_L", "Armature/Skeleton3D:Middle_Distal_L", "Armature/Skeleton3D:Middle_Intermediate_L", "Armature/Skeleton3D:Middle_Metacarpal_L", "Armature/Skeleton3D:Middle_Proximal_L", "Armature/Skeleton3D:Ring_Distal_L", "Armature/Skeleton3D:Ring_Intermediate_L", "Armature/Skeleton3D:Ring_Metacarpal_L", "Armature/Skeleton3D:Ring_Proximal_L", "Armature/Skeleton3D:Thumb_Distal_L", "Armature/Skeleton3D:Thumb_Metacarpal_L", "Armature/Skeleton3D:Thumb_Proximal_L", "Armature/Skeleton:Little_Distal_L", "Armature/Skeleton:Little_Intermediate_L", "Armature/Skeleton:Little_Proximal_L", "Armature/Skeleton:Middle_Distal_L", "Armature/Skeleton:Middle_Intermediate_L", "Armature/Skeleton:Middle_Proximal_L", "Armature/Skeleton:Ring_Distal_L", "Armature/Skeleton:Ring_Intermediate_L", "Armature/Skeleton:Ring_Proximal_L", "Armature/Skeleton:Thumb_Distal_L", "Armature/Skeleton:Thumb_Proximal_L"]

[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_3d11p"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_5s3xj"]
animation = &"Grip 5"

[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_qaknm"]
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_ktn2n"]
filter_enabled = true
filters = ["Armature/Skeleton3D:Index_Distal_L", "Armature/Skeleton3D:Index_Intermediate_L", "Armature/Skeleton3D:Index_Metacarpal_L", "Armature/Skeleton3D:Index_Proximal_L", "Armature/Skeleton:Index_Distal_L", "Armature/Skeleton:Index_Intermediate_L", "Armature/Skeleton:Index_Proximal_L"]

[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_ougf0"]
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_21l0p"]
graph_offset = Vector2(-536, 11)
nodes/ClosedHand1/node = SubResource("AnimationNodeAnimation_a53jr")
nodes/ClosedHand1/node = SubResource("AnimationNodeAnimation_dq1db")
nodes/ClosedHand1/position = Vector2(-600, 300)
nodes/ClosedHand2/node = SubResource("AnimationNodeAnimation_no2j2")
nodes/ClosedHand2/node = SubResource("AnimationNodeAnimation_iolra")
nodes/ClosedHand2/position = Vector2(-360, 300)
nodes/Grip/node = SubResource("AnimationNodeBlend2_pj3so")
nodes/Grip/node = SubResource("AnimationNodeBlend2_xtp1x")
nodes/Grip/position = Vector2(0, 20)
nodes/OpenHand/node = SubResource("AnimationNodeAnimation_3d11p")
nodes/OpenHand/node = SubResource("AnimationNodeAnimation_5s3xj")
nodes/OpenHand/position = Vector2(-600, 100)
nodes/Trigger/node = SubResource("AnimationNodeBlend2_qaknm")
nodes/Trigger/node = SubResource("AnimationNodeBlend2_ktn2n")
nodes/Trigger/position = Vector2(-360, 20)
node_connections = [&"output", 0, &"Grip", &"Grip", 0, &"Trigger", &"Grip", 1, &"ClosedHand2", &"Trigger", 0, &"OpenHand", &"Trigger", 1, &"ClosedHand1"]

[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_f3eia"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_4akrm"]
animation = &"Grip"

[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_kg04j"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_sjxyc"]
animation = &"Grip"

[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_ubtjw"]
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_5i45q"]
filter_enabled = true
filters = ["Armature/Skeleton3D:Little_Distal_R", "Armature/Skeleton3D:Little_Intermediate_R", "Armature/Skeleton3D:Little_Metacarpal_R", "Armature/Skeleton3D:Little_Proximal_R", "Armature/Skeleton3D:Middle_Distal_R", "Armature/Skeleton3D:Middle_Intermediate_R", "Armature/Skeleton3D:Middle_Metacarpal_R", "Armature/Skeleton3D:Middle_Proximal_R", "Armature/Skeleton3D:Ring_Distal_R", "Armature/Skeleton3D:Ring_Intermediate_R", "Armature/Skeleton3D:Ring_Metacarpal_R", "Armature/Skeleton3D:Ring_Proximal_R", "Armature/Skeleton3D:Thumb_Distal_R", "Armature/Skeleton3D:Thumb_Metacarpal_R", "Armature/Skeleton3D:Thumb_Proximal_R", "Armature/Skeleton:Little_Distal_R", "Armature/Skeleton:Little_Intermediate_R", "Armature/Skeleton:Little_Proximal_R", "Armature/Skeleton:Middle_Distal_R", "Armature/Skeleton:Middle_Intermediate_R", "Armature/Skeleton:Middle_Proximal_R", "Armature/Skeleton:Ring_Distal_R", "Armature/Skeleton:Ring_Intermediate_R", "Armature/Skeleton:Ring_Proximal_R", "Armature/Skeleton:Thumb_Distal_R", "Armature/Skeleton:Thumb_Proximal_R"]

[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_gi1hy"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ylh2k"]
animation = &"Grip 5"

[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_snhct"]
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_3j1ly"]
filter_enabled = true
filters = ["Armature/Skeleton3D:Index_Distal_R", "Armature/Skeleton3D:Index_Intermediate_R", "Armature/Skeleton3D:Index_Metacarpal_R", "Armature/Skeleton3D:Index_Proximal_R", "Armature/Skeleton:Index_Distal_R", "Armature/Skeleton:Index_Intermediate_R", "Armature/Skeleton:Index_Proximal_R"]

[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_8tjfy"]
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_3wbxl"]
graph_offset = Vector2(-552.664, 107.301)
nodes/ClosedHand1/node = SubResource("AnimationNodeAnimation_f3eia")
nodes/ClosedHand1/node = SubResource("AnimationNodeAnimation_4akrm")
nodes/ClosedHand1/position = Vector2(-600, 300)
nodes/ClosedHand2/node = SubResource("AnimationNodeAnimation_kg04j")
nodes/ClosedHand2/node = SubResource("AnimationNodeAnimation_sjxyc")
nodes/ClosedHand2/position = Vector2(-360, 300)
nodes/Grip/node = SubResource("AnimationNodeBlend2_ubtjw")
nodes/Grip/node = SubResource("AnimationNodeBlend2_5i45q")
nodes/Grip/position = Vector2(0, 40)
nodes/OpenHand/node = SubResource("AnimationNodeAnimation_gi1hy")
nodes/OpenHand/node = SubResource("AnimationNodeAnimation_ylh2k")
nodes/OpenHand/position = Vector2(-600, 100)
nodes/Trigger/node = SubResource("AnimationNodeBlend2_snhct")
nodes/Trigger/node = SubResource("AnimationNodeBlend2_3j1ly")
nodes/Trigger/position = Vector2(-360, 40)
node_connections = [&"output", 0, &"Grip", &"Grip", 0, &"Trigger", &"Grip", 1, &"ClosedHand2", &"Trigger", 0, &"OpenHand", &"Trigger", 1, &"ClosedHand1"]

Expand Down Expand Up @@ -123,7 +124,7 @@ bone_idx = 9
transform = Transform3D(0.999999, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)

[node name="AnimationTree" parent="XROrigin3D/LeftHand/LeftHand" index="1"]
tree_root = SubResource("AnimationNodeBlendTree_ougf0")
tree_root = SubResource("AnimationNodeBlendTree_21l0p")

[node name="FunctionPoseDetector" parent="XROrigin3D/LeftHand" index="1" instance=ExtResource("5_xgcrx")]

Expand Down Expand Up @@ -166,7 +167,7 @@ bone_idx = 9
transform = Transform3D(0.999999, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)

[node name="AnimationTree" parent="XROrigin3D/RightHand/RightHand" index="1"]
tree_root = SubResource("AnimationNodeBlendTree_8tjfy")
tree_root = SubResource("AnimationNodeBlendTree_3wbxl")

[node name="FunctionPoseDetector" parent="XROrigin3D/RightHand" index="1" instance=ExtResource("5_xgcrx")]

Expand All @@ -188,71 +189,77 @@ scene = "res://scenes/basic_movement_demo/basic_movement_demo.tscn"
title = ExtResource("10")

[node name="ToFootstepDemo" parent="Demos" index="1" instance=ExtResource("9")]
transform = Transform3D(0.866025, 0, 0.5, 0, 1, 0, -0.5, 0, 0.866025, -5, 0, -8.66025)
transform = Transform3D(0.885456, 0, 0.464723, 0, 1, 0, -0.464723, 0, 0.885456, -4.64723, 0, -8.85456)
scene_base = NodePath("../..")
scene = "res://scenes/footstep_movement_demo/footstep_movement_demo.tscn"
title = ExtResource("15_k6bhw")

[node name="ToTeleportDemo" parent="Demos" index="2" instance=ExtResource("9")]
transform = Transform3D(0.5, 0, 0.866025, 0, 1, 0, -0.866025, 0, 0.5, -8.66025, 0, -5)
transform = Transform3D(0.568065, 0, 0.822984, 0, 1, 0, -0.822984, 0, 0.568065, -8.22984, 0, -5.68065)
scene_base = NodePath("../..")
scene = "res://scenes/teleport_demo/teleport_demo.tscn"
title = ExtResource("12")

[node name="ToClimbingGlidingDemo" parent="Demos" index="3" instance=ExtResource("9")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -10, 0, 4.37114e-07)
transform = Transform3D(0.120537, 0, 0.992709, 0, 1, 0, -0.992709, 0, 0.120537, -9.92709, 0, -1.20537)
scene_base = NodePath("../..")
scene = "res://scenes/climbing_gliding_demo/climbing_gliding_demo.tscn"
title = ExtResource("13")

[node name="ToGrapplingDemo" parent="Demos" index="4" instance=ExtResource("9")]
transform = Transform3D(-0.5, 0, 0.866025, 0, 1, 0, -0.866025, 0, -0.5, -8.66025, 0, 5)
transform = Transform3D(-0.354605, 0, 0.935016, 0, 1, 0, -0.935016, 0, -0.354605, -9.35016, 0, 3.54605)
scene_base = NodePath("../..")
scene = "res://scenes/grappling_demo/grappling_demo.tscn"
title = ExtResource("16")

[node name="ToInteractablesDemo" parent="Demos" index="5" instance=ExtResource("9")]
transform = Transform3D(-0.866025, 0, 0.5, 0, 1, 0, -0.5, 0, -0.866025, -5, 0, 8.66025)
transform = Transform3D(-0.748511, 0, 0.663123, 0, 1, 0, -0.663123, 0, -0.748511, -6.63123, 0, 7.48511)
scene_base = NodePath("../..")
scene = "res://scenes/interactables_demo/interactables_demo.tscn"
title = ExtResource("17")

[node name="ToPointerDemo" parent="Demos" index="6" instance=ExtResource("9")]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 8.74228e-07, 0, 10)
transform = Transform3D(-0.970942, 0, 0.239316, 0, 1, 0, -0.239316, 0, -0.970942, -2.39316, 0, 9.70942)
scene_base = NodePath("../..")
scene = "res://scenes/interactables_demo/interactables_demo.tscn"
title = ExtResource("20")

[node name="ToPickableDemo" parent="Demos" index="7" instance=ExtResource("9")]
transform = Transform3D(-0.866025, 0, -0.5, 0, 1, 0, 0.5, 0, -0.866025, 5, 0, 8.66025)
transform = Transform3D(-0.970942, 0, -0.239316, 0, 1, 0, 0.239316, 0, -0.970942, 2.39316, 0, 9.70942)
scene_base = NodePath("../..")
scene = "res://scenes/pickable_demo/pickable_demo.tscn"
title = ExtResource("22")

[node name="ToPokeDemo" parent="Demos" index="8" instance=ExtResource("9")]
transform = Transform3D(-0.5, 0, -0.866025, 0, 1, 0, 0.866025, 0, -0.5, 8.66025, 0, 5)
transform = Transform3D(-0.748511, 0, -0.663123, 0, 1, 0, 0.663123, 0, -0.748511, 6.63123, 0, 7.48511)
scene_base = NodePath("../..")
scene = "res://scenes/poke_demo/poke_demo.tscn"
title = ExtResource("25_rg3rn")

[node name="ToSprintDemo" parent="Demos" index="9" instance=ExtResource("9")]
transform = Transform3D(1.19249e-08, 0, -1, 0, 1, 0, 1, 0, 1.19249e-08, 10, 0, -1.19249e-07)
transform = Transform3D(-0.354605, 0, -0.935016, 0, 1, 0, 0.935016, 0, -0.354605, 9.35016, 0, 3.54605)
scene_base = NodePath("../..")
scene = "res://scenes/sprinting_demo/sprinting_demo.tscn"
title = ExtResource("29_h1jn0")

[node name="ToOriginGravityDemo" parent="Demos" index="10" instance=ExtResource("9")]
transform = Transform3D(0.5, 0, -0.866025, 0, 1, 0, 0.866025, 0, 0.5, 8.66025, 0, -5)
transform = Transform3D(0.120537, 0, -0.992709, 0, 1, 0, 0.992709, 0, 0.120537, 9.92709, 0, -1.20537)
scene_base = NodePath("../..")
scene = "res://scenes/origin_gravity_demo/origin_gravity_demo.tscn"
title = ExtResource("32_c4n1q")

[node name="ToSphereWorldDemo" parent="Demos" index="11" instance=ExtResource("9")]
transform = Transform3D(0.866025, 0, -0.5, 0, 1, 0, 0.5, 0, 0.866025, 5, 0, -8.66025)
transform = Transform3D(0.568065, 0, -0.822984, 0, 1, 0, 0.822984, 0, 0.568065, 8.22984, 0, -5.68065)
scene_base = NodePath("../..")
scene = "res://scenes/sphere_world_demo/sphere_world_demo.tscn"
title = ExtResource("34_xw8ig")

[node name="ToSwimming" parent="Demos" index="12" instance=ExtResource("9")]
transform = Transform3D(0.885456, 0, -0.464723, 0, 1, 0, 0.464723, 0, 0.885456, 4.64723, 0, -8.85456)
scene_base = NodePath("../..")
scene = "res://scenes/swim_demo/swim_demo.tscn"
title = ExtResource("25_axwbd")

[node name="SettingsUI" parent="." index="3" instance=ExtResource("26_0uyxa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1.5)
camera = NodePath("../XROrigin3D/XRCamera3D")
Expand Down
24 changes: 24 additions & 0 deletions scenes/swim_demo/objects/instructions.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[gd_scene load_steps=5 format=3 uid="uid://cap4i60th5v7v"]

[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="1_ppayj"]
[ext_resource type="PackedScene" uid="uid://b45jxqo2nss1h" path="res://scenes/swim_demo/objects/instructions_2d.tscn" id="2_m8jyc"]
[ext_resource type="Material" path="res://assets/wahooney.itch.io/brown_grid_triplanar.tres" id="3_corps"]

[sub_resource type="BoxMesh" id="1"]
material = ExtResource("3_corps")
size = Vector3(4.2, 2.7, 0.1)

[node name="Instructions" type="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4, -4)

[node name="Viewport2Din3D" parent="." instance=ExtResource("1_ppayj")]
screen_size = Vector2(4, 2.5)
viewport_size = Vector2(400, 250)
unshaded = true
scene = ExtResource("2_m8jyc")
update_mode = 0
collision_layer = 0

[node name="MeshInstance" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.1)
mesh = SubResource("1")
36 changes: 36 additions & 0 deletions scenes/swim_demo/objects/instructions_2d.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[gd_scene format=3 uid="uid://b45jxqo2nss1h"]

[node name="Instructions" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
offset_right = 400.0
offset_bottom = 250.0
color = Color(0, 0, 0, 0.87451)

[node name="Description" type="RichTextLabel" parent="."]
layout_mode = 0
offset_left = 10.0
offset_top = 10.0
offset_right = 390.0
offset_bottom = 240.0
theme_override_constants/line_separation = -3
theme_override_font_sizes/normal_font_size = 12
text = "Swim Demo
This scene demonstrates example swimming. Advanced rendering options such as Volume Fog can be added based on the choice of renderer.
> Left Controller:
- Direct Movement: U/D/L/R Joystick
- Flight Movement: U/D/L/R Joystick
> Right Controller:
- Direct Movement: U/D Joystick
- Turning: L/R Joystick
"
16 changes: 16 additions & 0 deletions scenes/swim_demo/objects/swim_area.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extends Area3D

func _on_body_entered(body):
if body is XRToolsPlayerBody:
if !body.get_parent().has_node("MovementFlight"):
printerr("Flight Area tried to find MovementFlight, but it could not...")
return
body.get_parent().get_node("MovementFlight").set_flying(true)


func _on_body_exited(body):
if body is XRToolsPlayerBody:
if !body.get_parent().has_node("MovementFlight"):
printerr("Flight Area tried to find MovementFlight, but it could not...")
return
body.get_parent().get_node("MovementFlight").set_flying(false)
Loading

0 comments on commit f0ad7c8

Please sign in to comment.