Skip to content

Commit

Permalink
Add remote panel with welcome message
Browse files Browse the repository at this point in the history
  • Loading branch information
mgschwan committed Feb 23, 2021
1 parent 8e34958 commit b90a0b9
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 46 deletions.
1 change: 1 addition & 0 deletions godot_project/Area.gd
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ func _on_Area_body_exited(body):
if controller.is_left:
hand = "left"
body.end_hold(hand)

elif body.has_method("released_by_controller"):
body.released_by_controller(get_parent(), get_parent().get_parent().get_parent())
27 changes: 20 additions & 7 deletions godot_project/VRScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ func _enter_tree():
ProjectSettings.set("application/config/backend_server", "http://127.0.0.1:5000")


func connect_tracker_callbacks():
ARVRServer.connect("tracker_added",self,"_on_Tracker_added")
ARVRServer.connect("tracker_removed",self, "_on_Tracker_removed")



func initialize():
var available_interfaces = ARVRServer.get_interfaces();
for interface in available_interfaces:
Expand All @@ -274,7 +280,8 @@ func initialize():
print ("Oculus Mobile")
ProjectSettings.set("game/is_oculusquest", true)
ProjectSettings.set("game/external_songs", ProjectSettings.get("application/config/music_directory"))

connect_tracker_callbacks()

# the init config needs to be done before arvr_interface.initialize()
if (ovr_init_config):
ovr_init_config = ovr_init_config.new()
Expand All @@ -291,9 +298,12 @@ func initialize():
_initialize_OVR_API()

if ovr_performance:
print ("Set foveation performance level")
ovr_performance.set_foveation_level(4)
ovr_performance.set_enable_dynamic_foveation(true)
if GameVariables.FEATURE_FOVEATED_RENDERING:
ovr_performance.set_foveation_level(4)
ovr_performance.set_enable_dynamic_foveation(true)
else:
ovr_performance.set_foveation_level(0)
ovr_performance.set_enable_dynamic_foveation(false)
else:
print ("Can't set dynamic foveation")

Expand All @@ -309,6 +319,8 @@ func initialize():

elif arvr_oculus_interface:
print ("Oculus PC")
connect_tracker_callbacks()

if arvr_oculus_interface.initialize():
arvr_interface = arvr_oculus_interface
GameVariables.vr_mode = true
Expand All @@ -318,6 +330,8 @@ func initialize():
print ("Oculus PC ... done")
elif arvr_open_vr_interface:
print ("OpenVR")
connect_tracker_callbacks()

if arvr_open_vr_interface.initialize():
arvr_interface = arvr_open_vr_interface
get_viewport().arvr = true;
Expand All @@ -328,6 +342,8 @@ func initialize():
print ("OpenVR ... done")
elif arvr_webxr_interface:
print(" Found WebXR Interface.");
connect_tracker_callbacks()

arvr_webxr_interface.connect("session_supported", self, "_webxr_cb_session_supported")
arvr_webxr_interface.connect("session_started", self, "_webxr_cb_session_started")
arvr_webxr_interface.session_mode = 'immersive-vr'
Expand All @@ -343,9 +359,6 @@ func initialize():
cam.translation.y = demo_mode_player_height
cam.rotation.x = -0.4

if GameVariables.vr_mode:
ARVRServer.connect("tracker_added",self,"_on_Tracker_added")
ARVRServer.connect("tracker_removed",self, "_on_Tracker_removed")

print ("Initializing VR Interface ... done")

Expand Down
8 changes: 7 additions & 1 deletion godot_project/cue_h_obj.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[gd_scene load_steps=19 format=2]
[gd_scene load_steps=20 format=2]

[ext_resource path="res://models/Bezergreen.material" type="Material" id=1]
[ext_resource path="res://models/fist_right.obj" type="ArrayMesh" id=2]
[ext_resource path="res://cue_v_obj.gd" type="Script" id=3]
[ext_resource path="res://audio/dull_hit.wav" type="AudioStream" id=4]
[ext_resource path="res://TargetTimer.tscn" type="PackedScene" id=5]
[ext_resource path="res://models/black.material" type="Material" id=6]
[ext_resource path="res://models/green_ball_mat.material" type="Material" id=7]
Expand Down Expand Up @@ -285,4 +286,9 @@ transform = Transform( 0.03, 0, 0, 0, 0.03, 1.88745e-09, 0, -8.4639e-09, 0.05, 0
visible = false
mesh = SubResource( 10 )
material/0 = ExtResource( 9 )

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 4 )
volume_db = 0.2

