Skip to content

Commit

Permalink
Change stage material to be less GPU intensive
Browse files Browse the repository at this point in the history
  • Loading branch information
mgschwan committed Apr 30, 2021
1 parent 6ed5d27 commit 3e80f35
Show file tree
Hide file tree
Showing 102 changed files with 2,188 additions and 575 deletions.
Binary file added 3d models/simple_phone.blend
Binary file not shown.
Binary file added 3d models/tron_material_baked_ambient.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 3d models/vrworkout_stage.blend
Binary file not shown.
Binary file added 3d models/vrworkout_stage.blend1
Binary file not shown.
35 changes: 35 additions & 0 deletions asset_src/arrow_button.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added asset_src/arrow_button_down.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added asset_src/arrow_button_up.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added asset_src/stage_lightmap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added asset_src/stage_lightmap.xcf
Binary file not shown.
1 change: 0 additions & 1 deletion godot_project/ControllerScript.gd
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func get_hit_velocity():

var timedelta = max(0.001, last_time[2])
var velocity = distance/timedelta
get_parent().get_parent().level.infolayer.print_info("Velocity %.2f"%velocity, "debug")
return velocity

func get_touch_object():
Expand Down
9 changes: 8 additions & 1 deletion godot_project/InfoBoxOpaque.tscn
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=8 format=2]

[ext_resource path="res://fonts/Droid_Sans_Regular.tres" type="DynamicFont" id=1]
[ext_resource path="res://InfoBox.gd" type="Script" id=2]
[ext_resource path="res://fonts/Droid_Sans_Bold.tres" type="DynamicFont" id=3]
[ext_resource path="res://themes/vrworkout_theme.theme" type="Theme" id=4]

[sub_resource type="PlaneMesh" id=1]
size = Vector2( 2, 1 )

[sub_resource type="ViewportTexture" id=2]
flags = 4
viewport_path = NodePath("ViewportInfo")

[sub_resource type="SpatialMaterial" id=3]
Expand All @@ -27,6 +29,11 @@ usage = 0
render_target_v_flip = true
render_target_update_mode = 0

[node name="Panel" type="Panel" parent="ViewportInfo"]
margin_right = 1024.0
margin_bottom = 512.0
theme = ExtResource( 4 )

[node name="CanvasLayer" type="CanvasLayer" parent="ViewportInfo"]

[node name="Container" type="MarginContainer" parent="ViewportInfo/CanvasLayer"]
Expand Down
20 changes: 19 additions & 1 deletion godot_project/Main.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=28 format=2]
[gd_scene load_steps=31 format=2]

[ext_resource path="res://VRScene.gd" type="Script" id=1]
[ext_resource path="res://ARVRCamera.gd" type="Script" id=2]
Expand All @@ -21,6 +21,8 @@
[ext_resource path="res://scripts/VisualRayCast.gd" type="Script" id=19]
[ext_resource path="res://scenes/YoutubeInterface.tscn" type="PackedScene" id=20]
[ext_resource path="res://scenes/GASTWebView.tscn" type="PackedScene" id=21]
[ext_resource path="res://scenes/NetworkARVRController.tscn" type="PackedScene" id=22]
[ext_resource path="res://scenes/SimplePhone.tscn" type="PackedScene" id=23]

[sub_resource type="SphereShape" id=1]
radius = 0.12
Expand Down Expand Up @@ -58,6 +60,9 @@ tracks/0/keys = {
"values": [ Vector3( 0, 0, 0 ), Vector3( 360, 0, 360 ) ]
}

[sub_resource type="PrismMesh" id=7]
size = Vector3( 0.1, 0.2, 0.02 )

[node name="VRScene" type="Spatial"]
script = ExtResource( 1 )

