Skip to content

Commit 5de28fc

Browse files
authored
feat(runner): vary the starship corridor walls (#111)
1 parent 9b4cfed commit 5de28fc

4 files changed

Lines changed: 71 additions & 25 deletions

File tree

213 KB
Loading

‎hoppys-adventure-arcade/scenes/runner/environment/starship/starship_assets.gd‎

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,46 @@ static func beam(st: SurfaceTool, a: Vector3, b: Vector3, width: float, depth: f
7373
for i in face: polygon.append(points[i]-center)
7474
Forge.polygon(st,polygon,center,Color(shade,shade,shade,1))
7575

76+
static func _observation_wall(parts: Array[SurfaceTool]) -> void:
77+
# Three wide panes share a recessed frame.
78+
box(parts[ALLOY], Vector3(-5.43, 3.32, 3.0), Vector3(0.34, 1.72, 4.66), 0.90, 0.10)
79+
slab(parts[DARK], Vector3(-5.24, 3.32, 3.0), Vector3(0.12, 1.46, 4.38), 0.76)
80+
for z in [1.57, 3.0, 4.43]:
81+
slab(parts[WINDOW], Vector3(-5.17, 3.32, z), Vector3(0.04, 1.17, 1.27))
82+
for z in [2.28, 3.72]:
83+
slab(parts[HULL], Vector3(-5.11, 3.32, z), Vector3(0.12, 1.48, 0.13), 0.82)
84+
slab(parts[CONDUIT], Vector3(-5.17, 2.48, 3.0), Vector3(0.04, 0.05, 3.9), 0.72)
85+
86+
# A sealed pressure door has tall split leaves and an amber header.
87+
box(parts[ALLOY], Vector3(-5.41, 3.23, 9.0), Vector3(0.32, 2.9, 3.7), 0.90, 0.14)
88+
slab(parts[DARK], Vector3(-5.22, 3.20, 9.0), Vector3(0.12, 2.66, 3.40), 0.80)
89+
for z in [8.17, 9.83]:
90+
box(parts[HULL], Vector3(-5.12, 3.12, z), Vector3(0.13, 2.37, 1.56), 0.94, 0.06)
91+
slab(parts[ALLOY], Vector3(-5.03, 3.70, z), Vector3(0.07, 0.30, 1.35))
92+
for z in [8.77, 9.23]:
93+
slab(parts[DARK], Vector3(-5.00, 3.12, z), Vector3(0.09, 0.48, 0.09))
94+
slab(parts[ENERGY], Vector3(-5.14, 4.48, 9.0), Vector3(0.05, 0.08, 1.8), 0.66)
95+
96+
static func _service_wall(parts: Array[SurfaceTool]) -> void:
97+
# Long horizontal louvres sit inside the coolant intake.
98+
box(parts[ALLOY], Vector3(5.43, 3.24, 3.0), Vector3(0.34, 2.62, 4.55), 0.82, 0.12)
99+
slab(parts[DARK], Vector3(5.22, 3.24, 3.0), Vector3(0.13, 2.34, 4.18), 0.63)
100+
for row in 6:
101+
var y := 2.31 + row * 0.37
102+
box(parts[HULL], Vector3(5.11, y, 3.0), Vector3(0.29, 0.13, 3.9), 0.82, 0.05)
103+
for z in [1.66, 4.34]:
104+
slab(parts[ALLOY], Vector3(4.93, 3.24, z), Vector3(0.14, 2.30, 0.15))
105+
106+
# A power distribution rack has narrow cabinets and vertical status strips.
107+
box(parts[ALLOY], Vector3(5.41, 3.23, 9.0), Vector3(0.32, 2.76, 3.7), 0.84, 0.10)
108+
slab(parts[DARK], Vector3(5.19, 3.23, 9.0), Vector3(0.15, 2.54, 3.40), 0.86)
109+
for z in [7.90, 9.0, 10.10]:
110+
box(parts[HULL], Vector3(5.05, 3.23, z), Vector3(0.18, 2.2, 0.94), 0.86, 0.08)
111+
slab(parts[DARK], Vector3(4.93, 3.39, z), Vector3(0.06, 1.57, 0.48))
112+
slab(parts[ENERGY], Vector3(4.89, 3.45, z), Vector3(0.04, 1.22, 0.09), 0.58)
113+
for y in [2.45, 2.60]:
114+
slab(parts[ALLOY], Vector3(4.92, y, z), Vector3(0.07, 0.06, 0.58))
115+
76116
static func module_meshes() -> Array[ArrayMesh]:
77117
if not _meshes.is_empty(): return _meshes
78118
var parts: Array[SurfaceTool] = []
@@ -91,35 +131,20 @@ static func module_meshes() -> Array[ArrayMesh]:
91131
beam(parts[CONDUIT],Vector3(x-side*0.13,4.45,0.44),Vector3(side*2.55,6.44,0.44),0.07,0.025)
92132
for h in [0.8,3.9]:
93133
box(parts[ALLOY],Vector3(x,h,0),Vector3(0.75,0.26,1.05),1.0,0.055)
94-
# Solid hull walls: continuous plating closes every 12 m module end to end (seams sit behind
95-
# the next bulkhead), leaving one small inset porthole per side instead of a space vista.
134+
# Continuous plating closes each module end to end behind the wall bays.
96135
box(parts[DARK],Vector3(side*5.62,0.85,6.0),Vector3(0.45,1.7,12.0),0.8)
97136
box(parts[DARK],Vector3(side*5.62,5.65,6.0),Vector3(0.45,1.55,12.0),1.0)
98137
slab(parts[DARK],Vector3(side*5.9,3.28,6.0),Vector3(0.1,3.4,12.0),0.45)
99138
# Hull panels with 5 cm inset seams showing the dark backing plate.
100-
for panel: Array in [[0.0,2.18,1.72,4.85,0.92],[2.2,3.8,1.72,2.63,0.86],[2.2,3.8,3.81,4.85,0.86],[3.82,6.9,1.72,4.85,0.98],[6.95,12.0,1.72,3.24,0.9],[6.95,12.0,3.29,4.85,0.94]]:
101-
slab(parts[HULL],Vector3(side*5.66,(panel[2]+panel[3])*0.5,(panel[0]+panel[1])*0.5),Vector3(0.28,panel[3]-panel[2],panel[1]-panel[0]),panel[4])
102-
# One small porthole (1.6 x 1.1 m) recessed behind the plating inside an alloy rim.
103-
slab(parts[WINDOW],Vector3(side*5.79,3.22,3.0),Vector3(0.02,1.1,1.6))
104-
for rim: Array in [[3.0,2.62,1.84,0.12],[3.0,3.82,1.84,0.12],[2.14,3.22,0.12,1.32],[3.86,3.22,0.12,1.32]]:
105-
slab(parts[ALLOY],Vector3(side*5.49,rim[1],rim[0]),Vector3(0.1,rim[3],rim[2]),0.9)
139+
for z in [1.5, 4.5, 7.5, 10.5]:
140+
slab(parts[HULL], Vector3(side * 5.66, 3.28, z), Vector3(0.28, 3.12, 2.95), 0.90)
106141
for y in [1.66,4.78]:
107142
box(parts[HULL],Vector3(side*5.44,y,5.8),Vector3(0.3,0.18,11.3))
108143
box(parts[CONDUIT],Vector3(side*5.25,y,5.8),Vector3(0.025,0.035,10.4),0.55,0.005)
109144
# Floor-edge skirting, plus a sub-deck filler under the trench so the chord sag of 12 m pieces
110145
# against the finely bent deck never opens a sliver during turns.
111146
slab(parts[DARK],Vector3(side*5.2,0.22,6.0),Vector3(0.5,1.04,12.0),0.7)
112147
slab(parts[DARK],Vector3(side*4.14,-0.175,6.0),Vector3(1.68,0.25,12.0),0.6)
113-
# Armoured equipment bay breaks up the plating with layered access panels.
114-
box(parts[HULL],Vector3(side*5.33,3.23,9.05),Vector3(0.28,2.72,2.55),0.8,0.13)
115-
box(parts[DARK],Vector3(side*5.14,3.23,9.05),Vector3(0.15,2.28,2.14),0.95,0.12)
116-
for panel in [-1.0,1.0]:
117-
box(parts[ALLOY],Vector3(side*5.02,3.25,9.05+panel*0.65),Vector3(0.17,1.8,0.55),0.94,0.07)
118-
for vent in 3:
119-
box(parts[DARK],Vector3(side*4.91,2.65+vent*0.60,9.05+panel*0.65),Vector3(0.06,0.065,0.40),0.6,0.01)
120-
box(parts[CONDUIT],Vector3(side*4.94,3.35,9.05),Vector3(0.04,1.05,0.085),0.65,0.02)
121-
for diode in 3:
122-
box(parts[ENERGY],Vector3(side*4.98,2.42,8.83+diode*0.22),Vector3(0.04,0.07,0.09),0.65,0.01)
123148
# Deck-edge service trenches and orange power trunks.
124149
box(parts[ALLOY],Vector3(side*4.13,-0.13,5.7),Vector3(0.50,0.22,12),0.6)
125150
box(parts[ENERGY],Vector3(side*4.12,-0.005,5.7),Vector3(0.075,0.04,12),0.6,0.01)
@@ -145,6 +170,8 @@ static func module_meshes() -> Array[ArrayMesh]:
145170
box(parts[ALLOY],Vector3(0,6.9,z),Vector3(5.1,0.15,0.14),0.85)
146171
box(parts[HULL],Vector3(0,6.8,z),Vector3(1.8,0.10,1.35),0.8)
147172
box(parts[CONDUIT],Vector3(0,6.73,z),Vector3(1.4,0.025,0.58),0.72,0.01)
173+
_observation_wall(parts)
174+
_service_wall(parts)
148175
# Small amber bulkhead identifier strips establish rhythm at speed.
149176
for i in 3:
150177
box(parts[ENERGY],Vector3(-0.28+i*0.28,6.65,0.47),Vector3(0.13,0.15,0.02),0.6,0.01)

‎hoppys-adventure-arcade/scenes/runner/environment/starship/starship_world.gd‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
extends Node3D
22
const Assets = preload("res://scenes/runner/environment/starship/starship_assets.gd")
3+
const MODULE_LENGTH := 12.0
4+
# Each side has different bays. Swap sides in an eight-module sequence with both
5+
# single and paired layouts, using the same meshes and material batches.
6+
const MIRRORED_MODULES := [false, true, true, false, true, false, false, true]
7+
const MIRRORED_BASIS := Basis(Vector3.LEFT, Vector3.UP, Vector3.BACK)
38
var batches: Array[MultiMesh] = []
49
var materials: Array[ShaderMaterial] = []
510
var reactor_dock: Node3D
@@ -21,7 +26,7 @@ func _ready() -> void:
2126
var batch := MultiMesh.new()
2227
batch.transform_format = MultiMesh.TRANSFORM_3D
2328
batch.mesh = meshes[i]
24-
batch.instance_count = 8
29+
batch.instance_count = MIRRORED_MODULES.size()
2530
batches.append(batch)
2631
var instance := MultiMeshInstance3D.new()
2732
instance.name = ["PressureBulkheads","RecessedHull","ServiceMachinery","LightConduits","ObservationWindows","PowerTrunks"][i]
@@ -165,12 +170,18 @@ func _plane(title: String, size: Vector2, location: Vector3, material: ShaderMat
165170
add_child(node)
166171
if not materials.has(material): materials.append(material)
167172

173+
func _module_transform(index: int, offset: float) -> Transform3D:
174+
var loop_length := MODULE_LENGTH * MIRRORED_MODULES.size()
175+
var z := MODULE_LENGTH - fposmod(index * MODULE_LENGTH - offset, loop_length)
176+
var basis := MIRRORED_BASIS if MIRRORED_MODULES[index] else Basis.IDENTITY
177+
return Transform3D(basis, Vector3(0, 0, z))
178+
168179
## `frame` is the corridor's global transform: the floor-mode surfaces measure their plating in it.
169180
func sync(offset: float, clock: float, frame: Transform3D, arena: bool, delta: float) -> void:
170-
for batch in batches:
171-
for i in batch.instance_count:
172-
var z := 12.0-fposmod(i*12.0-offset,96.0)
173-
batch.set_instance_transform(i,Transform3D(Basis.IDENTITY,Vector3(0,0,z)))
181+
for i in MIRRORED_MODULES.size():
182+
var pose := _module_transform(i, offset)
183+
for batch in batches:
184+
batch.set_instance_transform(i, pose)
174185
var frame_changed := not _frame_written or frame != _frame
175186
_frame = frame
176187
_frame_written = true

‎hoppys-adventure-arcade/tests/assets/starship_check.gd‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,17 @@ func run() -> void:
4242
check(triangles + extra_triangles < 60000, "whole starship including boss dock stays within 60k triangles")
4343
check(triangles < 60000, "starship module geometry stays within 60k triangles")
4444
check(corridor.starship.batches.size() == 6, "bounded material batches")
45-
for i in 8:
46-
var z: float = corridor.starship.batches[0].get_instance_transform(i).origin.z
45+
var module_count: int = corridor.starship.batches[0].instance_count
46+
var mirrored_count := 0
47+
for i in module_count:
48+
# The headless renderer does not store MultiMesh instance transforms.
49+
var pose: Transform3D = corridor.starship._module_transform(i, 7.5)
50+
var wrapped_pose: Transform3D = corridor.starship._module_transform(i, 103.5)
51+
var z := pose.origin.z
4752
check(z <= 12 and z > -84, "recycle bounds")
53+
check(wrapped_pose.is_equal_approx(pose), "wall layout repeats on the 96 m boundary")
54+
mirrored_count += int(pose.basis.determinant() < 0.0)
55+
check(mirrored_count > 0 and mirrored_count < module_count, "wall bays appear on both sides of the corridor")
4856
corridor.set_scroll_speed(32)
4957
corridor._process(3.0)
5058
check(is_zero_approx(corridor._offset), "maximum-speed 96m wrap has no drift")

0 commit comments

Comments
 (0)