generated from krampus/template-godot4
CSG carving for more interesting metro rooftops
All checks were successful
linting & formatting / build (push) Successful in 12s
All checks were successful
linting & formatting / build (push) Successful in 12s
This commit is contained in:
parent
9cb5de8e93
commit
ba8461068b
@ -3,7 +3,22 @@ class_name MetroConstructSimple extends GenerationFeature
|
||||
@export var min_height := 48.0
|
||||
@export var height_factor := 200.0
|
||||
|
||||
@export var p_roof_carve := 0.2
|
||||
|
||||
@onready var construct_box: CSGBox3D = %ConstructBox
|
||||
@onready var carve_pivot: CSGCombiner3D = %CarvePivot
|
||||
|
||||
|
||||
func generate_carve() -> void:
|
||||
var carve_value := absf(sample_noise_at(global_position + Vector3(0, 65535, 0)))
|
||||
if wrapf(carve_value * 65535.0, 0, 1) < p_roof_carve:
|
||||
carve_pivot.position.y = construct_box.position.y
|
||||
|
||||
var rotate_value := absf(sample_noise_at(global_position + Vector3(0, 42069, 0)))
|
||||
var rotations := floorf(wrapf(rotate_value * 65535, 0, 8))
|
||||
carve_pivot.rotation.y = rotations * PI / 4
|
||||
else:
|
||||
carve_pivot.queue_free()
|
||||
|
||||
|
||||
func generate_feature(lod: WorldGen.LOD) -> void:
|
||||
@ -13,3 +28,4 @@ func generate_feature(lod: WorldGen.LOD) -> void:
|
||||
var height := value * height_factor + min_height
|
||||
construct_box.position.y = height / 2
|
||||
construct_box.size.y = height
|
||||
generate_carve()
|
||||
|
||||
@ -42,3 +42,12 @@ size = Vector3(48, 48, 48)
|
||||
script = ExtResource("2_74b57")
|
||||
lod = 2
|
||||
metadata/_custom_type_script = "uid://cv0o1lirqeq44"
|
||||
|
||||
[node name="CarvePivot" type="CSGCombiner3D" parent="ConstructBox"]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 24, 0)
|
||||
operation = 2
|
||||
|
||||
[node name="CarveBox" type="CSGBox3D" parent="ConstructBox/CarvePivot"]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.70710677, -0.70710677, 0, 0.70710677, 0.70710677, 0, 0, 24)
|
||||
size = Vector3(100, 48, 100)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user