Merge branch 'main' of https://gitea.joylink.club/joylink/godot-psd-training
This commit is contained in:
commit
0a2a81d366
@ -4,6 +4,8 @@ extends Node3D
|
||||
class_name ScreenDoor
|
||||
@onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer
|
||||
@onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer
|
||||
@export var mtd_material: ShaderMaterial
|
||||
@export var mtd_fault_material: ShaderMaterial
|
||||
|
||||
##是否设置隔离带
|
||||
@onready var isSetIsolationStrip:bool = false :
|
||||
@ -45,19 +47,24 @@ func openScreenDoor (isUseLCBKey=false)-> void:
|
||||
if screenDoorState == ScreenDoor_State.close and (screenDoorFaultState != ScreenDoor_Fault_State.openFault or isUseLCBKey):
|
||||
screenDoorState=ScreenDoor_State.opening
|
||||
$Timer.connect('timeout', _on_timer_timeout)
|
||||
$Timer.start(0.5)
|
||||
$Timer.start(0.3)
|
||||
|
||||
|
||||
##关闭屏蔽门
|
||||
func closeScreenDoor (isUseLCBKey=false)-> void:
|
||||
if screenDoorState == ScreenDoor_State.open and (screenDoorFaultState != ScreenDoor_Fault_State.closeFault or isUseLCBKey):
|
||||
screenDoorState=ScreenDoor_State.closeing
|
||||
$Timer.connect('timeout', _on_timer_timeout)
|
||||
$Timer.start(0.3)
|
||||
|
||||
|
||||
|
||||
func _on_left_animation_player_animation_finished(anim_name: StringName) -> void:
|
||||
if anim_name == 'leftOpen':
|
||||
screenDoorState = ScreenDoor_State.open
|
||||
$Timer.stop()
|
||||
is_dark = false
|
||||
_set_mtd(is_dark)
|
||||
elif anim_name == 'leftClose':
|
||||
screenDoorState = ScreenDoor_State.close
|
||||
$Timer.stop()
|
||||
@ -86,10 +93,16 @@ func setScreenDoorFault (faultType:ScreenDoor_Fault_State)-> void:
|
||||
if faultType == ScreenDoor_Fault_State.glassBreakage :
|
||||
$leftDoor_broken.visible = true
|
||||
$leftDoor_broken/AudioStreamPlayer.play()
|
||||
elif faultType == ScreenDoor_Fault_State.openFault :
|
||||
$MTD.material_override = mtd_fault_material
|
||||
elif faultType == ScreenDoor_Fault_State.closeFault :
|
||||
$MTD.material_override = mtd_fault_material
|
||||
mtd_fault_material.set_shader_parameter('is_dark', false)
|
||||
|
||||
##恢复故障
|
||||
func removeScreenDoorFault ()-> void:
|
||||
screenDoorFaultState = ScreenDoor_Fault_State.noFault
|
||||
$MTD.material_override = mtd_material
|
||||
|
||||
##以下是lcb相关
|
||||
class LcbKeyWindow :
|
||||
@ -116,12 +129,13 @@ func _on_timer_timeout():
|
||||
|
||||
func _set_mtd(dark):
|
||||
if is_dark:
|
||||
$MTD.set_instance_shader_parameter("color_dark", 0.5)
|
||||
mtd_material.set_shader_parameter('is_dark', true)
|
||||
$SpotLight3D.hide()
|
||||
else:
|
||||
$MTD.set_instance_shader_parameter("color_dark", 1.5)
|
||||
$SpotLight3D.show()
|
||||
mtd_material.set_shader_parameter('is_dark', false)
|
||||
$SpotLight3D.show()
|
||||
|
||||
func _ready():
|
||||
$MTD.material_override = mtd_material
|
||||
_set_mtd(is_dark)
|
||||
$SpotLight3D.hide()
|
||||
|
@ -1,9 +1,12 @@
|
||||
[gd_scene load_steps=45 format=3 uid="uid://bc2dnsyx16kk6"]
|
||||
[gd_scene load_steps=48 format=3 uid="uid://bc2dnsyx16kk6"]
|
||||
|
||||
[ext_resource type="Script" path="res://sceen/platform/screenDoor.gd" id="1_nse1y"]
|
||||
[ext_resource type="Shader" path="res://shaders/mtd.gdshader" id="2_04fd1"]
|
||||
[ext_resource type="Texture2D" uid="uid://57t8x7rlqk7y" path="res://Model/textures/GD_SDFSDF_an.jpg" id="2_rf1ed"]
|
||||
[ext_resource type="Texture2D" uid="uid://dipiewtuqhdd0" path="res://Model/textures/GD_SDFSDF_liang.jpg" id="2_runrf"]
|
||||
[ext_resource type="Texture2D" uid="uid://jrx8rifckwtb" path="res://Model/textures/haerbin_jz_menkuangyanse87.png" id="3_0l1gg"]
|
||||
[ext_resource type="Texture2D" uid="uid://dpue4vjyr04iv" path="res://Assets/GD_SDFSDF_liang.jpg" id="3_7tk5i"]
|
||||
[ext_resource type="Shader" path="res://shaders/mtd_fault.gdshader" id="3_mot0p"]
|
||||
[ext_resource type="Texture2D" uid="uid://bl5okq27c107u" path="res://Assets/GD_SDFSDF_an.jpg" id="3_wxjgd"]
|
||||
[ext_resource type="PackedScene" uid="uid://0ys58lvdq51b" path="res://sceen/platform/lcb.tscn" id="4_t5qy2"]
|
||||
[ext_resource type="Script" path="res://sceen/platform/screenDoorArea3D.gd" id="5_8p3um"]
|
||||
[ext_resource type="Texture2D" uid="uid://bywpyj1w7nk86" path="res://Model/textures/haerbin_jz_menkuangyanse_BL.png" id="6_8lvxg"]
|
||||
@ -12,64 +15,39 @@
|
||||
[ext_resource type="Texture2D" uid="uid://co0ggcy26r38g" path="res://Model/textures/2cengtietu_zst.png" id="9_da8bg"]
|
||||
[ext_resource type="AudioStream" uid="uid://k0e2shfdjyrq" path="res://Assets/music/glass-breaking.mp3" id="9_kpf37"]
|
||||
|
||||
[sub_resource type="Shader" id="Shader_qbwwy"]
|
||||
code = "// NOTE: Shader automatically converted from Godot Engine 4.2.2.stable's StandardMaterial3D.
|
||||
|
||||
shader_type spatial;
|
||||
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx;
|
||||
uniform vec4 albedo : source_color;
|
||||
uniform sampler2D texture_albedo : source_color,filter_linear_mipmap,repeat_enable;
|
||||
uniform float point_size : hint_range(0,128);
|
||||
uniform float roughness : hint_range(0,1);
|
||||
uniform sampler2D texture_metallic : hint_default_white,filter_linear_mipmap,repeat_enable;
|
||||
uniform vec4 metallic_texture_channel;
|
||||
uniform sampler2D texture_roughness : hint_roughness_r,filter_linear_mipmap,repeat_enable;
|
||||
uniform float specular;
|
||||
uniform float metallic;
|
||||
uniform vec3 uv1_scale;
|
||||
uniform vec3 uv1_offset;
|
||||
uniform vec3 uv2_scale;
|
||||
uniform vec3 uv2_offset;
|
||||
uniform float color_dark = 0.5;
|
||||
|
||||
|
||||
void vertex() {
|
||||
UV=UV*uv1_scale.xy+uv1_offset.xy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void fragment() {
|
||||
vec2 base_uv = UV;
|
||||
vec4 albedo_tex = texture(texture_albedo,base_uv);
|
||||
ALBEDO = albedo.rgb * albedo_tex.rgb * color_dark;
|
||||
float metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);
|
||||
METALLIC = metallic_tex * metallic;
|
||||
vec4 roughness_texture_channel = vec4(1.0,0.0,0.0,0.0);
|
||||
float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);
|
||||
ROUGHNESS = roughness_tex * roughness;
|
||||
SPECULAR = specular;
|
||||
}
|
||||
"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7cioj"]
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_4f4ck"]
|
||||
render_priority = 0
|
||||
shader = SubResource("Shader_qbwwy")
|
||||
shader = ExtResource("2_04fd1")
|
||||
shader_parameter/albedo = Color(1, 1, 1, 1)
|
||||
shader_parameter/point_size = 1.0
|
||||
shader_parameter/roughness = 1.0
|
||||
shader_parameter/metallic_texture_channel = null
|
||||
shader_parameter/specular = 0.5
|
||||
shader_parameter/metallic = 0.0
|
||||
shader_parameter/metallic = null
|
||||
shader_parameter/uv1_scale = Vector3(1, 1, 1)
|
||||
shader_parameter/uv1_offset = Vector3(0, 0, 0)
|
||||
shader_parameter/uv1_offset = null
|
||||
shader_parameter/uv2_scale = Vector3(1, 1, 1)
|
||||
shader_parameter/uv2_offset = Vector3(0, 0, 0)
|
||||
shader_parameter/color_dark = 1.0
|
||||
shader_parameter/texture_albedo = ExtResource("2_runrf")
|
||||
shader_parameter/uv2_offset = null
|
||||
shader_parameter/is_dark = true
|
||||
shader_parameter/texture_light = ExtResource("3_7tk5i")
|
||||
shader_parameter/texture_dark = ExtResource("3_wxjgd")
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ic8qb"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("3_mot0p")
|
||||
shader_parameter/albedo = Color(1, 1, 1, 1)
|
||||
shader_parameter/point_size = 1.0
|
||||
shader_parameter/roughness = 1.0
|
||||
shader_parameter/metallic_texture_channel = null
|
||||
shader_parameter/specular = 0.5
|
||||
shader_parameter/metallic = null
|
||||
shader_parameter/uv1_scale = Vector3(1, 1, 1)
|
||||
shader_parameter/uv1_offset = null
|
||||
shader_parameter/uv2_scale = Vector3(1, 1, 1)
|
||||
shader_parameter/uv2_offset = null
|
||||
shader_parameter/is_dark = true
|
||||
shader_parameter/texture_light = ExtResource("3_7tk5i")
|
||||
shader_parameter/texture_dark = ExtResource("3_wxjgd")
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_c3ofc"]
|
||||
resource_name = "Material #2137405273"
|
||||
@ -494,10 +472,11 @@ shadow_mesh = SubResource("ArrayMesh_xyf5j")
|
||||
|
||||
[node name="screenDoor" type="Node3D"]
|
||||
script = ExtResource("1_nse1y")
|
||||
mtd_material = SubResource("ShaderMaterial_4f4ck")
|
||||
mtd_fault_material = SubResource("ShaderMaterial_ic8qb")
|
||||
|
||||
[node name="MTD" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.57784, 2.99429, 1.84928)
|
||||
material_override = SubResource("ShaderMaterial_7cioj")
|
||||
mesh = SubResource("ArrayMesh_28g0p")
|
||||
skeleton = NodePath("")
|
||||
|
||||
@ -509,9 +488,9 @@ light_indirect_energy = 2.194
|
||||
light_volumetric_fog_energy = 0.642
|
||||
light_specular = 0.0
|
||||
spot_range = 0.111
|
||||
spot_attenuation = 1.8025
|
||||
spot_attenuation = 1.03526
|
||||
spot_angle = 0.0
|
||||
spot_angle_attenuation = 2.0
|
||||
spot_angle_attenuation = 5.09824
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
|
||||
|
@ -2,29 +2,25 @@ extends Node3D
|
||||
|
||||
class_name TotalScene
|
||||
|
||||
##开始实训,车主动来和开屏蔽门
|
||||
func beginTraining ()-> void:
|
||||
##车来和开屏蔽门和车门
|
||||
func trainComeAndOpenScreenDoor ()-> void:
|
||||
$train.trainCome()
|
||||
$BeginTimer.start()
|
||||
|
||||
func _on_beginTimer_timeout() -> void:
|
||||
$Timer.start()
|
||||
$train.openLeftTrainDoorALL()
|
||||
$platform.openScreenDoorALL()
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
##关屏蔽门和车门
|
||||
func closeScreenDoor() -> void:
|
||||
$train.closeLeftTrainDoorALL()
|
||||
$platform.closeScreenDoorALL()
|
||||
$EndTimer.start()
|
||||
|
||||
func _on_end_timer_timeout() -> void:
|
||||
##车走
|
||||
func trainLeave() -> void:
|
||||
$train.trainLeave()
|
||||
|
||||
|
||||
##关屏蔽门
|
||||
func closeAllScreenDoor() -> void:
|
||||
pass
|
||||
|
||||
## 屏蔽门名字的枚举
|
||||
enum ScreenDoor_name{
|
||||
screenDoor1=1,
|
||||
|
@ -88,14 +88,5 @@ libraries = {
|
||||
wait_time = 3.0
|
||||
one_shot = true
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 15.0
|
||||
one_shot = true
|
||||
|
||||
[node name="EndTimer" type="Timer" parent="."]
|
||||
wait_time = 4.0
|
||||
|
||||
[connection signal="animation_finished" from="trainAnimationPlayer" to="train" method="_on_train_animation_player_animation_finished"]
|
||||
[connection signal="timeout" from="BeginTimer" to="." method="_on_beginTimer_timeout"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||
[connection signal="timeout" from="EndTimer" to="." method="_on_end_timer_timeout"]
|
||||
|
46
shaders/mtd.gdshader
Normal file
46
shaders/mtd.gdshader
Normal file
@ -0,0 +1,46 @@
|
||||
// NOTE: Shader automatically converted from Godot Engine 4.2.2.stable's StandardMaterial3D.
|
||||
|
||||
shader_type spatial;
|
||||
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx;
|
||||
uniform vec4 albedo : source_color;
|
||||
uniform sampler2D texture_light : source_color,filter_linear_mipmap,repeat_enable;
|
||||
uniform sampler2D texture_dark : source_color,filter_linear_mipmap,repeat_enable;
|
||||
uniform float point_size : hint_range(0,128);
|
||||
uniform float roughness : hint_range(0,1);
|
||||
uniform sampler2D texture_metallic : hint_default_white,filter_linear_mipmap,repeat_enable;
|
||||
uniform vec4 metallic_texture_channel;
|
||||
uniform sampler2D texture_roughness : hint_roughness_r,filter_linear_mipmap,repeat_enable;
|
||||
uniform float specular;
|
||||
uniform float metallic;
|
||||
uniform vec3 uv1_scale;
|
||||
uniform vec3 uv1_offset;
|
||||
uniform vec3 uv2_scale;
|
||||
uniform vec3 uv2_offset;
|
||||
uniform bool is_dark;
|
||||
|
||||
|
||||
void vertex() {
|
||||
UV=UV*uv1_scale.xy+uv1_offset.xy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void fragment() {
|
||||
vec2 base_uv = UV;
|
||||
if(is_dark) {
|
||||
vec4 albedo_tex = texture(texture_dark,base_uv);
|
||||
ALBEDO = albedo.rgb * albedo_tex.rgb * 0.8;
|
||||
} else {
|
||||
vec4 albedo_tex = texture(texture_light,base_uv);
|
||||
ALBEDO = albedo.rgb * albedo_tex.rgb * 1.5;
|
||||
}
|
||||
float metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);
|
||||
METALLIC = metallic_tex * metallic;
|
||||
vec4 roughness_texture_channel = vec4(1.0,0.0,0.0,0.0);
|
||||
float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);
|
||||
ROUGHNESS = roughness_tex * roughness;
|
||||
SPECULAR = specular;
|
||||
}
|
46
shaders/mtd_fault.gdshader
Normal file
46
shaders/mtd_fault.gdshader
Normal file
@ -0,0 +1,46 @@
|
||||
// NOTE: Shader automatically converted from Godot Engine 4.2.2.stable's StandardMaterial3D.
|
||||
|
||||
shader_type spatial;
|
||||
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx;
|
||||
uniform vec4 albedo : source_color;
|
||||
uniform sampler2D texture_light : source_color,filter_linear_mipmap,repeat_enable;
|
||||
uniform sampler2D texture_dark : source_color,filter_linear_mipmap,repeat_enable;
|
||||
uniform float point_size : hint_range(0,128);
|
||||
uniform float roughness : hint_range(0,1);
|
||||
uniform sampler2D texture_metallic : hint_default_white,filter_linear_mipmap,repeat_enable;
|
||||
uniform vec4 metallic_texture_channel;
|
||||
uniform sampler2D texture_roughness : hint_roughness_r,filter_linear_mipmap,repeat_enable;
|
||||
uniform float specular;
|
||||
uniform float metallic;
|
||||
uniform vec3 uv1_scale;
|
||||
uniform vec3 uv1_offset;
|
||||
uniform vec3 uv2_scale;
|
||||
uniform vec3 uv2_offset;
|
||||
uniform bool is_dark;
|
||||
|
||||
|
||||
void vertex() {
|
||||
UV=UV*uv1_scale.xy+uv1_offset.xy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void fragment() {
|
||||
vec2 base_uv = UV;
|
||||
if(is_dark) {
|
||||
vec4 albedo_tex = texture(texture_dark,base_uv);
|
||||
ALBEDO = albedo.rgb * albedo_tex.rgb * 0.8;
|
||||
} else {
|
||||
vec4 albedo_tex = texture(texture_light,base_uv);
|
||||
ALBEDO = albedo.rgb * albedo_tex.rgb * 1.5;
|
||||
}
|
||||
float metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);
|
||||
METALLIC = metallic_tex * metallic;
|
||||
vec4 roughness_texture_channel = vec4(1.0,0.0,0.0,0.0);
|
||||
float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);
|
||||
ROUGHNESS = roughness_tex * roughness;
|
||||
SPECULAR = specular;
|
||||
}
|
@ -11,5 +11,5 @@ func _ready():
|
||||
|
||||
|
||||
func _on_training_desc_dialog_start_training():
|
||||
$total.beginTraining()
|
||||
$total.trainComeAndOpenScreenDoor()
|
||||
$total.setAssignScreenDoorsOpenFault([TotalScene.ScreenDoor_name.screenDoor2])
|
||||
|
Loading…
Reference in New Issue
Block a user