Add production bathymetric sonar slice
This commit is contained in:
1 parent
a18e82eb44
commit
7613daee84
28 files changed
+1825
-87
No files matched your search
@@ -1,8 +1,20 @@
|
||||
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)
|
||||
@@ -31,3 +43,111 @@ func _ready() -> void:
|
||||
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,4 +1,4 @@
|
||||
[gd_scene load_steps=12 format=3]
|
||||
[gd_scene load_steps=8 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://game/world/sites/vehicle_test_environment.gd" id="1_environment"]
|
||||
|
||||
@@ -18,36 +18,21 @@ volumetric_fog_enabled = true
|
||||
volumetric_fog_density = 0.025
|
||||
volumetric_fog_length = 72.0
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="RockMaterial"]
|
||||
albedo_color = Color(0.075, 0.19, 0.19, 1)
|
||||
roughness = 0.92
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="RockMaterialLight"]
|
||||
albedo_color = Color(0.105, 0.25, 0.24, 1)
|
||||
roughness = 0.88
|
||||
|
||||
[sub_resource type="BoxMesh" id="SeafloorMesh"]
|
||||
size = Vector3(220, 8, 250)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="SeafloorShape"]
|
||||
size = Vector3(220, 8, 250)
|
||||
|
||||
[sub_resource type="BoxMesh" id="RockMeshA"]
|
||||
size = Vector3(12, 30, 14)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="RockShapeA"]
|
||||
size = Vector3(12, 30, 14)
|
||||
|
||||
[sub_resource type="BoxMesh" id="RockMeshB"]
|
||||
size = Vector3(18, 42, 16)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="RockShapeB"]
|
||||
size = Vector3(18, 42, 16)
|
||||
|
||||
[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)
|
||||
@@ -67,60 +52,6 @@ light_color = Color(0.39, 0.65, 0.7, 1)
|
||||
light_energy = 0.38
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="Seafloor" type="StaticBody3D" parent="."]
|
||||
position = Vector3(0, -84, -58)
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="Seafloor"]
|
||||
mesh = SubResource("SeafloorMesh")
|
||||
material_override = SubResource("RockMaterial")
|
||||
|
||||
[node name="Collision" type="CollisionShape3D" parent="Seafloor"]
|
||||
shape = SubResource("SeafloorShape")
|
||||
|
||||
[node name="RockNearLeft" type="StaticBody3D" parent="."]
|
||||
position = Vector3(-10, -18, -18)
|
||||
rotation_degrees = Vector3(0, -14, 8)
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="RockNearLeft"]
|
||||
mesh = SubResource("RockMeshA")
|
||||
material_override = SubResource("RockMaterialLight")
|
||||
|
||||
[node name="Collision" type="CollisionShape3D" parent="RockNearLeft"]
|
||||
shape = SubResource("RockShapeA")
|
||||
|
||||
[node name="RockNearRight" type="StaticBody3D" parent="."]
|
||||
position = Vector3(12, -22, -32)
|
||||
rotation_degrees = Vector3(0, 18, -5)
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="RockNearRight"]
|
||||
mesh = SubResource("RockMeshB")
|
||||
material_override = SubResource("RockMaterial")
|
||||
|
||||
[node name="Collision" type="CollisionShape3D" parent="RockNearRight"]
|
||||
shape = SubResource("RockShapeB")
|
||||
|
||||
[node name="RockFarLeft" type="StaticBody3D" parent="."]
|
||||
position = Vector3(-18, -48, -68)
|
||||
rotation_degrees = Vector3(0, 9, 4)
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="RockFarLeft"]
|
||||
mesh = SubResource("RockMeshA")
|
||||
material_override = SubResource("RockMaterialLight")
|
||||
|
||||
[node name="Collision" type="CollisionShape3D" parent="RockFarLeft"]
|
||||
shape = SubResource("RockShapeA")
|
||||
|
||||
[node name="RockFarRight" type="StaticBody3D" parent="."]
|
||||
position = Vector3(20, -58, -94)
|
||||
rotation_degrees = Vector3(0, -11, -7)
|
||||
|
||||
[node name="Mesh" type="MeshInstance3D" parent="RockFarRight"]
|
||||
mesh = SubResource("RockMeshB")
|
||||
material_override = SubResource("RockMaterial")
|
||||
|
||||
[node name="Collision" type="CollisionShape3D" parent="RockFarRight"]
|
||||
shape = SubResource("RockShapeB")
|
||||
|
||||
[node name="NavigationBeacon" type="MeshInstance3D" parent="."]
|
||||
position = Vector3(0, -15, -22)
|
||||
mesh = SubResource("BeaconMesh")
|
||||
@@ -130,3 +61,15 @@ material_override = SubResource("BeaconMaterial")
|
||||
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