A5: World art for points of interest, build pieces, vessels and terrain

- PoiMesher dresses every point of interest from its parts: lapped tarred
  weatherboards, plank boards, stone in a running bond with lichen, tiled
  roofs with a ridge cap, salt-white trim on paint, crusted salt pans, and a
  tarred frame round the lighthouse's glowing glass. One mesh per POI.
- Huts get a shuttered window in each side wall (non-solid parts, no rng).
- Build pieces show their state: building in quarter steps, worn (a third of
  health gone) and battered (two thirds gone, strips knocked out).
  StructureView rebuilds a piece's mesh only when its state changes.
- VesselModels builds the barge (lofted hull, curved rails, mooring lines,
  gored envelope) and the sea chests in code; the primitive stand-ins are gone.
- Terrain: tussocks, wind-dried patches, shingle on sand, lichen on rock.
- test_world_art (9) fails on any primitive stand-in mesh or placeholder
  resource under src/ or assets/, and covers POI bounds and determinism,
  windows, the lamp surface, wear and build stages, view rebuilds and the
  vessel models.
- make poi-captures and make build-captures (state card, vessels).

Closes #45

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 20:39:24 -05:00
co-authored by Claude Opus 5.5
parent fdd4c992c3
commit 923876ed1f
22 changed files with 976 additions and 131 deletions
+19 -64
View File
@@ -6,8 +6,8 @@
## simulation replicates about them, with shots, swings and building played from FX
## records through hear(). Held and lying items are the models of A4 (ItemModels): a
## held one sits with its grip in the figure's right hand and points where its player
## looks. The barge and chests are still stand-in shapes. Nothing here is ever used
## for collision.
## looks. The barge and the sea chests are VesselModels, generated in code. Nothing
## here is ever used for collision.
class_name EntityView
extends Node3D
@@ -17,12 +17,10 @@ const OILSKINS: Array[Color] = [
Palette.OILSKIN_SLATE, Palette.OILSKIN_NAVY, Palette.TANNED_SAIL,
]
const SKIN: Color = Palette.SKIN
const CANVAS: Color = Palette.CANVAS
const TAR: Color = Palette.TAR
const PLANK: Color = Palette.PLANK
const CHEST_SHUT: Color = Palette.SEA_PAINT
const CHEST_OPEN: Color = Palette.HOLD_SHADOW
const ITEM: Color = Palette.GILT
## Chest instance colours, multiplied into the chest model's own: an opened chest
## shows darker, its paint dulled.
const CHEST_SHUT: Color = Color.WHITE
const CHEST_OPEN: Color = Palette.OPENED_DULL
## How far apart passengers stand on the barge's deck, in metres. The simulation
## carries them all at one point; this only spreads them out to be seen.
const DECK_SPACING: float = 1.3
@@ -56,7 +54,7 @@ func setup(sim: Simulation) -> void:
_pickups = Node3D.new()
_pickups.name = "Pickups"
add_child(_pickups)
_chests = _box_field("Chests", Vector3(0.9, 0.55, 0.6), false)
_chests = _chest_field()
add_child(_chests)
sync()
@@ -145,7 +143,7 @@ func sync() -> void:
var chests: MultiMesh = _chests.multimesh
chests.instance_count = _sim.loot.chest_positions.size()
for index: int in _sim.loot.chest_positions.size():
chests.set_instance_transform(index, Transform3D(Basis.IDENTITY, _sim.loot.chest_positions[index] + Vector3(0.0, 0.28, 0.0)))
chests.set_instance_transform(index, Transform3D(Basis.IDENTITY, _sim.loot.chest_positions[index]))
chests.set_instance_color(index, CHEST_OPEN if _sim.loot.chest_opened[index] != 0 else CHEST_SHUT)
@@ -231,11 +229,10 @@ func _item_field(key: String) -> MultiMeshInstance3D:
multimesh.transform_format = MultiMesh.TRANSFORM_3D
var mesh: ArrayMesh = ItemModels.model(key.get_slice("@", 0), key.get_slice("@", 1).to_int())
if mesh == null:
var stand_in: BoxMesh = BoxMesh.new()
stand_in.size = Vector3(0.25, 0.25, 0.25)
multimesh.mesh = stand_in
else:
multimesh.mesh = mesh
# Every catalogue item has a model (test_item_models); this is a bug.
push_error("EntityView: no model for item %s" % key)
mesh = ArrayMesh.new()
multimesh.mesh = mesh
var field: MultiMeshInstance3D = MultiMeshInstance3D.new()
field.name = key.replace("@", "_")
field.multimesh = multimesh
@@ -250,64 +247,22 @@ func _build_figure(entity_id: int) -> FigureRig:
return figure
## A flat-bottomed hull hung under a canvas envelope. Its deck is at the origin, where
## the simulation carries the passengers.
## The barge (VesselModels): a hull hung under a canvas envelope. Its deck is at the
## origin, where the simulation carries the passengers.
func _build_barge() -> Node3D:
var barge: Node3D = Node3D.new()
var barge: MeshInstance3D = MeshInstance3D.new()
barge.name = "Barge"
var deck: BoxMesh = BoxMesh.new()
deck.size = Vector3(7.5, 0.3, 11.0)
barge.add_child(_part(deck, PLANK, Vector3(0.0, -0.15, 0.0)))
var hull: BoxMesh = BoxMesh.new()
hull.size = Vector3(6.4, 1.3, 9.6)
barge.add_child(_part(hull, TAR, Vector3(0.0, -0.95, 0.0)))
for side: float in [-1.0, 1.0]:
var rail: BoxMesh = BoxMesh.new()
rail.size = Vector3(0.15, 0.7, 11.0)
barge.add_child(_part(rail, TAR, Vector3(side * 3.68, 0.35, 0.0)))
for end: float in [-1.0, 1.0]:
var rope: CylinderMesh = CylinderMesh.new()
rope.top_radius = 0.05
rope.bottom_radius = 0.05
rope.height = 7.0
barge.add_child(_part(rope, PLANK.darkened(0.3), Vector3(side * 3.4, 3.5, end * 4.6)))
var envelope: SphereMesh = SphereMesh.new()
envelope.radius = 1.0
envelope.height = 2.0
var bag: MeshInstance3D = _part(envelope, CANVAS, Vector3(0.0, 10.5, 0.0))
bag.scale = Vector3(5.2, 3.8, 9.0)
barge.add_child(bag)
barge.mesh = VesselModels.barge()
return barge
func _part(mesh: PrimitiveMesh, colour: Color, at: Vector3) -> MeshInstance3D:
var material: StandardMaterial3D = StandardMaterial3D.new()
material.albedo_color = colour
material.roughness = 0.85
mesh.material = material
var instance: MeshInstance3D = MeshInstance3D.new()
instance.mesh = mesh
instance.position = at
return instance
func _box_field(node_name: String, size: Vector3, glow: bool) -> MultiMeshInstance3D:
var material: StandardMaterial3D = StandardMaterial3D.new()
material.vertex_color_use_as_albedo = true
material.roughness = 0.7
if glow:
material.emission_enabled = true
material.emission = ITEM
material.emission_energy_multiplier = 0.5
var mesh: BoxMesh = BoxMesh.new()
mesh.size = size
mesh.material = material
func _chest_field() -> MultiMeshInstance3D:
var multimesh: MultiMesh = MultiMesh.new()
multimesh.transform_format = MultiMesh.TRANSFORM_3D
multimesh.use_colors = true
multimesh.mesh = mesh
multimesh.mesh = VesselModels.chest()
var instance: MultiMeshInstance3D = MultiMeshInstance3D.new()
instance.name = node_name
instance.name = "Chests"
instance.multimesh = multimesh
instance.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
return instance
+176
View File
@@ -0,0 +1,176 @@
## Generated meshes for the drop barge and the sea chests, built in code from Palette
## colours (no imported art):
##
## - the barge: a tarred, lofted hull with a sheer and pointed ends, a planked deck,
## rails, mooring lines, and a gored canvas envelope with tanned stripes and an ochre
## band, in the folk-art manner of docs/STYLE.md. Its deck top is at the origin, where
## the simulation carries the passengers; it points along +z;
## - a sea chest: a painted box with a lid, tarred iron bands, a salt-white border and a
## gilt hasp, its base at the origin.
class_name VesselModels
extends RefCounted
## Hull half-length, half-breadth at the deck, and depth amidships, in metres.
const HULL_HALF_LENGTH: float = 5.5
const HULL_HALF_BREADTH: float = 3.4
const HULL_DEPTH: float = 1.6
## Envelope centre height above the deck and its semi-axes (x, y, z), in metres.
const ENVELOPE_HEIGHT: float = 10.5
const ENVELOPE_AXES: Vector3 = Vector3(5.2, 3.8, 9.0)
const ENVELOPE_RINGS: int = 14
const ENVELOPE_SIDES: int = 20
## Chest size (x, y, z), in metres; its lid is the top LID share of its height.
const CHEST_SIZE: Vector3 = Vector3(0.9, 0.55, 0.6)
const LID: float = 0.3
static func barge() -> ArrayMesh:
var tool: SurfaceTool = SurfaceTool.new()
tool.begin(Mesh.PRIMITIVE_TRIANGLES)
tool.set_smooth_group(-1)
var rings: Array[PackedVector3Array] = _hull(tool)
# Deck planks run fore and aft, each cut to where the hull is wide enough for it.
var index: int = 0
var x: float = -HULL_HALF_BREADTH + 0.2
while x < HULL_HALF_BREADTH - 0.2:
var width: float = minf(0.32, HULL_HALF_BREADTH - 0.2 - x)
var outer: float = maxf(absf(x), absf(x + width)) + 0.15
var reach: float = HULL_HALF_LENGTH * pow(maxf(1.0 - pow(outer / HULL_HALF_BREADTH, 2.0), 0.0), 0.25) - 0.1
if reach > 0.3:
var plank: AABB = AABB(Vector3(x + 0.015, -0.12, -reach), Vector3(width - 0.03, 0.12, 2.0 * reach))
PieceMesher.add_box(tool, plank, PieceMesher.tint(Palette.PLANK, 9001 + index))
x += 0.32
index += 1
# Rails follow the sheer on stanchions at every station.
var rail: Vector3 = Vector3(0.0, 0.65, 0.0)
for side: int in [0, 4]:
var inward: Vector3 = Vector3(0.12 if side == 0 else -0.12, 0.0, 0.0)
for station: int in rings.size():
var at: Vector3 = rings[station][side] + inward
_line(tool, at, at + rail, 0.1, Palette.TAR)
if station + 1 < rings.size():
_line(tool, at + rail, rings[station + 1][side] + inward + rail, 0.1, Palette.TAR)
for side: float in [-1.0, 1.0]:
# Mooring lines from the rail to the envelope's belly.
for end: float in [-1.0, 1.0]:
var foot: Vector3 = Vector3(side * (HULL_HALF_BREADTH - 0.35), 0.6, end * 3.6)
var hx: float = 0.55
var hz: float = 0.5
var under: float = ENVELOPE_AXES.y * sqrt(1.0 - hx * hx - hz * hz)
var head: Vector3 = Vector3(side * ENVELOPE_AXES.x * hx, ENVELOPE_HEIGHT - under + 0.15, end * ENVELOPE_AXES.z * hz)
_line(tool, foot, head, 0.05, Palette.PLANK.darkened(0.3))
_envelope(tool)
tool.generate_normals()
var mesh: ArrayMesh = tool.commit()
mesh.surface_set_material(0, _material(0.85))
return mesh
static func chest() -> ArrayMesh:
var tool: SurfaceTool = SurfaceTool.new()
tool.begin(Mesh.PRIMITIVE_TRIANGLES)
tool.set_smooth_group(-1)
var s: Vector3 = CHEST_SIZE
var lid_y: float = s.y * (1.0 - LID)
var body: AABB = AABB(Vector3(-s.x * 0.5, 0.0, -s.z * 0.5), Vector3(s.x, lid_y, s.z))
PieceMesher.add_box(tool, body, Palette.SEA_PAINT)
var lid: AABB = AABB(Vector3(-s.x * 0.5 - 0.02, lid_y, -s.z * 0.5 - 0.02), Vector3(s.x + 0.04, s.y - lid_y, s.z + 0.04))
PieceMesher.add_box(tool, lid, Palette.SEA_PAINT.darkened(0.12))
# Salt-white border round the body, just under the lid.
PieceMesher.add_box(tool, AABB(Vector3(-s.x * 0.5 - 0.01, lid_y - 0.08, -s.z * 0.5 - 0.01), Vector3(s.x + 0.02, 0.035, s.z + 0.02)), Palette.SALT)
# Iron bands over the lid and down the sides, and the gilt hasp at the front.
for x: float in [-s.x * 0.3, s.x * 0.3]:
PieceMesher.add_box(tool, AABB(Vector3(x - 0.04, 0.0, -s.z * 0.5 - 0.03), Vector3(0.08, s.y + 0.01, s.z + 0.06)), Palette.TAR)
PieceMesher.add_box(tool, AABB(Vector3(-0.06, lid_y - 0.14, s.z * 0.5), Vector3(0.12, 0.18, 0.04)), Palette.GILT)
tool.generate_normals()
var mesh: ArrayMesh = tool.commit()
mesh.surface_set_material(0, _material(0.7))
return mesh
## The hull as rings of five points (rail, bilge, keel, bilge, rail) along z. Returns
## the rings, for the rails.
static func _hull(tool: SurfaceTool) -> Array[PackedVector3Array]:
var stations: int = 12
var rings: Array[PackedVector3Array] = []
for station: int in stations + 1:
var t: float = float(station) / stations * 2.0 - 1.0
var z: float = t * HULL_HALF_LENGTH
var breadth: float = HULL_HALF_BREADTH * sqrt(maxf(1.0 - pow(absf(t), 4.0), 0.015))
var keel: float = -HULL_DEPTH * (1.0 - 0.55 * pow(absf(t), 3.0))
var sheer: float = 0.25 * t * t
var ring: PackedVector3Array = PackedVector3Array([
Vector3(-breadth, sheer, z), Vector3(-breadth * 0.8, keel * 0.6, z), Vector3(0.0, keel, z),
Vector3(breadth * 0.8, keel * 0.6, z), Vector3(breadth, sheer, z),
])
rings.append(ring)
for station: int in stations:
for side: int in 4:
var colour: Color = Palette.TAR if side == 1 or side == 2 else Palette.TAR_WEATHERED
# A painted strake under the rail, every other station a shade lighter.
if side == 0 or side == 3:
colour = PieceMesher.tint(colour, station * 7 + side)
_quad(tool, rings[station][side], rings[station][side + 1], rings[station + 1][side + 1], rings[station + 1][side], colour)
# Rubbing strake: an ochre band along the top of the hull.
for station: int in stations:
for side: int in [0, 4]:
var a: Vector3 = rings[station][side]
var b: Vector3 = rings[station + 1][side]
var out: float = 0.04 * signf(a.x) if absf(a.x) > 0.01 else 0.0
var drop: Vector3 = Vector3(0.0, -0.22, 0.0)
_quad(tool, a + Vector3(out, 0.0, 0.0), b + Vector3(out, 0.0, 0.0), b + drop + Vector3(out, 0.0, 0.0), a + drop + Vector3(out, 0.0, 0.0), Palette.OCHRE_RED)
return rings
## The envelope: an ellipsoid of gores along z, alternately canvas and tanned, with an
## ochre band round its middle.
static func _envelope(tool: SurfaceTool) -> void:
var centre: Vector3 = Vector3(0.0, ENVELOPE_HEIGHT, 0.0)
var rings: Array[PackedVector3Array] = []
for ring: int in ENVELOPE_RINGS + 1:
var phi: float = PI * float(ring) / ENVELOPE_RINGS
var z: float = -cos(phi) * ENVELOPE_AXES.z
var r: float = sin(phi)
var points: PackedVector3Array = PackedVector3Array()
for side: int in ENVELOPE_SIDES + 1:
var theta: float = TAU * float(side) / ENVELOPE_SIDES
points.append(centre + Vector3(cos(theta) * r * ENVELOPE_AXES.x, sin(theta) * r * ENVELOPE_AXES.y, z))
rings.append(points)
var middle: int = ENVELOPE_RINGS / 2
tool.set_smooth_group(1)
for ring: int in ENVELOPE_RINGS:
for side: int in ENVELOPE_SIDES:
var colour: Color = Palette.CANVAS if (side / 2) % 2 == 0 else Palette.TANNED_SAIL.lightened(0.15)
if ring == middle or ring == middle - 1:
colour = Palette.OCHRE_RED
_quad(tool, rings[ring][side], rings[ring][side + 1], rings[ring + 1][side + 1], rings[ring + 1][side], colour)
tool.set_smooth_group(-1)
## A square line `width` thick from `a` to `b`.
static func _line(tool: SurfaceTool, a: Vector3, b: Vector3, width: float, colour: Color) -> void:
var along: Vector3 = (b - a).normalized()
var side: Vector3 = along.cross(Vector3.FORWARD if absf(along.z) < 0.9 else Vector3.RIGHT).normalized() * width * 0.5
var up: Vector3 = along.cross(side).normalized() * width * 0.5
var corners: Array[Vector3] = [side + up, -side + up, -side - up, side - up]
for index: int in 4:
var c0: Vector3 = corners[index]
var c1: Vector3 = corners[(index + 1) % 4]
_quad(tool, a + c0, a + c1, b + c1, b + c0, colour)
## A quad. The material draws both sides, so the order of its corners doesn't matter.
static func _quad(tool: SurfaceTool, a: Vector3, b: Vector3, c: Vector3, d: Vector3, colour: Color) -> void:
tool.set_color(colour)
for point: Vector3 in [a, b, c, a, c, d]:
tool.add_vertex(point)
static func _material(roughness: float) -> StandardMaterial3D:
var material: StandardMaterial3D = StandardMaterial3D.new()
material.vertex_color_use_as_albedo = true
material.vertex_color_is_srgb = true
material.roughness = roughness
material.cull_mode = BaseMaterial3D.CULL_DISABLED
return material
+1
View File
@@ -0,0 +1 @@
uid://b6u71jxsh531