diff --git a/addons/simple-portal-system/scripts/portal.gd b/addons/simple-portal-system/scripts/portal.gd index 3ab52e7..76099aa 100644 --- a/addons/simple-portal-system/scripts/portal.gd +++ b/addons/simple-portal-system/scripts/portal.gd @@ -117,7 +117,7 @@ func _create_viewport() -> void: _viewport = SubViewport.new() _viewport.name = "Viewport" _viewport.render_target_clear_mode = SubViewport.CLEAR_MODE_ONCE - add_child(_viewport) + exit_portal.add_child(_viewport) material_override.set_shader_parameter("albedo", _viewport.get_texture()) # Create the exit camera which renders the portal surface for the viewport diff --git a/levels/level_hermione.tscn b/levels/level_hermione.tscn index c240ee1..20e9916 100644 --- a/levels/level_hermione.tscn +++ b/levels/level_hermione.tscn @@ -1,10 +1,26 @@ -[gd_scene load_steps=6 format=3 uid="uid://dgvdetmbv5jya"] +[gd_scene load_steps=9 format=4 uid="uid://dgvdetmbv5jya"] [ext_resource type="PackedScene" uid="uid://b5x7fmpwck335" path="res://hud.tscn" id="1_2k7q4"] [ext_resource type="Script" uid="uid://ca45js46kc0l7" path="res://levels/level_hermione.gd" id="1_gyvwl"] [ext_resource type="PackedScene" uid="uid://drhaqr78kv1o2" path="res://levels/room_hermione_outside.tscn" id="2_empe6"] [ext_resource type="PackedScene" uid="uid://ci81nttn6foio" path="res://levels/room_hermione_inside.tscn" id="2_lv1mc"] [ext_resource type="PackedScene" uid="uid://cgdlowfuuorvi" path="res://player.tscn" id="3_gyvwl"] +[ext_resource type="PackedScene" uid="uid://jecigkibqyew" path="res://portal.tscn" id="6_owlrt"] +[ext_resource type="PackedScene" uid="uid://d1dtxvwk86ple" path="res://procedural_mesh_maker.tscn" id="7_ucmro"] + +[sub_resource type="ArrayMesh" id="ArrayMesh_owlrt"] +_surfaces = [{ +"aabb": AABB(-0.45, -1.075, 0, 0.9, 2.15, 1e-05), +"attribute_data": PackedByteArray("AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAPwAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAIA/AACAPw=="), +"format": 34359742487, +"index_count": 30, +"index_data": PackedByteArray("AAABAAQABAABAAUAAQADAAUABQADAAcAAwACAAcABwACAAYAAgAAAAYABgAAAAQABAAFAAYABgAFAAcA"), +"name": "Portal Material", +"primitive": 3, +"uv_scale": Vector4(0, 0, 0, 0), +"vertex_count": 8, +"vertex_data": PackedByteArray("ZmbmvpqZiT8AAAAAZmbmPpqZiT8AAAAAZmbmvpqZib8AAAAAZmbmPpqZib8AAAAAZmbmvpqZiT8AAAAAZmbmPpqZiT8AAAAAZmbmvpqZib8AAAAAZmbmPpqZib8AAAAA/3//f/9/AID/f/9//38AgP9//3//fwCA/3//f/9/AID/f/9//38AgP9//3//fwCA/3//f/9/AID/f/9//38AgA==") +}] [node name="level_hermione" type="Node"] script = ExtResource("1_gyvwl") @@ -30,6 +46,11 @@ render_target_update_mode = 4 unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6.08041, 1.41104, 0) +[node name="PortalOutside" parent="SubViewportContainer/OutsideWorld/OutsideWorldContainer" node_paths=PackedStringArray("main_camera") instance=ExtResource("6_owlrt")] +transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 3.505, 1.55, 0.5) +mesh = SubResource("ArrayMesh_owlrt") +main_camera = NodePath("../Player/Camera3D") + [node name="HUD" parent="." instance=ExtResource("1_2k7q4")] [node name="TeleportButton" type="Button" parent="HUD"] @@ -45,4 +66,18 @@ size = Vector2i(1920, 1080) [node name="room_hermione_inside" parent="InsideWorld/InsideWorldContainer" instance=ExtResource("2_lv1mc")] +[node name="PortalInside" parent="InsideWorld/InsideWorldContainer" node_paths=PackedStringArray("main_camera", "exit_portal") instance=ExtResource("6_owlrt")] +transform = Transform3D(1.19249e-08, 0, -1, 0, 1, 0, 1, 0, 1.19249e-08, 3.505, 1.55, 0.5) +mesh = SubResource("ArrayMesh_owlrt") +main_camera = NodePath("../../../SubViewportContainer/OutsideWorld/OutsideWorldContainer/Player/Camera3D") +exit_portal = NodePath("../../../SubViewportContainer/OutsideWorld/OutsideWorldContainer/PortalOutside") + +[node name="ProceduralMeshMaker" parent="." node_paths=PackedStringArray("portal") instance=ExtResource("7_ucmro")] +portal = NodePath("../InsideWorld/InsideWorldContainer/PortalInside") +height = 2.15 +width = 0.9 +indent = 0.0 + [connection signal="pressed" from="HUD/TeleportButton" to="." method="_on_teleport_button_pressed"] + +[editable path="SubViewportContainer/OutsideWorld/OutsideWorldContainer/Player"] diff --git a/portal.tscn b/portal.tscn new file mode 100644 index 0000000..b8d8d7d --- /dev/null +++ b/portal.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://jecigkibqyew"] + +[ext_resource type="Script" uid="uid://d2bvvjsibau8c" path="res://addons/simple-portal-system/scripts/portal.gd" id="1_0r486"] + +[node name="Portal" type="MeshInstance3D"] +script = ExtResource("1_0r486")