feat(composition): dive world assembled from a selected site definition
The calibration site spawn sat 16 m from the south bounds edge, inside the 40 m warning margin. The vehicle_test recipe now extends the terrain and playable bounds 42 m to the south so the spawn is inside the zone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bbf1dc9990
commit
51634820bd
12 files changed
+154
-258
No files matched your search
@@ -1,153 +0,0 @@
|
||||
class_name VehicleTestEnvironment
|
||||
extends Node3D
|
||||
|
||||
const TERRAIN_COLUMNS := 61
|
||||
const TERRAIN_ROWS := 69
|
||||
const TERRAIN_WIDTH_M := 180.0
|
||||
const TERRAIN_LENGTH_M := 200.0
|
||||
const TERRAIN_NEAR_Z := 28.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_add_bathymetric_terrain()
|
||||
_place_calibration_target()
|
||||
_add_suspended_particles()
|
||||
|
||||
|
||||
func _add_suspended_particles() -> void:
|
||||
var particles := GPUParticles3D.new()
|
||||
particles.name = "SuspendedParticles"
|
||||
particles.position = Vector3(0.0, -34.0, -42.0)
|
||||
particles.amount = 360
|
||||
particles.lifetime = 14.0
|
||||
particles.preprocess = 14.0
|
||||
particles.visibility_aabb = AABB(
|
||||
Vector3(-50.0, -35.0, -78.0),
|
||||
Vector3(100.0, 70.0, 156.0)
|
||||
)
|
||||
|
||||
var motion := ParticleProcessMaterial.new()
|
||||
motion.emission_shape = ParticleProcessMaterial.EMISSION_SHAPE_BOX
|
||||
motion.emission_box_extents = Vector3(45.0, 28.0, 70.0)
|
||||
motion.direction = Vector3(0.1, 0.04, 0.0)
|
||||
motion.spread = 180.0
|
||||
motion.initial_velocity_min = 0.02
|
||||
motion.initial_velocity_max = 0.09
|
||||
motion.gravity = Vector3.ZERO
|
||||
motion.scale_min = 0.025
|
||||
motion.scale_max = 0.08
|
||||
particles.process_material = motion
|
||||
|
||||
var particle_mesh := SphereMesh.new()
|
||||
particle_mesh.radius = 0.035
|
||||
particle_mesh.height = 0.07
|
||||
particles.draw_pass_1 = particle_mesh
|
||||
add_child(particles)
|
||||
|
||||
|
||||
func _add_bathymetric_terrain() -> void:
|
||||
var surface := SurfaceTool.new()
|
||||
surface.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
for row in range(TERRAIN_ROWS - 1):
|
||||
for column in range(TERRAIN_COLUMNS - 1):
|
||||
var top_left := _terrain_vertex(row, column)
|
||||
var top_right := _terrain_vertex(row, column + 1)
|
||||
var bottom_left := _terrain_vertex(row + 1, column)
|
||||
var bottom_right := _terrain_vertex(row + 1, column + 1)
|
||||
_add_terrain_triangle(surface, top_left, top_right, bottom_left)
|
||||
_add_terrain_triangle(surface, top_right, bottom_right, bottom_left)
|
||||
surface.generate_normals()
|
||||
var mesh := surface.commit()
|
||||
|
||||
var body := StaticBody3D.new()
|
||||
body.name = "BathymetricTerrain"
|
||||
body.set_meta("sonar_material", 1)
|
||||
body.set_meta("sonar_reflectivity", 0.72)
|
||||
var mesh_instance := MeshInstance3D.new()
|
||||
mesh_instance.name = "Mesh"
|
||||
mesh_instance.mesh = mesh
|
||||
var material := StandardMaterial3D.new()
|
||||
material.albedo_color = Color(0.075, 0.19, 0.19)
|
||||
material.roughness = 0.92
|
||||
mesh_instance.material_override = material
|
||||
body.add_child(mesh_instance)
|
||||
var collision := CollisionShape3D.new()
|
||||
collision.name = "Collision"
|
||||
var height_map := HeightMapShape3D.new()
|
||||
height_map.map_width = TERRAIN_COLUMNS
|
||||
height_map.map_depth = TERRAIN_ROWS
|
||||
var height_data := PackedFloat32Array()
|
||||
height_data.resize(TERRAIN_COLUMNS * TERRAIN_ROWS)
|
||||
for row in TERRAIN_ROWS:
|
||||
for column in TERRAIN_COLUMNS:
|
||||
var vertex := _terrain_vertex(row, column)
|
||||
height_data[row * TERRAIN_COLUMNS + column] = vertex.y
|
||||
height_map.map_data = height_data
|
||||
collision.shape = height_map
|
||||
collision.position = Vector3(
|
||||
0.0,
|
||||
0.0,
|
||||
TERRAIN_NEAR_Z - TERRAIN_LENGTH_M * 0.5
|
||||
)
|
||||
collision.scale = Vector3(
|
||||
TERRAIN_WIDTH_M / float(TERRAIN_COLUMNS - 1),
|
||||
1.0,
|
||||
TERRAIN_LENGTH_M / float(TERRAIN_ROWS - 1)
|
||||
)
|
||||
body.add_child(collision)
|
||||
add_child(body)
|
||||
|
||||
|
||||
func _terrain_vertex(row: int, column: int) -> Vector3:
|
||||
var x := lerpf(
|
||||
-TERRAIN_WIDTH_M * 0.5,
|
||||
TERRAIN_WIDTH_M * 0.5,
|
||||
float(column) / float(TERRAIN_COLUMNS - 1)
|
||||
)
|
||||
var z := TERRAIN_NEAR_Z - (
|
||||
TERRAIN_LENGTH_M * float(row) / float(TERRAIN_ROWS - 1)
|
||||
)
|
||||
return Vector3(x, _terrain_height(x, z), z)
|
||||
|
||||
|
||||
func _terrain_height(x: float, z: float) -> float:
|
||||
var distance_ratio := clampf(
|
||||
(TERRAIN_NEAR_Z - z) / TERRAIN_LENGTH_M,
|
||||
0.0,
|
||||
1.0
|
||||
)
|
||||
var base := lerpf(-40.0, -78.0, distance_ratio)
|
||||
var left_ridge := 13.0 * exp(
|
||||
-(pow(x + 24.0, 2.0) / 210.0 + pow(z + 48.0, 2.0) / 980.0)
|
||||
)
|
||||
var right_ridge := 15.0 * exp(
|
||||
-(pow(x - 25.0, 2.0) / 250.0 + pow(z + 58.0, 2.0) / 1150.0)
|
||||
)
|
||||
var channel := -8.5 * exp(
|
||||
-(pow(x, 2.0) / 120.0 + pow(z + 66.0, 2.0) / 2500.0)
|
||||
)
|
||||
var rear_rise := 8.0 * exp(
|
||||
-(pow(x + 5.0, 2.0) / 900.0 + pow(z + 125.0, 2.0) / 620.0)
|
||||
)
|
||||
var undulation := 1.8 * sin(x * 0.075) * cos(z * 0.048)
|
||||
return base + left_ridge + right_ridge + channel + rear_rise + undulation
|
||||
|
||||
|
||||
func _add_terrain_triangle(
|
||||
surface: SurfaceTool,
|
||||
a: Vector3,
|
||||
b: Vector3,
|
||||
c: Vector3
|
||||
) -> void:
|
||||
surface.set_uv(Vector2(a.x, a.z) * 0.02)
|
||||
surface.add_vertex(a)
|
||||
surface.set_uv(Vector2(b.x, b.z) * 0.02)
|
||||
surface.add_vertex(b)
|
||||
surface.set_uv(Vector2(c.x, c.z) * 0.02)
|
||||
surface.add_vertex(c)
|
||||
|
||||
|
||||
func _place_calibration_target() -> void:
|
||||
var target := get_node_or_null("SonarCalibrationTarget") as Node3D
|
||||
if target != null:
|
||||
target.position.y = _terrain_height(target.position.x, target.position.z) + 2.5
|
||||
@@ -1,75 +0,0 @@
|
||||
[gd_scene load_steps=8 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://game/world/sites/vehicle_test_environment.gd" id="1_environment"]
|
||||
|
||||
[sub_resource type="Environment" id="EnvironmentUnderwater"]
|
||||
background_mode = 1
|
||||
background_color = Color(0.005, 0.045, 0.065, 1)
|
||||
ambient_light_source = 3
|
||||
ambient_light_color = Color(0.12, 0.32, 0.37, 1)
|
||||
ambient_light_energy = 0.42
|
||||
fog_enabled = true
|
||||
fog_light_color = Color(0.07, 0.25, 0.3, 1)
|
||||
fog_light_energy = 0.48
|
||||
fog_density = 0.014
|
||||
fog_height = -4.0
|
||||
fog_height_density = 0.025
|
||||
volumetric_fog_enabled = true
|
||||
volumetric_fog_density = 0.025
|
||||
volumetric_fog_length = 72.0
|
||||
|
||||
[sub_resource type="SphereMesh" id="BeaconMesh"]
|
||||
radius = 0.55
|
||||
height = 1.1
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="MetalTargetMaterial"]
|
||||
albedo_color = Color(0.24, 0.18, 0.08, 1)
|
||||
metallic = 0.88
|
||||
roughness = 0.27
|
||||
|
||||
[sub_resource type="BoxMesh" id="MetalTargetMesh"]
|
||||
size = Vector3(8, 5, 7)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="MetalTargetShape"]
|
||||
size = Vector3(8, 5, 7)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="BeaconMaterial"]
|
||||
shading_mode = 0
|
||||
albedo_color = Color(0.2, 0.78, 0.9, 1)
|
||||
emission_enabled = true
|
||||
emission = Color(0.2, 0.78, 0.9, 1)
|
||||
emission_energy_multiplier = 5.0
|
||||
|
||||
[node name="VehicleTestEnvironment" type="Node3D"]
|
||||
script = ExtResource("1_environment")
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("EnvironmentUnderwater")
|
||||
|
||||
[node name="AmbientDirection" type="DirectionalLight3D" parent="."]
|
||||
rotation_degrees = Vector3(-52, -24, 0)
|
||||
light_color = Color(0.39, 0.65, 0.7, 1)
|
||||
light_energy = 0.38
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="NavigationBeacon" type="MeshInstance3D" parent="."]
|
||||
position = Vector3(0, -15, -22)
|
||||
mesh = SubResource("BeaconMesh")
|
||||
material_override = SubResource("BeaconMaterial")
|
||||
|
||||
[node name="BeaconLight" type="OmniLight3D" parent="NavigationBeacon"]
|
||||
omni_range = 12.0
|
||||
light_color = Color(0.2, 0.78, 0.9, 1)
|
||||
light_energy = 4.0
|
||||
|
||||
[node name="SonarCalibrationTarget" type="StaticBody3D" parent="."]
|
||||
position = Vector3(0, -60, -58)
|
||||
metadata/sonar_material = 2
|
||||
metadata/sonar_reflectivity = 1.0
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="SonarCalibrationTarget"]
|
||||
mesh = SubResource("MetalTargetMesh")
|
||||
material_override = SubResource("MetalTargetMaterial")
|
||||
|
||||
[node name="Collision" type="CollisionShape3D" parent="SonarCalibrationTarget"]
|
||||
shape = SubResource("MetalTargetShape")
|
||||
Reference in new issue
Block a user