From f2213efc26fe0f1f1a9bc7fc1e663e90fbd94443 Mon Sep 17 00:00:00 2001 From: soul-walker Date: Mon, 22 Apr 2024 19:57:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E9=AA=8Cviewport=E7=BA=B9=E7=90=86?= =?UTF-8?q?=E4=BD=9C=E4=B8=BA=E6=9D=90=E8=B4=A8=E5=9C=A8=E4=B8=89=E7=BB=B4?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E4=B8=AD=E7=BB=98=E5=88=B6=E7=AB=99=E5=8F=B0?= =?UTF-8?q?=E4=B8=8A=E7=9A=84=E7=BA=BF=E8=B7=AF=E7=AB=99=E7=82=B9=E6=8C=87?= =?UTF-8?q?=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- experiments/psd_panel.gd | 12 +++++++++--- experiments/psd_panel.tscn | 23 ++++++++++++++++++----- experiments/psd_panel_ui.gd | 8 ++------ experiments/psd_panel_ui.tscn | 6 +++--- experiments/screen_door_t1.tscn | 6 +----- experiments/station_label.gd | 7 ++++--- experiments/station_label.tscn | 8 ++++---- experiments/test_3d.gd | 14 +++++++------- experiments/test_3d.tscn | 10 ++-------- 9 files changed, 50 insertions(+), 44 deletions(-) diff --git a/experiments/psd_panel.gd b/experiments/psd_panel.gd index 2a5a603..2699b37 100644 --- a/experiments/psd_panel.gd +++ b/experiments/psd_panel.gd @@ -1,6 +1,12 @@ @tool extends Node3D -#func _ready(): - #var lt = $LabelTexture.get_texture() - #$Sprite3D.texture = lt +@export_range(0.2, 20, 0.2) var repeat_times: float = 1 + +func _ready(): + var vp = $LabelTexture + vp.set_clear_mode(SubViewport.CLEAR_MODE_ONCE) + + $Plane.material_override.albedo_texture = vp.get_texture() + $Plane.material_override.uv1_scale = Vector3(repeat_times, 1, 1) + diff --git a/experiments/psd_panel.tscn b/experiments/psd_panel.tscn index 70594d4..569877e 100644 --- a/experiments/psd_panel.tscn +++ b/experiments/psd_panel.tscn @@ -1,18 +1,31 @@ -[gd_scene load_steps=4 format=3 uid="uid://c63e3ugq35q5g"] +[gd_scene load_steps=6 format=3 uid="uid://c63e3ugq35q5g"] [ext_resource type="Script" path="res://experiments/psd_panel.gd" id="1_wg3fd"] [ext_resource type="PackedScene" uid="uid://c5vvgu50akjwl" path="res://experiments/psd_panel_ui.tscn" id="2_rtht1"] -[sub_resource type="ViewportTexture" id="ViewportTexture_c2vxd"] +[sub_resource type="ViewportTexture" id="ViewportTexture_lwjc8"] viewport_path = NodePath("LabelTexture") +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pbh8q"] +albedo_texture = SubResource("ViewportTexture_lwjc8") +uv1_scale = Vector3(5, 1, 1) + +[sub_resource type="PlaneMesh" id="PlaneMesh_mfy0l"] +resource_local_to_scene = true +size = Vector2(100, 2) +orientation = 2 + [node name="PSD_Panel" type="Node3D"] script = ExtResource("1_wg3fd") +repeat_times = 4.0 [node name="LabelTexture" type="SubViewport" parent="."] -size = Vector2i(2048, 256) +canvas_item_default_texture_repeat = 1 +size = Vector2i(1800, 256) +render_target_clear_mode = 2 [node name="PSD_Panel_UI" parent="LabelTexture" instance=ExtResource("2_rtht1")] -[node name="Sprite3D" type="Sprite3D" parent="."] -texture = SubResource("ViewportTexture_c2vxd") +[node name="Plane" type="MeshInstance3D" parent="."] +material_override = SubResource("StandardMaterial3D_pbh8q") +mesh = SubResource("PlaneMesh_mfy0l") diff --git a/experiments/psd_panel_ui.gd b/experiments/psd_panel_ui.gd index 708797f..8100884 100644 --- a/experiments/psd_panel_ui.gd +++ b/experiments/psd_panel_ui.gd @@ -14,9 +14,9 @@ class StationLable: var stations = [ - StationLable.new("会展中心", "Exhibition Center", true), + StationLable.new("会展中心", "Exhibition Center", false), StationLable.new("世纪大道", "Century Avenue", false), - StationLable.new("交通大学", "JiaoTong Univercity", false), + StationLable.new("交通大学", "JiaoTong Univercity", true), StationLable.new("市图书馆", "City Library", false), StationLable.new("中心医院", "Central Hospital", false), StationLable.new("未来路", "Wei lai lu", false), @@ -25,11 +25,7 @@ var stations = [ StationLable.new("体育中心", "sports center", false), ] -var reverseStations = stations.reverse() - func _ready(): - print(stationLabelNode) - for i in stations.size(): var slable = stations[i] print(slable.name, slable.enName, slable.current) diff --git a/experiments/psd_panel_ui.tscn b/experiments/psd_panel_ui.tscn index d3e5147..6df2d55 100644 --- a/experiments/psd_panel_ui.tscn +++ b/experiments/psd_panel_ui.tscn @@ -6,7 +6,7 @@ script = ExtResource("1_cmik1") [node name="ColorRect" type="ColorRect" parent="."] -offset_right = 43.0 +offset_right = 52.0 offset_bottom = 25.0 scale = Vector2(36.8932, 11.8384) color = Color(0.564706, 0.564706, 0.564706, 1) @@ -23,14 +23,14 @@ layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_colors/font_shadow_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 36 -text = "当前车站" +text = "会展中心" horizontal_alignment = 1 [node name="EnName" type="Label" parent="VBoxContainer"] layout_mode = 2 theme_override_colors/font_color = Color(0, 0, 0, 1) theme_override_font_sizes/font_size = 20 -text = "Current Station" +text = "Exhibition Center" horizontal_alignment = 1 [node name="Container" type="Node2D" parent="."] diff --git a/experiments/screen_door_t1.tscn b/experiments/screen_door_t1.tscn index e83a25e..8b50d51 100644 --- a/experiments/screen_door_t1.tscn +++ b/experiments/screen_door_t1.tscn @@ -1,13 +1,9 @@ -[gd_scene load_steps=3 format=3 uid="uid://crpmwcp85khdr"] +[gd_scene load_steps=2 format=3 uid="uid://crpmwcp85khdr"] [ext_resource type="PackedScene" uid="uid://biot7d8s87d3y" path="res://Assets/models/screendoor1/screenDoor.gltf" id="1_tvcny"] -[ext_resource type="Script" path="res://experiments/screendoor_lcb.gd" id="2_5qyph"] [node name="screenDoor" instance=ExtResource("1_tvcny")] -[node name="JH_GD_LCB" parent="." index="0"] -script = ExtResource("2_5qyph") - [node name="Label3D" type="Label3D" parent="JH_GD_LCB" index="0"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.147186, 0) text = "LCB" diff --git a/experiments/station_label.gd b/experiments/station_label.gd index 3db5644..a69bea1 100644 --- a/experiments/station_label.gd +++ b/experiments/station_label.gd @@ -1,6 +1,7 @@ +@tool extends Node2D -func _init_station_name_and_position(name, enName, i): - $StationName/Name.text = name - $StationName/EnName.text = enName +func _init_station_name_and_position(sn, sen, i): + $StationName/Name.text = sn + $StationName/EnName.text = sen self.translate(Vector2(100 * i, 0)) diff --git a/experiments/station_label.tscn b/experiments/station_label.tscn index 0fe81a9..9bd3bf1 100644 --- a/experiments/station_label.tscn +++ b/experiments/station_label.tscn @@ -10,10 +10,10 @@ script = ExtResource("1_ch36d") [node name="StationName" type="Control" parent="."] layout_mode = 3 anchors_preset = 0 -offset_left = -24.0 -offset_top = -8.0 -offset_right = -24.0 -offset_bottom = -8.0 +offset_left = -16.0 +offset_top = -16.0 +offset_right = -16.0 +offset_bottom = -16.0 rotation = -0.785397 size_flags_horizontal = 8 size_flags_vertical = 8 diff --git a/experiments/test_3d.gd b/experiments/test_3d.gd index 47af1dc..81bf12b 100644 --- a/experiments/test_3d.gd +++ b/experiments/test_3d.gd @@ -2,10 +2,10 @@ extends Node3D @onready var camera = $Camera3D -func _ready(): - var sp = get_screen_position($LCB) - print("3D物体在屏幕上的位置: ", sp) - -func get_screen_position(mesh_instance): - var global_position = mesh_instance.global_transform.origin - return camera.unproject_position(global_position) +#func _ready(): + #var sp = get_screen_position($LCB) + #print("3D物体在屏幕上的位置: ", sp) +# +#func get_screen_position(mesh_instance): + #var global_position = mesh_instance.global_transform.origin + #return camera.unproject_position(global_position) diff --git a/experiments/test_3d.tscn b/experiments/test_3d.tscn index 6d4bb02..2105c99 100644 --- a/experiments/test_3d.tscn +++ b/experiments/test_3d.tscn @@ -1,9 +1,7 @@ -[gd_scene load_steps=7 format=3 uid="uid://4ygkabji3g16"] +[gd_scene load_steps=5 format=3 uid="uid://4ygkabji3g16"] [ext_resource type="PackedScene" uid="uid://bmiexmyoh0ehv" path="res://experiments/platform1.tscn" id="1_cq2ki"] -[ext_resource type="Script" path="res://experiments/test_3d.gd" id="1_uqsdo"] [ext_resource type="PackedScene" uid="uid://crpmwcp85khdr" path="res://experiments/screen_door_t1.tscn" id="2_rvfj7"] -[ext_resource type="PackedScene" uid="uid://b5c3atssvhkwy" path="res://experiments/lcb.tscn" id="3_htmjl"] [ext_resource type="PackedScene" uid="uid://c63e3ugq35q5g" path="res://experiments/psd_panel.tscn" id="4_wjde3"] [sub_resource type="Environment" id="Environment_mybsf"] @@ -11,16 +9,12 @@ ambient_light_color = Color(0.831373, 0.290196, 0.556863, 1) ambient_light_energy = 6.23 [node name="Node3D" type="Node3D"] -script = ExtResource("1_uqsdo") [node name="platform" parent="." instance=ExtResource("1_cq2ki")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.16258, 0) -[node name="LCB" parent="." instance=ExtResource("3_htmjl")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.58244, 2.40247, -7.38809) - [node name="PSD_Panel" parent="." instance=ExtResource("4_wjde3")] -transform = Transform3D(0.381944, 0, 0, 0, 0.381944, 0, 0, 0, 0.381944, 4.13301, 1.83159, -7.03252) +transform = Transform3D(0.381944, 0, 0, 0, 0.381944, 0, 0, 0, 0.381944, 15.3792, 1.86346, -7.03252) [node name="screenDoor" parent="." instance=ExtResource("2_rvfj7")]