sd
This commit is contained in:
parent
24e89d9383
commit
1c0518d5eb
8 changed files with 104 additions and 0 deletions
BIN
assets/models/crt-back.jpg
Normal file
BIN
assets/models/crt-back.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
BIN
assets/models/crt-front.jpg
Normal file
BIN
assets/models/crt-front.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
BIN
assets/models/crt-monitor.blend
Normal file
BIN
assets/models/crt-monitor.blend
Normal file
Binary file not shown.
BIN
assets/models/crt-monitor.blend1
Normal file
BIN
assets/models/crt-monitor.blend1
Normal file
Binary file not shown.
BIN
assets/models/crt-side.jpg
Normal file
BIN
assets/models/crt-side.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
34
scenes/ui/main_menu/main_menu.gd
Normal file
34
scenes/ui/main_menu/main_menu.gd
Normal file
|
|
@ -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)
|
||||
1
scenes/ui/main_menu/main_menu.gd.uid
Normal file
1
scenes/ui/main_menu/main_menu.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dytci31yxfsp2
|
||||
69
scenes/ui/main_menu/main_menu.tscn
Normal file
69
scenes/ui/main_menu/main_menu.tscn
Normal file
|
|
@ -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")
|
||||
Loading…
Reference in a new issue