generated from krampus/template-godot4
Added path-based guard rails
This commit is contained in:
parent
1bd11434e4
commit
9d6a902d78
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cxeela02ysscf"
|
||||||
|
path="res://.godot/imported/guard_rail_post.png-4447ff881a5916e5281ed251b7beecd0.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/textures/guard_rail/guard_rail_post.png"
|
||||||
|
dest_files=["res://.godot/imported/guard_rail_post.png-4447ff881a5916e5281ed251b7beecd0.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=true
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=0
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=38 format=3 uid="uid://bm2o3mex10v11"]
|
[gd_scene load_steps=40 format=3 uid="uid://bm2o3mex10v11"]
|
||||||
|
|
||||||
[ext_resource type="Terrain3DStorage" uid="uid://bu1gewgsgc5hm" path="res://levels/debug_level/terrain_3d_storage.res" id="1_nlsu2"]
|
[ext_resource type="Terrain3DStorage" uid="uid://bu1gewgsgc5hm" path="res://levels/debug_level/terrain_3d_storage.res" id="1_nlsu2"]
|
||||||
[ext_resource type="Texture2D" path="res://assets/textures/grass_fairway/grass_fairway_albedo.dds" id="2_e4m27"]
|
[ext_resource type="Texture2D" path="res://assets/textures/grass_fairway/grass_fairway_albedo.dds" id="2_e4m27"]
|
||||||
|
@ -15,6 +15,7 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://di7aql54lksn7" path="res://src/props/scenery/trees/palm_tree/palm_tree.tscn" id="12_sswxf"]
|
[ext_resource type="PackedScene" uid="uid://di7aql54lksn7" path="res://src/props/scenery/trees/palm_tree/palm_tree.tscn" id="12_sswxf"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c7l58wuuahn7w" path="res://src/props/flag/flag.tscn" id="13_6jtao"]
|
[ext_resource type="PackedScene" uid="uid://c7l58wuuahn7w" path="res://src/props/flag/flag.tscn" id="13_6jtao"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dj60e8ri2fco" path="res://assets/models/scenery/city/concrete_building_1/concrete_building_1.png" id="14_y7s2h"]
|
[ext_resource type="Texture2D" uid="uid://dj60e8ri2fco" path="res://assets/models/scenery/city/concrete_building_1/concrete_building_1.png" id="14_y7s2h"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://nqar1qcun8ax" path="res://src/props/scenery/highway/guard_rail.tscn" id="16_xtxyj"]
|
||||||
|
|
||||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_rpgb7"]
|
[sub_resource type="FastNoiseLite" id="FastNoiseLite_rpgb7"]
|
||||||
noise_type = 0
|
noise_type = 0
|
||||||
|
@ -163,6 +164,13 @@ albedo_color = Color(0.427451, 0.917647, 1, 1)
|
||||||
material = SubResource("StandardMaterial3D_65jc8")
|
material = SubResource("StandardMaterial3D_65jc8")
|
||||||
size = Vector2(65536, 65536)
|
size = Vector2(65536, 65536)
|
||||||
|
|
||||||
|
[sub_resource type="Curve3D" id="Curve3D_3gyu3"]
|
||||||
|
_data = {
|
||||||
|
"points": PackedVector3Array(-4.50073, 0, 25.6049, 4.501, 0, -18.73, -15.152, 0, 5.61563, -20.4021, 0, 1.25826, 20.4021, 0, -1.25826, 25.991, 0, -27.2219, -9.077, 0, -17.164, 6.41687, 0, 33.4636, 72.1845, 0, 6.57864),
|
||||||
|
"tilts": PackedFloat32Array(0, 0, 0)
|
||||||
|
}
|
||||||
|
point_count = 3
|
||||||
|
|
||||||
[node name="TestLevel" type="Node3D"]
|
[node name="TestLevel" type="Node3D"]
|
||||||
|
|
||||||
[node name="Terrain3D" type="Terrain3D" parent="."]
|
[node name="Terrain3D" type="Terrain3D" parent="."]
|
||||||
|
@ -242,3 +250,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 540, 4, 452)
|
||||||
|
|
||||||
[node name="ShotSetup" parent="Course" instance=ExtResource("8_h44v5")]
|
[node name="ShotSetup" parent="Course" instance=ExtResource("8_h44v5")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 212.717, 4, 294.073)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 212.717, 4, 294.073)
|
||||||
|
|
||||||
|
[node name="GuardRail" parent="." instance=ExtResource("16_xtxyj")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 211.416, 4, 288.708)
|
||||||
|
curve = SubResource("Curve3D_3gyu3")
|
||||||
|
|
|
@ -169,7 +169,7 @@ bones/23/scale = Vector3(1, 1, 1)
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
[node name="BoneAttachment3D" type="BoneAttachment3D" parent="Armature/Skeleton3D" index="6"]
|
[node name="BoneAttachment3D" type="BoneAttachment3D" parent="Armature/Skeleton3D" index="6"]
|
||||||
transform = Transform3D(-0.944824, 0.316851, -0.0831418, -0.326496, -0.931474, 0.160486, -0.0265942, 0.178777, 0.98353, -0.1687, 3.14973, 0.864426)
|
transform = Transform3D(-0.944824, 0.316851, -0.0831417, -0.326395, -0.932135, 0.156815, -0.027812, 0.1753, 0.984122, -0.1687, 3.13445, 0.86185)
|
||||||
bone_name = "Hand.R"
|
bone_name = "Hand.R"
|
||||||
bone_idx = 11
|
bone_idx = 11
|
||||||
|
|
||||||
|
|
|
@ -487,7 +487,7 @@ shader_parameter/change_color_depth = true
|
||||||
shader_parameter/target_color_depth = 6
|
shader_parameter/target_color_depth = 6
|
||||||
shader_parameter/dithering = true
|
shader_parameter/dithering = true
|
||||||
shader_parameter/scale_resolution = true
|
shader_parameter/scale_resolution = true
|
||||||
shader_parameter/target_resolution_scale = 2
|
shader_parameter/target_resolution_scale = 3
|
||||||
shader_parameter/enable_recolor = false
|
shader_parameter/enable_recolor = false
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_pk1s7"]
|
[sub_resource type="Animation" id="Animation_pk1s7"]
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
@tool
|
||||||
|
extends Path3D
|
||||||
|
## Guard rail along a curve with nicely spaced posts
|
||||||
|
##
|
||||||
|
## Ref: https://www.youtube.com/watch?v=Gfpnxg-jne4
|
||||||
|
|
||||||
|
## Distance between railing posts, in meters
|
||||||
|
@export var post_space := 4.0:
|
||||||
|
set(value):
|
||||||
|
if value != post_space:
|
||||||
|
_dirty = true
|
||||||
|
post_space = value
|
||||||
|
|
||||||
|
## If enabled, always places a railing post at the end of the curve.
|
||||||
|
## Post spacing will be adjusted to accomodate.
|
||||||
|
@export var end_cap := false:
|
||||||
|
set(value):
|
||||||
|
if value != end_cap:
|
||||||
|
_dirty = true
|
||||||
|
end_cap = value
|
||||||
|
|
||||||
|
var _dirty := false
|
||||||
|
|
||||||
|
@onready var post_multi_mesh: MultiMeshInstance3D = $PostMultiMesh
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
post_multi_mesh.multimesh = post_multi_mesh.multimesh.duplicate()
|
||||||
|
|
||||||
|
|
||||||
|
func _update_multimesh() -> void:
|
||||||
|
if not curve:
|
||||||
|
post_multi_mesh.multimesh.instance_count = 0
|
||||||
|
return
|
||||||
|
|
||||||
|
var path_length := curve.get_baked_length()
|
||||||
|
var count: int = floor(path_length / post_space)
|
||||||
|
var spacing := post_space
|
||||||
|
|
||||||
|
if end_cap:
|
||||||
|
spacing = path_length / float(count)
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
post_multi_mesh.multimesh.instance_count = count
|
||||||
|
|
||||||
|
for i in range(0, count):
|
||||||
|
var tx := curve.sample_baked_with_rotation(spacing * i, true, true)
|
||||||
|
post_multi_mesh.multimesh.set_instance_transform(i, tx)
|
||||||
|
|
||||||
|
|
||||||
|
func _process(_delta: float) -> void:
|
||||||
|
if _dirty:
|
||||||
|
_update_multimesh()
|
||||||
|
_dirty = false
|
||||||
|
|
||||||
|
|
||||||
|
func _on_curve_changed() -> void:
|
||||||
|
_dirty = true
|
|
@ -0,0 +1,62 @@
|
||||||
|
[gd_scene load_steps=6 format=3 uid="uid://nqar1qcun8ax"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://src/props/scenery/highway/guard_rail.gd" id="1_imntf"]
|
||||||
|
|
||||||
|
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_fo7j3"]
|
||||||
|
load_path = "res://.godot/imported/guard_rail_post.png-4447ff881a5916e5281ed251b7beecd0.ctex"
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_k1yjg"]
|
||||||
|
transparency = 2
|
||||||
|
alpha_scissor_threshold = 0.5
|
||||||
|
alpha_antialiasing_mode = 0
|
||||||
|
albedo_texture = SubResource("CompressedTexture2D_fo7j3")
|
||||||
|
texture_filter = 4
|
||||||
|
texture_repeat = false
|
||||||
|
billboard_mode = 2
|
||||||
|
|
||||||
|
[sub_resource type="PlaneMesh" id="PlaneMesh_ko4yv"]
|
||||||
|
material = SubResource("StandardMaterial3D_k1yjg")
|
||||||
|
size = Vector2(0.5, 1)
|
||||||
|
center_offset = Vector3(0, 0.5, 0)
|
||||||
|
orientation = 2
|
||||||
|
|
||||||
|
[sub_resource type="MultiMesh" id="MultiMesh_o7ch8"]
|
||||||
|
transform_format = 1
|
||||||
|
mesh = SubResource("PlaneMesh_ko4yv")
|
||||||
|
|
||||||
|
[node name="GuardRail" type="Path3D"]
|
||||||
|
script = ExtResource("1_imntf")
|
||||||
|
end_cap = true
|
||||||
|
|
||||||
|
[node name="UpperRail" type="CSGPolygon3D" parent="."]
|
||||||
|
use_collision = true
|
||||||
|
polygon = PackedVector2Array(0, 0.8, -0.01, 0.9, 0, 1, 0.01, 0.9)
|
||||||
|
mode = 2
|
||||||
|
path_node = NodePath("..")
|
||||||
|
path_interval_type = 0
|
||||||
|
path_interval = 1.0
|
||||||
|
path_simplify_angle = 0.0
|
||||||
|
path_rotation = 2
|
||||||
|
path_local = true
|
||||||
|
path_continuous_u = true
|
||||||
|
path_u_distance = 1.0
|
||||||
|
path_joined = false
|
||||||
|
|
||||||
|
[node name="LowerRail" type="CSGPolygon3D" parent="."]
|
||||||
|
use_collision = true
|
||||||
|
polygon = PackedVector2Array(0, 0.4, -0.01, 0.5, 0, 0.6, 0.01, 0.5)
|
||||||
|
mode = 2
|
||||||
|
path_node = NodePath("..")
|
||||||
|
path_interval_type = 0
|
||||||
|
path_interval = 1.0
|
||||||
|
path_simplify_angle = 0.0
|
||||||
|
path_rotation = 2
|
||||||
|
path_local = true
|
||||||
|
path_continuous_u = true
|
||||||
|
path_u_distance = 1.0
|
||||||
|
path_joined = false
|
||||||
|
|
||||||
|
[node name="PostMultiMesh" type="MultiMeshInstance3D" parent="."]
|
||||||
|
multimesh = SubResource("MultiMesh_o7ch8")
|
||||||
|
|
||||||
|
[connection signal="curve_changed" from="." to="." method="_on_curve_changed"]
|
|
@ -24,7 +24,9 @@ grow_vertical = 2
|
||||||
stretch = true
|
stretch = true
|
||||||
|
|
||||||
[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"]
|
[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"]
|
||||||
|
handle_input_locally = false
|
||||||
size = Vector2i(1280, 720)
|
size = Vector2i(1280, 720)
|
||||||
|
render_target_update_mode = 4
|
||||||
|
|
||||||
[node name="Level" type="Node3D" parent="SubViewportContainer/SubViewport"]
|
[node name="Level" type="Node3D" parent="SubViewportContainer/SubViewport"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue