Skip to content

Commit a7a9ebf

Browse files
Added basic swim demo from work performed by pietru2004.
Added swim demo into main menu level. Co-Authored-By: pietru2004 <pietru2004@users.noreply.github.com>
1 parent ba5641f commit a7a9ebf

File tree

9 files changed

+392
-12
lines changed

9 files changed

+392
-12
lines changed

scenes/main_menu/main_menu_level.tscn

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=38 format=3 uid="uid://utga61rlgb3t"]
1+
[gd_scene load_steps=39 format=3 uid="uid://utga61rlgb3t"]
22

33
[ext_resource type="PackedScene" uid="uid://qbmx03iibuuu" path="res://addons/godot-xr-tools/staging/scene_base.tscn" id="1"]
44
[ext_resource type="Script" path="res://scenes/main_menu/main_menu_level.gd" id="2_taoax"]
@@ -19,6 +19,7 @@
1919
[ext_resource type="Texture2D" uid="uid://ny4n43p3e3du" path="res://scenes/pickable_demo/pickable_demo.png" id="22"]
2020
[ext_resource type="PackedScene" uid="uid://bq86r4yll8po" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/left_fullglove_low.tscn" id="23_pr05t"]
2121
[ext_resource type="PackedScene" uid="uid://xqimcf20s2jp" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/right_fullglove_low.tscn" id="25_2b81d"]
22+
[ext_resource type="Texture2D" uid="uid://dd2u7l7q2de65" path="res://scenes/swim_demo/swim demo.png" id="25_5hl33"]
2223
[ext_resource type="Texture2D" uid="uid://bbe7o7pdq38m2" path="res://scenes/poke_demo/poke_demo.png" id="25_rg3rn"]
2324
[ext_resource type="PackedScene" uid="uid://3bsyhd7ehoa1" path="res://scenes/main_menu/objects/settings_ui.tscn" id="26_0uyxa"]
2425
[ext_resource type="Material" uid="uid://bhiiya7ow6h8v" path="res://addons/godot-xr-tools/hands/materials/labglove.material" id="26_id1x7"]
@@ -186,71 +187,77 @@ scene = "res://scenes/basic_movement_demo/basic_movement_demo.tscn"
186187
title = ExtResource("10")
187188

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

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

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

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

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

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

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

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

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

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

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

255+
[node name="ToSwimDemo" parent="Demos" index="12" instance=ExtResource("9")]
256+
transform = Transform3D(0.885456, 0, -0.464723, 0, 1, 0, 0.464723, 0, 0.885456, 4.64723, 0, -8.85456)
257+
scene_base = NodePath("../..")
258+
scene = "res://scenes/swim_demo/swim_demo.tscn"
259+
title = ExtResource("25_5hl33")
260+
254261
[node name="SettingsUI" parent="." index="3" instance=ExtResource("26_0uyxa")]
255262
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1.5)
256263
camera = NodePath("../XROrigin3D/XRCamera3D")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[gd_scene load_steps=5 format=3 uid="uid://cap4i60th5v7v"]
2+
3+
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="1_ppayj"]
4+
[ext_resource type="PackedScene" uid="uid://b45jxqo2nss1h" path="res://scenes/swim_demo/objects/instructions_2d.tscn" id="2_m8jyc"]
5+
[ext_resource type="Material" path="res://assets/wahooney.itch.io/brown_grid_triplanar.tres" id="3_corps"]
6+
7+
[sub_resource type="BoxMesh" id="1"]
8+
material = ExtResource("3_corps")
9+
size = Vector3(4.2, 2.7, 0.1)
10+
11+
[node name="Instructions" type="Node3D"]
12+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4, -4)
13+
14+
[node name="Viewport2Din3D" parent="." instance=ExtResource("1_ppayj")]
15+
screen_size = Vector2(4, 2.5)
16+
viewport_size = Vector2(400, 250)
17+
unshaded = true
18+
scene = ExtResource("2_m8jyc")
19+
update_mode = 0
20+
collision_layer = 0
21+
22+
[node name="MeshInstance" type="MeshInstance3D" parent="."]
23+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.1)
24+
mesh = SubResource("1")
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[gd_scene format=3 uid="uid://b45jxqo2nss1h"]
2+
3+
[node name="Instructions" type="Control"]
4+
layout_mode = 3
5+
anchors_preset = 15
6+
anchor_right = 1.0
7+
anchor_bottom = 1.0
8+
grow_horizontal = 2
9+
grow_vertical = 2
10+
11+
[node name="ColorRect" type="ColorRect" parent="."]
12+
layout_mode = 1
13+
offset_right = 400.0
14+
offset_bottom = 250.0
15+
color = Color(0, 0, 0, 0.87451)
16+
17+
[node name="Description" type="RichTextLabel" parent="."]
18+
layout_mode = 0
19+
offset_left = 10.0
20+
offset_top = 10.0
21+
offset_right = 390.0
22+
offset_bottom = 240.0
23+
theme_override_constants/line_separation = -3
24+
theme_override_font_sizes/normal_font_size = 12
25+
text = "Swim Demo
26+
27+
This scene demonstrates example swimming. Advanced rendering options such as Volume Fog can be added based on the choice of renderer.
28+
29+
> Left Controller:
30+
- Direct Movement: U/D/L/R Joystick
31+
- Flight Movement: U/D/L/R Joystick
32+
33+
> Right Controller:
34+
- Direct Movement: U/D Joystick
35+
- Turning: L/R Joystick
36+
"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
extends Area3D
2+
3+
func _on_body_entered(body):
4+
if body is XRToolsPlayerBody:
5+
if !body.get_parent().has_node("MovementFlight"):
6+
printerr("Flight Area tried to find MovementFlight, but it could not...")
7+
return
8+
body.get_parent().get_node("MovementFlight").set_flying(true)
9+
10+
11+
func _on_body_exited(body):
12+
if body is XRToolsPlayerBody:
13+
if !body.get_parent().has_node("MovementFlight"):
14+
printerr("Flight Area tried to find MovementFlight, but it could not...")
15+
return
16+
body.get_parent().get_node("MovementFlight").set_flying(false)
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
[gd_scene load_steps=6 format=3 uid="uid://bjuel0yobnb7l"]
2+
3+
[ext_resource type="Material" path="res://assets/wahooney.itch.io/green_grid_triplanar.tres" id="1_isyto"]
4+
[ext_resource type="Material" path="res://assets/wahooney.itch.io/brown_grid_triplanar.tres" id="2_bp8ee"]
5+
6+
[sub_resource type="QuadMesh" id="7"]
7+
size = Vector2(96, 96)
8+
9+
[sub_resource type="QuadMesh" id="8"]
10+
size = Vector2(96, 16)
11+
12+
[sub_resource type="BoxShape3D" id="4"]
13+
size = Vector3(100, 16, 2)
14+
15+
[node name="SwimMap" type="Node3D"]
16+
17+
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
18+
transform = Transform3D(0.866025, -0.321394, 0.383022, 0, 0.766044, 0.642788, -0.5, -0.55667, 0.663414, 0, 5, 0)
19+
light_energy = 0.8
20+
21+
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="."]
22+
use_collision = true
23+
24+
[node name="CSGMesh3D" type="CSGMesh3D" parent="CSGCombiner3D"]
25+
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0)
26+
mesh = SubResource("7")
27+
material = ExtResource("1_isyto")
28+
29+
[node name="CSGBox3D" type="CSGBox3D" parent="CSGCombiner3D"]
30+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, -12)
31+
size = Vector3(8, 4, 16)
32+
material = ExtResource("2_bp8ee")
33+
34+
[node name="CSGBox3D2" type="CSGBox3D" parent="CSGCombiner3D"]
35+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.7, -12)
36+
operation = 2
37+
size = Vector3(6, 3.6, 14)
38+
material = ExtResource("2_bp8ee")
39+
40+
[node name="CSGBox3D3" type="CSGBox3D" parent="CSGCombiner3D"]
41+
transform = Transform3D(0.642788, 0.766045, 0, -0.766045, 0.642788, 0, 0, 0, 1, 3.1, 0, -12)
42+
operation = 2
43+
size = Vector3(1, 1.4, 14)
44+
material = ExtResource("2_bp8ee")
45+
46+
[node name="CSGBox3D4" type="CSGBox3D" parent="CSGCombiner3D"]
47+
transform = Transform3D(0.766045, 0.642788, 0, -0.642788, 0.766045, 0, 0, 0, 1, -3.1, 0, -12)
48+
operation = 2
49+
size = Vector3(1.4, 1, 14)
50+
material = ExtResource("2_bp8ee")
51+
52+
[node name="CSGBox3D5" type="CSGBox3D" parent="CSGCombiner3D"]
53+
transform = Transform3D(-3.09086e-08, -3.09086e-08, -1, -0.766045, 0.642788, 3.8097e-09, 0.642788, 0.766045, -4.35451e-08, -1.31134e-07, 0, -4.9)
54+
operation = 2
55+
size = Vector3(1, 1.4, 6)
56+
material = ExtResource("2_bp8ee")
57+
58+
[node name="CSGBox3D6" type="CSGBox3D" parent="CSGCombiner3D"]
59+
transform = Transform3D(-3.09086e-08, -3.09086e-08, -1, -0.642788, 0.766045, -3.8097e-09, 0.766045, 0.642788, -4.35451e-08, 1.31134e-07, 0, -19.1)
60+
operation = 2
61+
size = Vector3(1.4, 1, 6)
62+
material = ExtResource("2_bp8ee")
63+
64+
[node name="Wall1" type="StaticBody3D" parent="."]
65+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -48)
66+
67+
[node name="MeshInstance3D" type="MeshInstance3D" parent="Wall1"]
68+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 0)
69+
mesh = SubResource("8")
70+
skeleton = NodePath("../..")
71+
surface_material_override/0 = ExtResource("1_isyto")
72+
73+
[node name="CollisionShape3D" type="CollisionShape3D" parent="Wall1"]
74+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, -1)
75+
shape = SubResource("4")
76+
77+
[node name="Wall2" type="StaticBody3D" parent="."]
78+
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 48, 0, 0)
79+
80+
[node name="MeshInstance3D" type="MeshInstance3D" parent="Wall2"]
81+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 0)
82+
mesh = SubResource("8")
83+
skeleton = NodePath("../..")
84+
surface_material_override/0 = ExtResource("1_isyto")
85+
86+
[node name="CollisionShape3D" type="CollisionShape3D" parent="Wall2"]
87+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, -1)
88+
shape = SubResource("4")
89+
90+
[node name="Wall3" type="StaticBody3D" parent="."]
91+
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 48)
92+
93+
[node name="MeshInstance3D" type="MeshInstance3D" parent="Wall3"]
94+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 0)
95+
mesh = SubResource("8")
96+
skeleton = NodePath("../..")
97+
surface_material_override/0 = ExtResource("1_isyto")
98+
99+
[node name="CollisionShape3D" type="CollisionShape3D" parent="Wall3"]
100+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, -1)
101+
shape = SubResource("4")
102+
103+
[node name="Wall4" type="StaticBody3D" parent="."]
104+
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -48, 0, 0)
105+
106+
[node name="MeshInstance3D" type="MeshInstance3D" parent="Wall4"]
107+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 0)
108+
mesh = SubResource("8")
109+
skeleton = NodePath("../..")
110+
surface_material_override/0 = ExtResource("1_isyto")
111+
112+
[node name="CollisionShape3D" type="CollisionShape3D" parent="Wall4"]
113+
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, -1)
114+
shape = SubResource("4")
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
shader_type spatial;
2+
render_mode cull_disabled;
3+
4+
// Water material properties
5+
uniform vec3 albedo : source_color = vec3(0.0, 0.0, 0.4);
6+
uniform float metallic : hint_range(0.0, 1.0) = 0.0;
7+
uniform float roughness : hint_range(0.0, 1.0) = 0.02;
8+
uniform float alpha = 0.7;
9+
10+
// Noise scale and texture
11+
uniform float scale = 0.05;
12+
uniform sampler2D normal_texture;
13+
14+
void fragment() {
15+
// Get the world X/Z coordinates
16+
vec2 world = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xz * scale;
17+
18+
// Calculate two time-varying offsets to the noise texture
19+
vec2 offset1 = vec2(0.05, 0.0) * sin(TIME / 5.0 * PI);
20+
vec2 offset2 = vec2(0.0, 0.05) * cos(TIME / 5.0 * PI);
21+
22+
// Sample the noise texture at the two offsets and blend
23+
vec3 normal1v = texture(normal_texture, world + offset1).rgb;
24+
vec3 normal2v = texture(normal_texture, world + offset2).rgb;
25+
vec3 normal = mix(normal1v, normal2v, 0.5);
26+
27+
// Set the outputs
28+
ALBEDO = albedo;
29+
METALLIC = metallic;
30+
ROUGHNESS = roughness;
31+
NORMAL_MAP = normal;
32+
ALPHA = alpha;
33+
}

