diff --git a/assets/models/crt-back.jpg b/assets/models/crt-back.jpg new file mode 100644 index 0000000..7469b04 Binary files /dev/null and b/assets/models/crt-back.jpg differ diff --git a/assets/models/crt-front.jpg b/assets/models/crt-front.jpg new file mode 100644 index 0000000..2718e32 Binary files /dev/null and b/assets/models/crt-front.jpg differ diff --git a/assets/models/crt-monitor.blend b/assets/models/crt-monitor.blend new file mode 100644 index 0000000..fc82dbf Binary files /dev/null and b/assets/models/crt-monitor.blend differ diff --git a/assets/models/crt-monitor.blend1 b/assets/models/crt-monitor.blend1 new file mode 100644 index 0000000..8cc4c98 Binary files /dev/null and b/assets/models/crt-monitor.blend1 differ diff --git a/assets/models/crt-side.jpg b/assets/models/crt-side.jpg new file mode 100644 index 0000000..1d69acb Binary files /dev/null and b/assets/models/crt-side.jpg differ diff --git a/scenes/ui/main_menu/main_menu.gd b/scenes/ui/main_menu/main_menu.gd new file mode 100644 index 0000000..e7f1bbd --- /dev/null +++ b/scenes/ui/main_menu/main_menu.gd @@ -0,0 +1,34 @@ +extends Area3D + +@onready var viewport: SubViewport = %SubViewport +@onready var screen_mesh: MeshInstance3D = $".." + +func _input_event(_camera: Camera3D, event: InputEvent, event_position: Vector3, _normal: Vector3, _shape_idx: int) -> void: + # Only care about mouse/touch events + if not (event is InputEventMouse or event is InputEventScreenTouch): + return + + # 1. Convert the world 3D click into local 3D coordinates relative to the ScreenMesh + var local_pos = screen_mesh.to_local(event_position) + + # 2. Get the size of our 3D QuadMesh + var quad_size = screen_mesh.mesh.size + + # 3. Convert the local 3D position into a 2D percentage (0.0 to 1.0) + # (Quad coordinates go from -0.5 to +0.5 from the center. We offset by +0.5 to make it 0 to 1) + var percent_x = (local_pos.x / quad_size.x) + 0.5 + + # 3D Y goes UP. 2D Y goes DOWN. We must invert the Y axis! + var percent_y = 0.5 - (local_pos.y / quad_size.y) + + # 4. Multiply the percentage by the SubViewport's actual pixel resolution + var viewport_size = viewport.size + var final_2d_pos = Vector2(percent_x * viewport_size.x, percent_y * viewport_size.y) + + # 5. Overwrite the event's position data with our calculated 2D coordinates + event.position = final_2d_pos + if event is InputEventMouse: + event.global_position = final_2d_pos + + # 6. Force the SubViewport to process this customized 2D event! + viewport.push_input(event) diff --git a/scenes/ui/main_menu/main_menu.gd.uid b/scenes/ui/main_menu/main_menu.gd.uid new file mode 100644 index 0000000..c507843 --- /dev/null +++ b/scenes/ui/main_menu/main_menu.gd.uid @@ -0,0 +1 @@ +uid://dytci31yxfsp2 diff --git a/scenes/ui/main_menu/main_menu.tscn b/scenes/ui/main_menu/main_menu.tscn new file mode 100644 index 0000000..94da0d5 --- /dev/null +++ b/scenes/ui/main_menu/main_menu.tscn @@ -0,0 +1,69 @@ +[gd_scene format=3 uid="uid://bor2crcvgyams"] + +[ext_resource type="Script" uid="uid://dytci31yxfsp2" path="res://scenes/ui/main_menu/main_menu.gd" id="1_1ch07"] + +[sub_resource type="ViewportTexture" id="ViewportTexture_qt1dd"] +viewport_path = NodePath("SubViewport") + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_02q7b"] +resource_local_to_scene = true +transparency = 1 +albedo_texture = SubResource("ViewportTexture_qt1dd") + +[sub_resource type="QuadMesh" id="QuadMesh_02q7b"] +material = SubResource("StandardMaterial3D_02q7b") +size = Vector2(1.92, 1.08) + +[sub_resource type="BoxShape3D" id="BoxShape3D_02q7b"] +size = Vector3(1.92, 1.08, 0.05) + +[node name="MainMenu" type="Node3D" unique_id=125340116] + +[node name="Camera3D" type="Camera3D" parent="." unique_id=629879959] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.2416561) + +[node name="SubViewport" type="SubViewport" parent="." unique_id=1756952437] +unique_name_in_owner = true +transparent_bg = true +size = Vector2i(1980, 1080) + +[node name="MenuUi" type="Control" parent="SubViewport" unique_id=2130463806] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="SubViewport/MenuUi" unique_id=1437013632] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Button" type="Button" parent="SubViewport/MenuUi/VBoxContainer" unique_id=100772649] +layout_mode = 2 +text = "Start random" + +[node name="Button2" type="Button" parent="SubViewport/MenuUi/VBoxContainer" unique_id=2127276855] +layout_mode = 2 +text = "Start dev" + +[node name="Button3" type="Button" parent="SubViewport/MenuUi/VBoxContainer" unique_id=2089724034] +layout_mode = 2 +text = "Settings" + +[node name="Button4" type="Button" parent="SubViewport/MenuUi/VBoxContainer" unique_id=1837266588] +layout_mode = 2 +text = "Exit" + +[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=813862939] +mesh = SubResource("QuadMesh_02q7b") + +[node name="Area3D" type="Area3D" parent="MeshInstance3D" unique_id=1370892947] +script = ExtResource("1_1ch07") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/Area3D" unique_id=685346505] +shape = SubResource("BoxShape3D_02q7b")