[connection signal="animation_finished" from="Circle/AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]
18 changes: 14 additions & 4 deletions godot_project/cue_v_obj.gd
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ func create_path_dot():
node.mesh.radial_segments = 6
return node


func hold_time_complete ():
return 1000.0 * hold_time < OS.get_ticks_msec() - hold_start

var path_calculated = false
func _process(delta):
if not hit and is_hold_cue and holding:
Expand All @@ -69,12 +71,16 @@ func _process(delta):
if hold_time:
var angle = 2*PI * rd/1000.0*hold_time
hold_node.rotation.y = angle
if 1000.0 * hold_time < now - hold_start:
if hold_time_complete():
var hand = "right"
if cue_left:
hand = "left"
has_been_hit(hand)

if is_hold_cue:
var a = self.global_transform.origin
var b = GameVariables.vr_camera.global_transform.origin
var r = PI + atan2(a.x-b.x,a.z-b.z)
self.rotation.y = r

if not path_calculated and coupled_node:
var tw = get_node("tween")
Expand All @@ -97,6 +103,9 @@ func has_been_hit(hand = "unknown"):
if not has_node(hand):
points = -1
elif not hit:
if is_hold_cue and emit_sound:
emit_sound = false
$AudioStreamPlayer.play()
get_node("tween").stop_all()
var delta = abs(target_time - parent.current_playback_time)
points = parent.score_hit(delta, self)
Expand All @@ -116,7 +125,8 @@ func begin_hold(hand = "unknown"):
holding = true
hold_start = OS.get_ticks_msec()+hold_time_offset
hold_ring_player.play("ring", -1 , 1/hold_time)

return true
return false

func end_hold(hand = "unknown"):
if has_node(hand):
Expand Down
8 changes: 7 additions & 1 deletion godot_project/cue_v_obj.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[gd_scene load_steps=19 format=2]
[gd_scene load_steps=20 format=2]

[ext_resource path="res://cue_v_obj.gd" type="Script" id=1]
[ext_resource path="res://models/Berzerker.material" type="Material" id=2]
[ext_resource path="res://models/fist_left.obj" type="ArrayMesh" id=3]
[ext_resource path="res://TargetTimer.tscn" type="PackedScene" id=4]
[ext_resource path="res://audio/dull_hit.wav" type="AudioStream" id=5]
[ext_resource path="res://models/black.material" type="Material" id=6]
[ext_resource path="res://Hold_Ring.tscn" type="PackedScene" id=7]
[ext_resource path="res://models/super_white.material" type="Material" id=8]
Expand Down Expand Up @@ -286,4 +287,9 @@ transform = Transform( 0.03, -8.08722e-16, 4.37114e-09, 0, 0.006, -2.78182e-10,
visible = false
mesh = SubResource( 11 )
material/0 = ExtResource( 8 )

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 5 )
volume_db = 0.2

[connection signal="animation_finished" from="Circle/AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]
2 changes: 1 addition & 1 deletion godot_project/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ keystore/release="/home/developer/LVCC_Shared/michael/vrworkout/quest.keystore"
keystore/release_user="questkey"
keystore/release_password="gruluHuri43"
one_click_deploy/clear_previous_install=false
version/code=14
version/code=19
version/name="0.9.9q"
package/unique_name="org.godotengine.$genname"
package/name="VRWorkout"
Expand Down
7 changes: 6 additions & 1 deletion godot_project/scenes/Levelselect.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=69 format=2]
[gd_scene load_steps=70 format=2]

[ext_resource path="res://fonts/droid-sans/DroidSans.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://BlackTheme.theme" type="Theme" id=2]
Expand Down Expand Up @@ -41,6 +41,7 @@
[ext_resource path="res://scenes/AchievementDisplay.tscn" type="PackedScene" id=39]
[ext_resource path="res://scenes/NumberEntryWidget.tscn" type="PackedScene" id=40]
[ext_resource path="res://scenes/SimpleText.tscn" type="PackedScene" id=41]
[ext_resource path="res://scenes/WelcomePanel.tscn" type="PackedScene" id=42]

[sub_resource type="CylinderShape" id=1]
radius = 0.2
Expand Down Expand Up @@ -833,6 +834,10 @@ volume_db = -9.0
[node name="SideQuestPanel" parent="." instance=ExtResource( 38 )]
transform = Transform( 2.84861e-14, 1, -1.62921e-07, -1, 1.91069e-15, -2.06632e-07, -2.06632e-07, 1.62921e-07, 1, -3.31028, 1.9648, 0.0695851 )

[node name="WelcomePanel" parent="." instance=ExtResource( 42 )]
transform = Transform( -1.30337e-07, -0.767281, -0.226449, 0, 0.226449, -0.767281, 0.8, -1.25006e-07, -3.68932e-08, 0.787944, 0.445045, 0.00432485 )
server_url = "https://portal.vrworkout.at/fast/welcome.msg"

[connection signal="selected" from="Recenter" to="." method="_on_Recenter_selected"]
[connection signal="toggled" from="BPM/OverrideBeats" to="." method="_on_OverrideBeats_toggled"]
[connection signal="level_selected" from="SongSelector" to="." method="_on_SongSelector_level_selected"]
Expand Down
10 changes: 5 additions & 5 deletions godot_project/scripts/ExerciseBuilder.gd
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ func handle_pushup_cues(current_time, target_time, cue_emitter_state):
var x = 0.3 + rng.randf() * 0.25
var x_head = rng.randf() * cue_parameters[cue_emitter_state][CueSelector.HEAD]["xrange"] - cue_parameters[cue_emitter_state][CueSelector.HEAD]["xrange"]/2
var y_hand = 0.3 + rng.randf() * 0.4
var y_hold_hand = "0.3+%f*(0.5*ph-0.3)"%(rng.randf())

if pushup_state == PushupState.REGULAR:
create_and_attach_cue(current_time,"head", x_head, y_head, target_time)
Expand All @@ -642,18 +643,17 @@ func handle_pushup_cues(current_time, target_time, cue_emitter_state):
elif pushup_state == PushupState.RIGHT_HAND:
var n = create_and_attach_cue(current_time,"right", x,y_hand, target_time, -hand_cue_offset,0,"onehanded")
elif pushup_state == PushupState.LEFT_HAND_HOLD:
create_and_attach_cue(current_time,"left_hold", -x, y_hand, target_time, -hand_cue_offset, 0,"onehanded")
temporary_cue_space_extension += 0.3
create_and_attach_cue(current_time,"left_hold", "-ph*0.33", y_hold_hand, target_time, -hand_cue_offset, 0,"onehanded")
temporary_cue_space_extension += 0.5
elif pushup_state == PushupState.RIGHT_HAND_HOLD:
create_and_attach_cue(current_time,"right_hold", x, y_hand, target_time, -hand_cue_offset, 0,"onehanded")

create_and_attach_cue(current_time,"right_hold", "ph*0.33", y_hold_hand, target_time, -hand_cue_offset, 0,"onehanded")
temporary_cue_space_extension += 0.5
elif pushup_state == PushupState.LEFT_SIDEPLANK or pushup_state == PushupState.RIGHT_SIDEPLANK:
#side plank
x_head = 0
x = 0
y_head = "ph*0.5"
y_hand = "ph*0.84"

var hand_delay = 0.15
var dd_df = fly_distance/fly_time

Expand Down
17 changes: 15 additions & 2 deletions godot_project/scripts/GameVariables.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ var hit_player = null
var FEATURE_MULTIPLAYER = false

#Deactivate certain features to meet Oculus Store requirements
var FEATURE_STORE_COMPATIBILITY = true
var FEATURE_STORE_COMPATIBILITY = false

var FEATURE_FOVEATED_RENDERING = true


#############################################################################
Expand Down Expand Up @@ -257,6 +259,11 @@ var predefined_achievements = {
"achievement": "VALWINTERGAMESRANKB",
"partial": true
},
{"type": AchievementEvaluator.ACHIEVEMENT_TYPES.MIN_DIFFICULTY,
"limit": 0.5,
"achievement": "VALWINTERGAMESRANKB",
"partial": true
},
#RANK A
{"type": AchievementEvaluator.ACHIEVEMENT_TYPES.SCORE,
"limit": 95,
Expand Down Expand Up @@ -413,7 +420,13 @@ var exercise_model = {
CueState.SPRINT: {CueState.STAND: 50, CueState.JUMP: 10, CueState.SQUAT: 10},
CueState.YOGA: { CueState.STAND: 50 },
},
"pushup_state_model": { PushupState.REGULAR : { PushupState.LEFT_HAND : 15, PushupState.RIGHT_HAND: 15, PushupState.LEFT_SIDEPLANK: 10, PushupState.RIGHT_SIDEPLANK: 10},
# "pushup_state_model": { PushupState.REGULAR : { PushupState.LEFT_HAND : 15, PushupState.RIGHT_HAND: 15, PushupState.LEFT_SIDEPLANK: 10, PushupState.RIGHT_SIDEPLANK: 10},
# PushupState.LEFT_HAND : { PushupState.REGULAR: 25, PushupState.RIGHT_HAND: 5, PushupState.RIGHT_SIDEPLANK: 10},
# PushupState.RIGHT_HAND : { PushupState.REGULAR: 25, PushupState.LEFT_HAND: 5, PushupState.LEFT_SIDEPLANK: 10},
# PushupState.LEFT_SIDEPLANK : { PushupState.REGULAR: 20, PushupState.RIGHT_HAND: 10},
# PushupState.RIGHT_SIDEPLANK : { PushupState.REGULAR: 20, PushupState.LEFT_HAND: 10},
# },
"pushup_state_model": { PushupState.REGULAR : { PushupState.LEFT_HAND : 15, PushupState.RIGHT_HAND: 15, PushupState.LEFT_SIDEPLANK: 10, PushupState.RIGHT_SIDEPLANK: 10,PushupState.LEFT_HAND_HOLD: 15,PushupState.RIGHT_HAND_HOLD: 5},
PushupState.LEFT_HAND : { PushupState.REGULAR: 25, PushupState.RIGHT_HAND: 5, PushupState.LEFT_HAND_HOLD: 5, PushupState.RIGHT_SIDEPLANK: 10},
PushupState.RIGHT_HAND : { PushupState.REGULAR: 25, PushupState.LEFT_HAND: 5, PushupState.RIGHT_HAND_HOLD: 5, PushupState.LEFT_SIDEPLANK: 10},
PushupState.LEFT_SIDEPLANK : { PushupState.REGULAR: 20, PushupState.RIGHT_HAND: 10, PushupState.RIGHT_HAND_HOLD: 10},
Expand Down
9 changes: 8 additions & 1 deletion godot_project/scripts/Level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,14 @@ func create_and_attach_cue_actual(cue_data):
cue_node.extended = true
if cue_type in ["right_hold", "left_hold"]:
cue_node.is_hold_cue = true
cue_node.hold_time = 0.35
cue_node.hold_time = 0.25
var dd_dt = fly_distance/fly_time
if dd_dt > 0:
#Calculate the hold time based on the assumed arm length
cue_node.hold_time = 0.35*GameVariables.player_height / dd_dt
print ("Hold time %.4f %.f"%[cue_node.hold_time, GameVariables.player_height])


cue_node.target_time = target_time
cue_node.start_time = cue_emitter.current_playback_time
var actual_flytime = fly_time
Expand Down
7 changes: 3 additions & 4 deletions godot_project/scripts/SideQuestAPI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ var generic_post_result = {}


func sidequest_generic_post_request(endpoint, parameters):
print ("Start Generic POST Request")
#print ("Start Generic POST Request")
if current_api_state == API_STATE.IDLE:
generic_post_endpoint = endpoint
generic_post_parameters = parameters
Expand All @@ -361,7 +361,7 @@ func api_generic_post_request():
request_inprocess = true
request_type = SQ_API.GENERIC_POST_REQUEST
var url = "%s%s"%[api_endpoint,generic_post_endpoint]
print ("Posting to: %s (%s)"%[url,str(generic_post_parameters)])
#print ("Posting to: %s (%s)"%[url,str(generic_post_parameters)])
var ret = http_req.request(url, ["Authorization: Bearer %s"%sidequest_connection.get("access_token",""),"Content-Type: application/json"], true, HTTPClient.METHOD_POST, to_json(generic_post_parameters))
if ret != OK:
print ("Could not send request %s"%str(ret))
Expand All @@ -371,7 +371,7 @@ func api_generic_post_request():

#Disconnect all connections for a certain signal
func disconnect_all_connections(node, signal_):
print ("Disconnect: %s -> %s"%[str(node), str(signal_)])
#print ("Disconnect: %s -> %s"%[str(node), str(signal_)])
var connections = node.get_signal_connection_list(signal_)
for s in connections:
node.disconnect(s["signal"], s["target"], s["method"])
Expand All @@ -388,7 +388,6 @@ func store_persistent_config(location, parameters):
else:
print ("Could not save config")


func load_persistent_config(location):
var config_file = File.new()
var error = config_file.open(location, File.READ)
Expand Down
Loading

0 comments on commit b90a0b9

Please sign in to comment.