scenes/swim_demo/swim demo.png

3.68 KB
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://dd2u7l7q2de65"
6+
path.s3tc="res://.godot/imported/swim demo.png-68e418131c0f315222da038696c9d228.s3tc.ctex"
7+
path.etc2="res://.godot/imported/swim demo.png-68e418131c0f315222da038696c9d228.etc2.ctex"
8+
metadata={
9+
"imported_formats": ["s3tc_bptc", "etc2_astc"],
10+
"vram_texture": true
11+
}
12+
13+
[deps]
14+
15+
source_file="res://scenes/swim_demo/swim demo.png"
16+
dest_files=["res://.godot/imported/swim demo.png-68e418131c0f315222da038696c9d228.s3tc.ctex", "res://.godot/imported/swim demo.png-68e418131c0f315222da038696c9d228.etc2.ctex"]
17+
18+
[params]
19+
20+
compress/mode=2
21+
compress/high_quality=false
22+
compress/lossy_quality=0.7
23+
compress/hdr_compression=1
24+
compress/normal_map=0
25+
compress/channel_pack=0
26+
mipmaps/generate=true
27+
mipmaps/limit=-1
28+
roughness/mode=0
29+
roughness/src_normal=""
30+
process/fix_alpha_border=true
31+
process/premult_alpha=false
32+
process/normal_map_invert_y=false
33+
process/hdr_as_srgb=false
34+
process/hdr_clamp_exposure=false
35+
process/size_limit=0
36+
detect_3d/compress_to=0

0 commit comments

Comments
 (0)