Skip to content

Commit

Permalink
Move Pushup view to a self contained node
Browse files Browse the repository at this point in the history
  • Loading branch information
mgschwan committed Jan 20, 2021
1 parent 75305c2 commit 88c5e60
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 45 deletions.
21 changes: 0 additions & 21 deletions godot_project/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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 )

Expand Down
5 changes: 3 additions & 2 deletions godot_project/VRScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions godot_project/scenes/Level.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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"]
Expand Down
40 changes: 40 additions & 0 deletions godot_project/scenes/PushupViewport.tscn
Original file line number Diff line number Diff line change
@@ -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 )
21 changes: 11 additions & 10 deletions godot_project/scripts/GameVariables.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -191,7 +192,7 @@ var exercise_collections = [
},
{"setting":"game/exercise/strength_focus",
"value": false,
"description": "Cardio Focus"
"description": "Strength Focus"
},
],
[
Expand Down Expand Up @@ -229,7 +230,7 @@ var exercise_collections = [
},
{"setting":"game/exercise/strength_focus",
"value": false,
"description": "Cardio Focus"
"description": "Strength Focus"
},
],
[
Expand All @@ -251,7 +252,7 @@ var exercise_collections = [
},
{"setting":"game/exercise/strength_focus",
"value": false,
"description": "Cardio Focus"
"description": "Strength Focus"
},
], [
{"setting":"game/exercise/squat",
Expand Down Expand Up @@ -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 },
},
Expand Down Expand Up @@ -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 },
},
Expand Down
10 changes: 5 additions & 5 deletions godot_project/scripts/Level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
7 changes: 7 additions & 0 deletions godot_project/scripts/PushupViewport.gd
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 88c5e60

Please sign in to comment.