Expand Down Expand Up @@ -166,6 +171,19 @@ transform = Transform( 0.998396, 0.0566011, 0, -0.0565104, 0.996796, 0.0566011,
[node name="AnimationPlayer" type="AnimationPlayer" parent="ARVROrigin/SkyBox"]
anims/starfield_rotation = SubResource( 6 )

[node name="NetworkARVRController" parent="ARVROrigin" instance=ExtResource( 22 )]
transform = Transform( -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0, 0, 0 )

[node name="Mesh" type="Spatial" parent="ARVROrigin/NetworkARVRController"]

[node name="Phone" parent="ARVROrigin/NetworkARVRController/Mesh" instance=ExtResource( 23 )]
transform = Transform( 0.1, 1.74845e-08, 0, -1.74845e-08, 0.1, 0, 0, 0, 0.1, 0, 0, 0 )

[node name="Compass" type="MeshInstance" parent="ARVROrigin/NetworkARVRController/Mesh"]
transform = Transform( 1, 1.06581e-14, 0, -1.06581e-14, 1, 0, 0, 0, 1, 0, 0, 0 )
mesh = SubResource( 7 )
material/0 = null

[node name="DemoTimer" type="Timer" parent="."]
wait_time = 5.0
one_shot = true
Expand Down
125 changes: 30 additions & 95 deletions godot_project/SongSelector.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extends Spatial

signal level_selected(filename, difficulty, level_number)
signal content_changed()

var current_difficulty = 0

Expand All @@ -12,10 +13,6 @@ var gu = GameUtilities.new()

var playlist = []

# Declare member variables here. Examples:
# var a = 2
# var b = "text"

func playlist_from_song_files(songs):
playlist.clear()
for song in songs:
Expand All @@ -33,63 +30,11 @@ func playlist_from_song_names(songs):
var songfile = get_tree().current_scene.get_node("SongDatabase").get_songfile(song)
if songfile:
playlist.append(songfile)

update_songs()

func update_song_list():
var offset = page * 6
var pages = ceil(len(song_list)/6.0)
for idx in range(6):
var element = get_node("SongBlocks/Element%d"%(idx+1))
if len(song_list) > idx+offset:
var filename = song_list[idx+offset]
var song_name = gu.get_song_name(filename)
var song_info = song_infos.get(filename,{})
var artist = song_info.get("artist","")
var length = get_tree().current_scene.get_node("SongDatabase").get_song_duration(filename)
element.is_set = true
element.set_song_info(song_name,filename,artist,length)
else:
element.is_set = false
element.set_song_info("empty",null)

get_node("NextPage").print_info("[b]Next Page\n\n Current: %d/%d[b]"%[page+1,pages])





func get_song_infos(songs):
var infos = {}
for song in songs:
var beat_file = File.new()
var error = beat_file.open("%s.json"%song, File.READ)
if error == OK:
var tmp = JSON.parse(beat_file.get_as_text()).result
beat_file.close()
if tmp:
var artist = tmp.get("artist", "")
infos[song] = {"artist": artist, "length": 0}
return infos

func sort_song_list(songs):
var retVal = []
var song_dict = {}
for s in songs:
var song_name = gu.get_song_name(s)
song_dict[song_name.to_lower()] = s

var song_tmp = song_dict.keys()
song_tmp.sort()
for s in song_tmp:
retVal.append(song_dict[s])
return retVal

func set_songs(songs):
song_list = sort_song_list(songs)
song_infos = get_song_infos(songs)
update_song_list()

$SongSelector/Viewport/SongSelection.set_songs(songs)
$SongSelector/Viewport.render_target_update_mode = Viewport.UPDATE_ONCE

var hrr #Heart rate receiver
var youtube #Youtube interface
Expand All @@ -102,26 +47,22 @@ func update_automatic():
get_node("DifficultyButtons").enable_automatic(false)
gu.deactivate_node(get_node("Heartrate"))


# Called when the node enters the scene tree for the first time.
func _ready():
hrr = get_tree().current_scene.get_node("HeartRateReceiver")
youtube = get_tree().current_scene.get_node("YoutubeInterface")

var external_dir = ProjectSettings.get("game/external_songs")

if external_dir:
get_node("MusicDirectory").print_info("Place custom OGG or MP3 files\n in: %s"%external_dir)


get_node("SongSelector/MusicDirectory").print_info("Place custom OGG or MP3 files\n in: %s"%external_dir)

update_automatic()
update_song_list()
update_hr_selectors()
update_songs()
select_difficulty(current_difficulty)
emit_signal("content_changed")



func update_songs():
var t = ""
var duration = 0
Expand All @@ -140,24 +81,8 @@ func update_songs():

root.set_text(0,"Your Playlist %s"%(gu.seconds_to_timestring(duration)))

emit_signal("content_changed")
#get_node("Viewport").render_target_update_mode = Viewport.UPDATE_ONCE

func next_page():
print ("Page: %d, Songs: %d, Pages: %d"%[page, len(song_list), int(ceil(len(song_list)/6.0))])
if len(song_list) > 0:
page = (page + 1) % int(ceil(len(song_list)/6.0))
print ("Next page: %d"%page)
update_song_list()

func previous_page():
print ("Page: %d, Songs: %d, Pages: %d"%[page, len(song_list), int(ceil(len(song_list)/6.0))])
page -= 1
if page < 0:
page = max(0,int(ceil(len(song_list)/6.0))-1)

print ("Previous page: %d"%page)
update_song_list()


var frame_idx = 0
# Called every frame. 'delta' is the elapsed time since the previous frame.
Expand All @@ -169,31 +94,22 @@ func _process(delta):
#print ("Youtube available")
$Viewport/CanvasLayer/TabContainer/Youtube/YoutubeButton.show()
$Viewport/CanvasLayer/TabContainer/Youtube/ActivateYoutube.hide()
#$Viewport.render_target_update_mode = Viewport.UPDATE_ONCE
emit_signal("content_changed")
elif not youtube.is_youtube_available(): # and $Viewport/CanvasLayer/TabContainer/Youtube/YoutubeButton.visible:
#print ("Youtube not available")
$Viewport/CanvasLayer/TabContainer/Youtube/YoutubeButton.hide()
$Viewport/CanvasLayer/TabContainer/Youtube/ActivateYoutube.show()
#$Viewport.render_target_update_mode = Viewport.UPDATE_ONCE
emit_signal("content_changed")
frame_idx = 0

func select_difficulty(d):
current_difficulty = d
get_node("DifficultyButtons").select_difficulty(d)


func _on_level_block_selected(filename, difficulty, level_number):
playlist.append(filename)
update_songs()

func _on_NextPage_touched():
next_page()

func _on_PreviousPage_touched():
previous_page()



var difficulties = {"easy":0,"medium": 1, "hard": 2, "ultra": 3, "auto": -1,}
func _on_DifficultyButtons_difficulty_selected(difficulty):
if difficulty in difficulties:
Expand Down Expand Up @@ -250,7 +166,6 @@ func _on_PauseButton_pressed():
playlist.append(-10)
update_songs()


func _on_RemoveButton_button_up():
print ("Remove Button UP")

Expand All @@ -262,3 +177,23 @@ func _on_YoutubeButton_pressed():
func _on_ActivateYoutube_pressed():
var link = "%s%d"%[ProjectSettings.get("application/config/youtube_link"),OS.get_unix_time()]
OS.shell_open(link)
emit_signal("content_changed")

func _on_SongSelection_add_playlist_song(song_filename):
playlist.append(song_filename)
update_songs()

func _on_SongSelection_preview_song(song_filename):
if song_filename:
var stream = gu.load_audio_resource(song_filename)
$AudioStreamPlayer.stream = stream
$AudioStreamPlayer.play()
else:
$AudioStreamPlayer.stop()


func _on_TabContainer_tab_selected(tab):
if tab == 0:
$SongSelector.enable()
else:
$SongSelector.disable()

0 comments on commit 3e80f35

Please sign in to comment.