generated from krampus/template-godot4
Feature & layer concepts in worldgen
This commit is contained in:
parent
2792a1681a
commit
16c76aeb72
@ -118,6 +118,8 @@ metadata/_custom_type_script = "uid://d11erhxna68vd"
|
|||||||
[node name="DebugMovement" type="Node" parent="."]
|
[node name="DebugMovement" type="Node" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
script = ExtResource("10_ylhto")
|
script = ExtResource("10_ylhto")
|
||||||
|
normal_speed = 500.0
|
||||||
|
fast_speed = 1000.0
|
||||||
metadata/_custom_type_script = "uid://htwqrc73xg7q"
|
metadata/_custom_type_script = "uid://htwqrc73xg7q"
|
||||||
|
|
||||||
[node name="DebugHUD" type="CanvasLayer" parent="." node_paths=PackedStringArray("player")]
|
[node name="DebugHUD" type="CanvasLayer" parent="." node_paths=PackedStringArray("player")]
|
||||||
|
|||||||
9
src/world/generation/feature/generation_feature.gd
Normal file
9
src/world/generation/feature/generation_feature.gd
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
class_name GenerationFeature extends Node3D
|
||||||
|
## Base class for world features generated during worldgen.
|
||||||
|
##
|
||||||
|
## Layers contain features. Some features may contain layers.
|
||||||
|
|
||||||
|
|
||||||
|
func probe() -> void:
|
||||||
|
# TODO may want to make low-detail & high-detail probes distinct
|
||||||
|
pass # Implemented in derived type.
|
||||||
1
src/world/generation/feature/generation_feature.gd.uid
Normal file
1
src/world/generation/feature/generation_feature.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://drk82eeqk2mjs
|
||||||
@ -1,21 +1,10 @@
|
|||||||
class_name GeneratedWorld extends Node3D
|
class_name GeneratedWorld extends Node3D
|
||||||
|
|
||||||
@export var generation_radius := 6.0
|
|
||||||
|
|
||||||
var chunks: Dictionary[Vector2, Chunk] = {}
|
|
||||||
|
|
||||||
|
|
||||||
func get_chunk(chunk_pos: Vector2) -> Chunk:
|
|
||||||
if chunk_pos not in chunks:
|
|
||||||
var chunk := Chunk.generate_chunk(chunk_pos)
|
|
||||||
add_child(chunk)
|
|
||||||
chunks[chunk_pos] = chunk
|
|
||||||
return chunks[chunk_pos]
|
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
var camera := get_viewport().get_camera_3d()
|
# Probe all child generation layers & features each frame
|
||||||
var center := Chunk.world_to_chunk(camera.global_position)
|
for c: Node in get_children():
|
||||||
for x in range(center.x - generation_radius, center.x + generation_radius):
|
if c is GenerationLayer:
|
||||||
for y in range(center.y - generation_radius, center.y + generation_radius):
|
(c as GenerationLayer).probe()
|
||||||
get_chunk(Vector2(x, y))
|
elif c is GenerationFeature:
|
||||||
|
(c as GenerationFeature).probe()
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://cop4mkrv70yhc"]
|
[gd_scene load_steps=3 format=3 uid="uid://cop4mkrv70yhc"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dka00cyvfr21t" path="res://src/world/generation/generated_world.gd" id="1_m2u13"]
|
[ext_resource type="Script" uid="uid://dka00cyvfr21t" path="res://src/world/generation/generated_world.gd" id="1_m2u13"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dlhc1te2ip8vg" path="res://src/world/generation/layer/arcology_grid_layer/arcology_grid_layer.tscn" id="2_k55gd"]
|
||||||
|
|
||||||
[node name="GeneratedWorld" type="Node3D"]
|
[node name="GeneratedWorld" type="Node3D"]
|
||||||
script = ExtResource("1_m2u13")
|
script = ExtResource("1_m2u13")
|
||||||
|
|
||||||
|
[node name="ArcologyGridLayer" parent="." instance=ExtResource("2_k55gd")]
|
||||||
|
|||||||
7
src/world/generation/layer/generation_layer.gd
Normal file
7
src/world/generation/layer/generation_layer.gd
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
class_name GenerationLayer extends Node3D
|
||||||
|
## A composite layer of world generation logic.
|
||||||
|
|
||||||
|
|
||||||
|
## Probe this layer and any sub-layers at the world generation point, generating features as needed.
|
||||||
|
func probe() -> void:
|
||||||
|
pass # Implement in derived type
|
||||||
1
src/world/generation/layer/generation_layer.gd.uid
Normal file
1
src/world/generation/layer/generation_layer.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://ciq8lxydnfc77
|
||||||
@ -2,3 +2,20 @@ class_name WorldGenManagerType extends Node
|
|||||||
## Global autoloaded singleton controller for worldgen parameters
|
## Global autoloaded singleton controller for worldgen parameters
|
||||||
|
|
||||||
@export var noise: FastNoiseLite
|
@export var noise: FastNoiseLite
|
||||||
|
|
||||||
|
## Generate features with the lowest detail, like large distant structures, within this radius
|
||||||
|
@export var low_detail_radius := 100000.0
|
||||||
|
## Generate features with medium detail, like buildings, within this radius
|
||||||
|
@export var med_detail_radius := 1024.0
|
||||||
|
## Generate features with high detail, like small complicated objects, within this radius
|
||||||
|
@export var high_detail_radius := 64.0
|
||||||
|
|
||||||
|
|
||||||
|
## Get the world-space coordinate to generate around.
|
||||||
|
func get_generation_point() -> Vector3:
|
||||||
|
var viewport := get_viewport()
|
||||||
|
if viewport:
|
||||||
|
var camera := viewport.get_camera_3d()
|
||||||
|
if camera:
|
||||||
|
return camera.global_position
|
||||||
|
return Vector3.ZERO
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://dtbulshrxetes" path="res://src/player/player.tscn" id="1_1k4gi"]
|
[ext_resource type="PackedScene" uid="uid://dtbulshrxetes" path="res://src/player/player.tscn" id="1_1k4gi"]
|
||||||
[ext_resource type="Script" uid="uid://bd046eokvcnu2" path="res://addons/phantom_camera/scripts/phantom_camera_host/phantom_camera_host.gd" id="2_6fy3g"]
|
[ext_resource type="Script" uid="uid://bd046eokvcnu2" path="res://addons/phantom_camera/scripts/phantom_camera_host/phantom_camera_host.gd" id="2_6fy3g"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cop4mkrv70yhc" path="res://src/world/generation/generated_world.tscn" id="2_jte2u"]
|
[ext_resource type="PackedScene" uid="uid://cop4mkrv70yhc" path="res://src/world/generation/generated_world.tscn" id="3_jte2u"]
|
||||||
|
|
||||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_6fy3g"]
|
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_6fy3g"]
|
||||||
sky_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
|
sky_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
|
||||||
@ -56,18 +56,16 @@ data = PackedVector3Array(-0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0
|
|||||||
environment = SubResource("Environment_bsf3i")
|
environment = SubResource("Environment_bsf3i")
|
||||||
|
|
||||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
transform = Transform3D(-0.8660254, -0.43301278, 0.25, 0, 0.49999997, 0.86602545, -0.50000006, 0.75, -0.43301266, 0, 0, 0)
|
transform = Transform3D(-0.54954004, 0.51725316, -0.6560906, -0.17890637, 0.69422466, 0.69716895, 0.8160872, 0.5005011, -0.2889644, 0, 0, 0)
|
||||||
shadow_enabled = true
|
shadow_enabled = true
|
||||||
directional_shadow_split_1 = 0.015
|
directional_shadow_split_1 = 0.015
|
||||||
directional_shadow_split_2 = 0.105
|
directional_shadow_split_2 = 0.105
|
||||||
directional_shadow_max_distance = 400.0
|
directional_shadow_max_distance = 400.0
|
||||||
|
|
||||||
[node name="GeneratedWorld" parent="." instance=ExtResource("2_jte2u")]
|
|
||||||
|
|
||||||
[node name="Camera3D" type="Camera3D" parent="."]
|
[node name="Camera3D" type="Camera3D" parent="."]
|
||||||
physics_interpolation_mode = 1
|
physics_interpolation_mode = 1
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 121.5, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 121.5, 0)
|
||||||
far = 40000.0
|
far = 100000.0
|
||||||
|
|
||||||
[node name="PhantomCameraHost" type="Node" parent="Camera3D"]
|
[node name="PhantomCameraHost" type="Node" parent="Camera3D"]
|
||||||
process_priority = 300
|
process_priority = 300
|
||||||
@ -100,23 +98,4 @@ skeleton = NodePath("../..")
|
|||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerSpawn/ReferenceCube/StaticBody3D"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerSpawn/ReferenceCube/StaticBody3D"]
|
||||||
shape = SubResource("ConcavePolygonShape3D_6fy3g")
|
shape = SubResource("ConcavePolygonShape3D_6fy3g")
|
||||||
|
|
||||||
[node name="BigTorus" type="CSGTorus3D" parent="."]
|
[node name="GeneratedWorld" parent="." instance=ExtResource("3_jte2u")]
|
||||||
transform = Transform3D(-0.76604444, 0.64278764, 0, -0.5421216, -0.6460753, -0.53729963, -0.34536955, -0.4115954, 0.8433914, 10000, 2000, 0)
|
|
||||||
inner_radius = 4000.0
|
|
||||||
outer_radius = 8000.0
|
|
||||||
sides = 32
|
|
||||||
ring_sides = 16
|
|
||||||
|
|
||||||
[node name="FarTower" type="CSGCylinder3D" parent="."]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5000, -4000)
|
|
||||||
radius = 2000.0
|
|
||||||
height = 10000.0
|
|
||||||
sides = 32
|
|
||||||
cone = true
|
|
||||||
|
|
||||||
[node name="NearTower" type="CSGCylinder3D" parent="."]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -600, 500, -400)
|
|
||||||
radius = 200.0
|
|
||||||
height = 1000.0
|
|
||||||
sides = 32
|
|
||||||
cone = true
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user