From 88c5e606f3fba5524397a5142c38300f97c2aac6 Mon Sep 17 00:00:00 2001 From: developer Date: Wed, 20 Jan 2021 16:20:39 +0100 Subject: [PATCH] Move Pushup view to a self contained node --- godot_project/Main.tscn | 21 ------------- godot_project/VRScene.gd | 5 +-- godot_project/scenes/Level.tscn | 10 ++---- godot_project/scenes/PushupViewport.tscn | 40 ++++++++++++++++++++++++ godot_project/scripts/GameVariables.gd | 21 +++++++------ godot_project/scripts/Level.gd | 10 +++--- godot_project/scripts/PushupViewport.gd | 7 +++++ 7 files changed, 69 insertions(+), 45 deletions(-) create mode 100644 godot_project/scenes/PushupViewport.tscn create mode 100644 godot_project/scripts/PushupViewport.gd diff --git a/godot_project/Main.tscn b/godot_project/Main.tscn index bc5fdb6..2bbe457 100644 --- a/godot_project/Main.tscn +++ b/godot_project/Main.tscn @@ -57,22 +57,6 @@ tracks/0/keys = { [node name="VRScene" type="Spatial"] script = ExtResource( 1 ) -[node name="PushupViewport" type="Viewport" parent="."] -size = Vector2( 1024, 512 ) -handle_input_locally = false -msaa = 6 -render_target_v_flip = true -gui_disable_input = true -shadow_atlas_quad_0 = 0 -shadow_atlas_quad_1 = 0 -shadow_atlas_quad_2 = 0 -shadow_atlas_quad_3 = 0 - -[node name="Camera" type="Camera" parent="PushupViewport"] -transform = Transform( 1, 0, 0, 0, 0.934857, -0.355025, 0, 0.355025, 0.934857, 0, 0, 0 ) -current = true -far = 300.0 - [node name="ARVROrigin" type="ARVROrigin" parent="."] [node name="ARVRCamera" type="ARVRCamera" parent="ARVROrigin"] @@ -84,11 +68,6 @@ script = ExtResource( 14 ) is_local = true transform_parent = true -[node name="RemoteTransform" type="RemoteTransform" parent="ARVROrigin/ARVRCamera"] -transform = Transform( 1, 0, 0, 0, -0.0153054, -0.999883, 0, 0.999883, -0.0153054, 0, 0, 0 ) -remote_path = NodePath("../../../PushupViewport/Camera") -update_rotation = false - [node name="AreaHead" type="Area" parent="ARVROrigin/ARVRCamera"] script = ExtResource( 9 ) diff --git a/godot_project/VRScene.gd b/godot_project/VRScene.gd index 2f50fae..badcd1b 100644 --- a/godot_project/VRScene.gd +++ b/godot_project/VRScene.gd @@ -254,7 +254,7 @@ func initialize(): GameVariables.vr_mode = false cam = get_node("ARVROrigin/ARVRCamera") - + GameVariables.player_camera = cam ProjectSettings.set("game/external_songs", ProjectSettings.get("application/config/pc_music_directory")) print (ProjectSettings.get("game/external_songs")) @@ -651,7 +651,8 @@ func _on_Area_level_selected(filename, diff, num): level.connect("level_finished",self,"_on_level_finished") level.connect("level_finished_manually",self,"_on_level_finished_manually") levelselect.queue_free() - add_child(level) + level.name = "Level" + add_child(level,true) if not GameVariables.vr_mode: demo_mode_player_height = GameVariables.player_height diff --git a/godot_project/scenes/Level.tscn b/godot_project/scenes/Level.tscn index dcbe346..2d7bbb9 100644 --- a/godot_project/scenes/Level.tscn +++ b/godot_project/scenes/Level.tscn @@ -8,6 +8,7 @@ [ext_resource path="res://InfoBox.tscn" type="PackedScene" id=6] [ext_resource path="res://scripts/DelayedButton.gd" type="Script" id=7] [ext_resource path="res://spawn_timer.gd" type="Script" id=8] +[ext_resource path="res://scenes/PushupViewport.tscn" type="PackedScene" id=9] [ext_resource path="res://assets/vrworkout_logo_cracked_noise.jpg" type="Texture" id=11] [ext_resource path="res://PointIndicatorOrigin.tscn" type="PackedScene" id=13] [ext_resource path="res://RetractableMat.tscn" type="PackedScene" id=14] @@ -77,9 +78,6 @@ extents = Vector3( 0.311419, 0.0926839, 0.161588 ) albedo_color = Color( 0.94902, 0.937255, 0.937255, 1 ) albedo_texture = ExtResource( 11 ) -[sub_resource type="PlaneMesh" id=14] -size = Vector2( 0.22, 0.13 ) - [node name="Main" type="Spatial"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0225873, -0.0546217, 0.0125537 ) script = ExtResource( 20 ) @@ -226,10 +224,8 @@ visible = false [node name="SpectrumDisplay" parent="." instance=ExtResource( 3 )] transform = Transform( 0.2, 0, 0, 0, -0.168573, -0.107625, 0, 0.107625, -0.168573, -2.18058, 3.36426, -11.4019 ) -[node name="PushupView" type="MeshInstance" parent="."] -transform = Transform( 10, 0, 0, 0, 8.50029, -5.53584, 0, 5.07871, 8.45678, -0.019583, -0.28405, -0.772499 ) -mesh = SubResource( 14 ) -material/0 = null +[node name="PushupView" parent="." instance=ExtResource( 9 )] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.313975, -0.77 ) [connection signal="timeout" from="spawn_timer" to="spawn_timer" method="_on_spawn_timer_timeout"] [connection signal="streak_changed" from="cue_emitter" to="." method="_on_cue_emitter_streak_changed"] diff --git a/godot_project/scenes/PushupViewport.tscn b/godot_project/scenes/PushupViewport.tscn new file mode 100644 index 0000000..f8a0f0a --- /dev/null +++ b/godot_project/scenes/PushupViewport.tscn @@ -0,0 +1,40 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://scripts/PushupViewport.gd" type="Script" id=1] + +[sub_resource type="PlaneMesh" id=1] +size = Vector2( 2.2, 1.3 ) + +[sub_resource type="ViewportTexture" id=2] +flags = 12 +viewport_path = NodePath("PushupViewport") + +[sub_resource type="SpatialMaterial" id=3] +resource_local_to_scene = true +flags_unshaded = true +albedo_texture = SubResource( 2 ) + +[node name="Spatial" type="Spatial"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.2, -0.77 ) + +[node name="PushupViewport" type="Viewport" parent="."] +size = Vector2( 1024, 512 ) +handle_input_locally = false +msaa = 6 +render_target_v_flip = true +gui_disable_input = true +shadow_atlas_quad_0 = 0 +shadow_atlas_quad_1 = 0 +shadow_atlas_quad_2 = 0 +shadow_atlas_quad_3 = 0 +script = ExtResource( 1 ) + +[node name="Camera" type="Camera" parent="PushupViewport"] +transform = Transform( 1, 0, 0, 0, 0.934857, -0.355025, 0, 0.355025, 0.934857, 0, 0, 0 ) +current = true +far = 300.0 + +[node name="PushupView" type="MeshInstance" parent="."] +transform = Transform( 1, 0, 0, 0, 0.85896, -0.512043, 0, 0.512043, 0.85896, 0, 0, 0 ) +mesh = SubResource( 1 ) +material/0 = SubResource( 3 ) diff --git a/godot_project/scripts/GameVariables.gd b/godot_project/scripts/GameVariables.gd index fe525d6..99b5d7e 100644 --- a/godot_project/scripts/GameVariables.gd +++ b/godot_project/scripts/GameVariables.gd @@ -27,6 +27,7 @@ var ar_mode = false var multiplayer_server = ProjectSettings.get("application/config/room_server") +var player_camera = null var player_height = 1.8 @@ -191,7 +192,7 @@ var exercise_collections = [ }, {"setting":"game/exercise/strength_focus", "value": false, - "description": "Cardio Focus" + "description": "Strength Focus" }, ], [ @@ -229,7 +230,7 @@ var exercise_collections = [ }, {"setting":"game/exercise/strength_focus", "value": false, - "description": "Cardio Focus" + "description": "Strength Focus" }, ], [ @@ -251,7 +252,7 @@ var exercise_collections = [ }, {"setting":"game/exercise/strength_focus", "value": false, - "description": "Cardio Focus" + "description": "Strength Focus" }, ], [ {"setting":"game/exercise/squat", @@ -293,10 +294,10 @@ var exercise_model = { "cardio": { "exercise_state_model": { CueState.STAND: { CueState.SQUAT: 10, CueState.PUSHUP: 10, CueState.CRUNCH: 10, CueState.JUMP: 10, CueState.BURPEE: 10, CueState.SPRINT: 10}, CueState.SQUAT: { CueState.STAND: 10, CueState.PUSHUP: 10, CueState.CRUNCH: 10, CueState.SPRINT: 10}, - CueState.PUSHUP: { CueState.STAND: 10, CueState.SQUAT: 10, CueState.BURPEE: 10}, - CueState.CRUNCH: { CueState.STAND: 10, CueState.SQUAT: 10}, - CueState.JUMP: {CueState.STAND: 50, CueState.BURPEE: 10}, - CueState.BURPEE: {CueState.STAND: 50}, + CueState.PUSHUP: { CueState.STAND: 10, CueState.SQUAT: 10, CueState.BURPEE: 10, CueState.SPRINT: 10}, + CueState.CRUNCH: { CueState.STAND: 10, CueState.SQUAT: 10, CueState.SPRINT: 10, CueState.JUMP: 5}, + CueState.JUMP: {CueState.STAND: 50, CueState.BURPEE: 10, CueState.SQUAT: 10, CueState.CRUNCH: 10}, + CueState.BURPEE: {CueState.STAND: 50, CueState.CRUNCH: 10, CueState.SQUAT: 10, CueState.PUSHUP: 10}, CueState.SPRINT: {CueState.STAND: 50, CueState.JUMP: 10, CueState.SQUAT: 10}, CueState.YOGA: { CueState.STAND: 50 }, }, @@ -326,9 +327,9 @@ var exercise_model = { "exercise_state_model": { CueState.STAND: { CueState.SQUAT: 20, CueState.PUSHUP: 20, CueState.CRUNCH: 5, CueState.JUMP: 1, CueState.BURPEE: 20, CueState.SPRINT: 1}, CueState.SQUAT: { CueState.STAND: 10, CueState.PUSHUP: 50, CueState.CRUNCH: 5, CueState.BURPEE: 10}, CueState.PUSHUP: { CueState.STAND: 10, CueState.SQUAT: 35, CueState.BURPEE: 10, CueState.CRUNCH: 10}, - CueState.CRUNCH: { CueState.PUSHUP: 25, CueState.SQUAT: 25}, - CueState.JUMP: {CueState.SQUAT: 50, CueState.PUSHUP: 25, CueState.BURPEE: 10}, - CueState.BURPEE: {CueState.SQUAT: 50, CueState.STAND: 45, CueState.PUSHUP: 5 }, + CueState.CRUNCH: { CueState.PUSHUP: 25, CueState.SQUAT: 25, CueState.JUMP: 10}, + CueState.JUMP: {CueState.SQUAT: 50, CueState.PUSHUP: 25, CueState.BURPEE: 10, CueState.CRUNCH: 10}, + CueState.BURPEE: {CueState.SQUAT: 50, CueState.STAND: 45, CueState.PUSHUP: 5, CueState.CRUNCH: 1 }, CueState.SPRINT: {CueState.SQUAT: 20, CueState.PUSHUP: 20, CueState.CRUNCH: 5, CueState.JUMP: 1, CueState.BURPEE: 20}, CueState.YOGA: { CueState.STAND: 50 }, }, diff --git a/godot_project/scripts/Level.gd b/godot_project/scripts/Level.gd index 5d74e6c..ae2e3e1 100644 --- a/godot_project/scripts/Level.gd +++ b/godot_project/scripts/Level.gd @@ -245,11 +245,11 @@ func _ready(): get_tree().get_current_scene().get_node("HeartRateReceiver").connect("heart_rate_received", self,"_on_HeartRateData") #Set up the safe pushup view - var mat = SpatialMaterial.new() - mat.albedo_texture = get_tree().get_current_scene().get_node("PushupViewport").get_texture() - mat.albedo_texture.flags = Texture.FLAG_FILTER - mat.flags_unshaded = true - get_node("PushupView").set_surface_material(0,mat) + #var mat = SpatialMaterial.new() + #mat.albedo_texture = get_tree().get_current_scene().get_node("PushupViewport").get_texture() + #mat.albedo_texture.flags = Texture.FLAG_FILTER + #mat.flags_unshaded = true + #get_node("PushupView").set_surface_material(0,mat) if not ProjectSettings.get("game/equalizer"): self.remove_child(get_node("SpectrumDisplay")) diff --git a/godot_project/scripts/PushupViewport.gd b/godot_project/scripts/PushupViewport.gd new file mode 100644 index 0000000..37bac2a --- /dev/null +++ b/godot_project/scripts/PushupViewport.gd @@ -0,0 +1,7 @@ +extends Viewport + +onready var camera = $Camera + +func _process(delta): + if GameVariables.player_camera: + $Camera.global_transform.origin = GameVariables.player_camera.global_transform.origin