Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added basic swim demo from work performed by pietru2004. #435

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 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,6 +19,7 @@
[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_5hl33"]
[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"]
Expand Down Expand Up @@ -186,71 +187,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="ToSwimDemo" 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_5hl33")

[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)
114 changes: 114 additions & 0 deletions scenes/swim_demo/objects/swim_map.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
[gd_scene load_steps=6 format=3 uid="uid://bjuel0yobnb7l"]

[ext_resource type="Material" path="res://assets/wahooney.itch.io/green_grid_triplanar.tres" id="1_isyto"]
[ext_resource type="Material" path="res://assets/wahooney.itch.io/brown_grid_triplanar.tres" id="2_bp8ee"]

[sub_resource type="QuadMesh" id="7"]
size = Vector2(96, 96)

[sub_resource type="QuadMesh" id="8"]
size = Vector2(96, 16)

[sub_resource type="BoxShape3D" id="4"]
size = Vector3(100, 16, 2)

[node name="SwimMap" type="Node3D"]

[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.866025, -0.321394, 0.383022, 0, 0.766044, 0.642788, -0.5, -0.55667, 0.663414, 0, 5, 0)
light_energy = 0.8

[node name="CSGCombiner3D" type="CSGCombiner3D" parent="."]
use_collision = true

[node name="CSGMesh3D" type="CSGMesh3D" parent="CSGCombiner3D"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0)
mesh = SubResource("7")
material = ExtResource("1_isyto")

[node name="CSGBox3D" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, -12)
size = Vector3(8, 4, 16)
material = ExtResource("2_bp8ee")

[node name="CSGBox3D2" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.7, -12)
operation = 2
size = Vector3(6, 3.6, 14)
material = ExtResource("2_bp8ee")

[node name="CSGBox3D3" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.642788, 0.766045, 0, -0.766045, 0.642788, 0, 0, 0, 1, 3.1, 0, -12)
operation = 2
size = Vector3(1, 1.4, 14)
material = ExtResource("2_bp8ee")

[node name="CSGBox3D4" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.766045, 0.642788, 0, -0.642788, 0.766045, 0, 0, 0, 1, -3.1, 0, -12)
operation = 2
size = Vector3(1.4, 1, 14)
material = ExtResource("2_bp8ee")

[node name="CSGBox3D5" type="CSGBox3D" parent="CSGCombiner3D"]
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)
operation = 2
size = Vector3(1, 1.4, 6)
material = ExtResource("2_bp8ee")

[node name="CSGBox3D6" type="CSGBox3D" parent="CSGCombiner3D"]
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)
operation = 2
size = Vector3(1.4, 1, 6)
material = ExtResource("2_bp8ee")

[node name="Wall1" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -48)

[node name="MeshInstance3D" type="MeshInstance3D" parent="Wall1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 0)
mesh = SubResource("8")
skeleton = NodePath("../..")
surface_material_override/0 = ExtResource("1_isyto")

[node name="CollisionShape3D" type="CollisionShape3D" parent="Wall1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, -1)
shape = SubResource("4")

[node name="Wall2" type="StaticBody3D" parent="."]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 48, 0, 0)

[node name="MeshInstance3D" type="MeshInstance3D" parent="Wall2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 0)
mesh = SubResource("8")
skeleton = NodePath("../..")
surface_material_override/0 = ExtResource("1_isyto")

[node name="CollisionShape3D" type="CollisionShape3D" parent="Wall2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, -1)
shape = SubResource("4")

[node name="Wall3" type="StaticBody3D" parent="."]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 48)

[node name="MeshInstance3D" type="MeshInstance3D" parent="Wall3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 0)
mesh = SubResource("8")
skeleton = NodePath("../..")
surface_material_override/0 = ExtResource("1_isyto")

[node name="CollisionShape3D" type="CollisionShape3D" parent="Wall3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, -1)
shape = SubResource("4")

[node name="Wall4" type="StaticBody3D" parent="."]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -48, 0, 0)

[node name="MeshInstance3D" type="MeshInstance3D" parent="Wall4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, 0)
mesh = SubResource("8")
skeleton = NodePath("../..")
surface_material_override/0 = ExtResource("1_isyto")

[node name="CollisionShape3D" type="CollisionShape3D" parent="Wall4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 8, -1)
shape = SubResource("4")
33 changes: 33 additions & 0 deletions scenes/swim_demo/objects/water_shader.gdshader
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
shader_type spatial;
render_mode cull_disabled;

// Water material properties
uniform vec3 albedo : source_color = vec3(0.0, 0.0, 0.4);
uniform float metallic : hint_range(0.0, 1.0) = 0.0;
uniform float roughness : hint_range(0.0, 1.0) = 0.02;
uniform float alpha = 0.7;

// Noise scale and texture
uniform float scale = 0.05;
uniform sampler2D normal_texture;

void fragment() {
// Get the world X/Z coordinates
vec2 world = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xz * scale;

// Calculate two time-varying offsets to the noise texture
vec2 offset1 = vec2(0.05, 0.0) * sin(TIME / 5.0 * PI);
vec2 offset2 = vec2(0.0, 0.05) * cos(TIME / 5.0 * PI);

// Sample the noise texture at the two offsets and blend
vec3 normal1v = texture(normal_texture, world + offset1).rgb;
vec3 normal2v = texture(normal_texture, world + offset2).rgb;
vec3 normal = mix(normal1v, normal2v, 0.5);

// Set the outputs
ALBEDO = albedo;
METALLIC = metallic;
ROUGHNESS = roughness;
NORMAL_MAP = normal;
ALPHA = alpha;
}
Binary file added scenes/swim_demo/swim demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions scenes/swim_demo/swim demo.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dd2u7l7q2de65"
path.s3tc="res://.godot/imported/swim demo.png-68e418131c0f315222da038696c9d228.s3tc.ctex"
path.etc2="res://.godot/imported/swim demo.png-68e418131c0f315222da038696c9d228.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}

[deps]

source_file="res://scenes/swim_demo/swim demo.png"
dest_files=["res://.godot/imported/swim demo.png-68e418131c0f315222da038696c9d228.s3tc.ctex", "res://.godot/imported/swim demo.png-68e418131c0f315222da038696c9d228.etc2.ctex"]

[params]

compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0
Loading