diff --git a/game/BeepCube_Cut.material b/game/BeepCube_Cut.material index 7ae9a0c4..c0053a56 100644 Binary files a/game/BeepCube_Cut.material and b/game/BeepCube_Cut.material differ diff --git a/game/BeepCube_Cut.shader b/game/BeepCube_Cut.shader index 8a2d0959..bfee3a48 100644 --- a/game/BeepCube_Cut.shader +++ b/game/BeepCube_Cut.shader @@ -1,6 +1,7 @@ shader_type spatial; varying vec3 object_pos; +uniform sampler2D viewport; void vertex() { object_pos = VERTEX * 2.0 + vec3(0.5); @@ -11,6 +12,6 @@ void fragment() { float u = min(min(a.x, a.y), a.z); u = smoothstep(u, 0.05, 1.0); - ALBEDO = vec3(0.0); + ALBEDO = texture(viewport,UV).rgb; EMISSION = vec3(u); } \ No newline at end of file diff --git a/game/BeepSaberMainMenu.gd b/game/BeepSaberMainMenu.gd index 48e9cf45..cd082b96 100644 --- a/game/BeepSaberMainMenu.gd +++ b/game/BeepSaberMainMenu.gd @@ -60,8 +60,7 @@ func _load_playlists(): if (!_playlists): vr.log_error("No songs found in " + bspath); - for b in $SongsMenu/Songs.get_children(): - b.queue_free() + $SongsMenu.clear() return false; if (_playlists.size() == 0): @@ -109,12 +108,13 @@ func _set_cur_playlist(pl): if current_id.size() > 0: _select_song(current_id[0]) +var default_song_icon = preload("res://game/data/beepsaber_logo.png") func _wire_song_dat(dat): var current_song_data = { id=dat, info=_load_song_info(_song_path(dat)) } - $SongsMenu.add_item("%s - %s" % [current_song_data.info._songAuthorName, current_song_data.info._songName]) + $SongsMenu.add_item("%s - %s" % [current_song_data.info._songAuthorName, current_song_data.info._songName],default_song_icon) $SongsMenu.set_item_metadata($SongsMenu.get_item_count()-1,current_song_data) func _song_path(dat): diff --git a/game/BeepSaber_Game.gd b/game/BeepSaber_Game.gd index 418d7751..a9032d59 100644 --- a/game/BeepSaber_Game.gd +++ b/game/BeepSaber_Game.gd @@ -395,6 +395,7 @@ func update_saber_colors(): right_saber.type = 1; #also updates map colors $event_driver.update_colors() + $StandingGround.update_colors(COLOR_LEFT,COLOR_RIGHT) func disable_events(disabled): $event_driver.disabled = disabled diff --git a/game/BeepSaber_Game.tscn b/game/BeepSaber_Game.tscn index d9537dc0..5fe71231 100644 --- a/game/BeepSaber_Game.tscn +++ b/game/BeepSaber_Game.tscn @@ -1,6 +1,6 @@ -[gd_scene load_steps=27 format=2] +[gd_scene load_steps=25 format=2] -[ext_resource path="res://game/BeepCube_Cut.material" type="Material" id=1] +[ext_resource path="res://game/floor.tscn" type="PackedScene" id=1] [ext_resource path="res://OQ_Toolkit/OQ_UI2D/OQ_UI2DLabel.tscn" type="PackedScene" id=2] [ext_resource path="res://OQ_Toolkit/OQ_UI2D/OQ_UI2DCanvas.tscn" type="PackedScene" id=3] [ext_resource path="res://OQ_Toolkit/OQ_ARVROrigin.tscn" type="PackedScene" id=4] @@ -34,11 +34,6 @@ glow_blend_mode = 0 [sub_resource type="SphereShape" id=2] radius = 0.07 -[sub_resource type="BoxShape" id=3] - -[sub_resource type="PlaneMesh" id=4] -size = Vector2( 0.5, 0.5 ) - [node name="BeepSaber" type="Spatial"] script = ExtResource( 9 ) @@ -82,21 +77,7 @@ ui_raycast_visible_button = -1 [node name="Track" type="Spatial" parent="."] -[node name="StandingGround" type="StaticBody" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1 ) -collision_layer = 8 -collision_mask = 8 - -[node name="CollisionShape" type="CollisionShape" parent="StandingGround"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 ) -shape = SubResource( 3 ) - -[node name="Spatial" type="Spatial" parent="StandingGround"] -transform = Transform( 4, 0, 0, 0, 1, 0, 0, 0, 4, 0, 0, 0 ) - -[node name="MeshInstance" type="MeshInstance" parent="StandingGround/Spatial"] -mesh = SubResource( 4 ) -material/0 = ExtResource( 1 ) +[node name="StandingGround" parent="." instance=ExtResource( 1 )] [node name="event_driver" parent="." instance=ExtResource( 13 )] game = NodePath("..") diff --git a/game/LightSaber.gd b/game/LightSaber.gd index 83d8da0c..027dbd96 100644 --- a/game/LightSaber.gd +++ b/game/LightSaber.gd @@ -69,6 +69,15 @@ func _process(delta): last_pos.insert(0,pos) while last_pos.size() > max_pos: last_pos.remove(last_pos.size()-1) + + #check floor collision for burn mark + $RayCast.force_raycast_update() + if $RayCast.is_colliding(): + var raycoli = $RayCast.get_collider() + if raycoli in get_tree().get_nodes_in_group("floor"): + var colipoint = $RayCast.get_collision_point() + raycoli.burn_mark(colipoint,type) + else: imm_geo.clear() diff --git a/game/LightSaber.tscn b/game/LightSaber.tscn index e497b99e..b31ed54b 100644 --- a/game/LightSaber.tscn +++ b/game/LightSaber.tscn @@ -283,3 +283,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0508851, 0 ) [node name="tip" type="Position3D" parent="."] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.26252, 0 ) + +[node name="RayCast" type="RayCast" parent="."] +cast_to = Vector3( 0, 1.26, 0 ) +collision_mask = 8 diff --git a/game/Wall/Wall.tscn b/game/Wall/Wall.tscn index 57623823..4b71624f 100644 --- a/game/Wall/Wall.tscn +++ b/game/Wall/Wall.tscn @@ -31,7 +31,7 @@ height = 3 depth = 16 [node name="WallMeshOrientation" type="Spatial" parent="."] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, -8 ) +transform = Transform( 1, 0, 0, 0, 0.999999, 0, 0, 0, 1, 0, 1.5, -8 ) [node name="WallMesh" type="MeshInstance" parent="WallMeshOrientation"] material_override = ExtResource( 3 ) diff --git a/game/floor.gd b/game/floor.gd new file mode 100644 index 00000000..568f393f --- /dev/null +++ b/game/floor.gd @@ -0,0 +1,56 @@ +extends StaticBody + + +#func _process(delta): +# burn_mark() + +var last_position = [Vector2(0,-50),Vector2(0,-50)] + +var C_LEFT = Color() +var C_RIGHT = Color() + +func update_colors(COLOR_LEFT,COLOR_RIGHT): + C_LEFT = COLOR_LEFT + C_RIGHT = COLOR_RIGHT + $Viewport/ColorRect/burn_l.modulate = C_LEFT*6 + $Viewport/ColorRect/burn_r.modulate = C_RIGHT*6 + +var is_out = [0,0] +func burn_mark(position=Vector3(0,0,-50),type=0): + var burn_mark_sprite + var burn_mark_sprite_long + if type == 0: + burn_mark_sprite = $Viewport/ColorRect/burn_l + burn_mark_sprite_long = $Viewport/ColorRect/burn_l/sprite + elif type == 1: + burn_mark_sprite = $Viewport/ColorRect/burn_r + burn_mark_sprite_long = $Viewport/ColorRect/burn_r/sprite + else: + return + var was_out = !burn_mark_sprite.visible + burn_mark_sprite.visible = true + is_out[type] = 0 + + var newpos = Vector2( + (position.x+1)*256, + position.z*256 + ) + + burn_mark_sprite.position = newpos + + burn_mark_sprite.rotation = newpos.angle_to_point(last_position[type]) + burn_mark_sprite.rotation_degrees += 180 + var dist = last_position[type].distance_to(newpos) + if dist > 12 and not was_out: + burn_mark_sprite_long.rect_size.x = dist+12 + else: + burn_mark_sprite_long.rect_size.x = 24 + + last_position[type] = newpos + +func _process(delta): + if is_out[0] == 1: + $Viewport/ColorRect/burn_l.visible = false + if is_out[1] == 1: + $Viewport/ColorRect/burn_r.visible = false + is_out = [1,1] diff --git a/game/floor.tscn b/game/floor.tscn new file mode 100644 index 00000000..ada0cd00 --- /dev/null +++ b/game/floor.tscn @@ -0,0 +1,99 @@ +[gd_scene load_steps=9 format=2] + +[ext_resource path="res://game/BeepCube_Cut.material" type="Material" id=1] +[ext_resource path="res://game/floor.gd" type="Script" id=3] + +[sub_resource type="BoxShape" id=1] + +[sub_resource type="PlaneMesh" id=2] +size = Vector2( 0.5, 0.5 ) + +[sub_resource type="ViewportTexture" id=3] +viewport_path = NodePath("Viewport") + +[sub_resource type="SpatialMaterial" id=4] +resource_local_to_scene = true +flags_unshaded = true +albedo_texture = SubResource( 3 ) + +[sub_resource type="CanvasItemMaterial" id=6] +blend_mode = 1 + +[sub_resource type="StyleBoxFlat" id=5] +bg_color = Color( 1, 1, 1, 1 ) +border_width_left = 8 +border_width_top = 8 +border_width_right = 8 +border_width_bottom = 8 +border_color = Color( 0, 0, 0, 1 ) +border_blend = true +corner_radius_top_left = 11 +corner_radius_top_right = 11 +corner_radius_bottom_right = 11 +corner_radius_bottom_left = 11 +corner_detail = 6 + +[node name="StandingGround" type="StaticBody" groups=[ +"floor", +]] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1 ) +collision_layer = 8 +collision_mask = 8 +script = ExtResource( 3 ) + +[node name="CollisionShape" type="CollisionShape" parent="."] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 ) +shape = SubResource( 1 ) + +[node name="Spatial" type="Spatial" parent="."] +transform = Transform( 4, 0, 0, 0, 1, 0, 0, 0, 4, 0, 0, 0 ) + +[node name="MeshInstance" type="MeshInstance" parent="Spatial"] +mesh = SubResource( 2 ) +material/0 = ExtResource( 1 ) + +[node name="MeshInstance2" type="MeshInstance" parent="Spatial"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.001, 0 ) +mesh = SubResource( 2 ) +material/0 = SubResource( 4 ) + +[node name="Viewport" type="Viewport" parent="."] +size = Vector2( 512, 512 ) +render_target_v_flip = true +render_target_clear_mode = 1 + +[node name="ColorRect" type="ColorRect" parent="Viewport"] +margin_right = 512.0 +margin_bottom = 512.0 +color = Color( 0, 0, 0, 0.027451 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="burn_l" type="Node2D" parent="Viewport/ColorRect"] +position = Vector2( -64, -64 ) + +[node name="sprite" type="Panel" parent="Viewport/ColorRect/burn_l"] +material = SubResource( 6 ) +margin_left = -12.0 +margin_top = -12.0 +margin_right = 12.0 +margin_bottom = 12.0 +custom_styles/panel = SubResource( 5 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="burn_r" type="Node2D" parent="Viewport/ColorRect"] +position = Vector2( -64, -64 ) + +[node name="sprite" type="Panel" parent="Viewport/ColorRect/burn_r"] +material = SubResource( 6 ) +margin_left = -12.0 +margin_top = -12.0 +margin_right = 12.0 +margin_bottom = 12.0 +custom_styles/panel = SubResource( 5 ) +__meta__ = { +"_edit_use_anchors_": false +}