#72: The packet ship, the lifeline mortar and the gull-kite
Eric chose option B on #72. The drop is now the GDD's launch: - A packet ship sails a seeded straight line past the island, offshore, as close in as it can while keeping 45 m of open water from any land (eight-way probes; up to 32 headings, then the four world sides). - Jump fires the lifeline mortar along the look heading. How high the player aims sets the charge (-10 to 45 degrees: 16 to 110 m/s over the ground; every shot climbs at 75 m/s). The climb can't be steered and the kite can't open until the arc tops out. Riders still aboard at the end are fired towards the middle of the island. - Drop.reach() mirrors the fall for both ways down (kite at the top, or a fall with the kite opening by itself); bots, the soak and autoplay clients and the tutorial pilot aim with Drop.aim_charge(). - Bots fire at their landing spot once abeam of it, when in easy reach at their own staggered moment, or just before the route ends, and open the kite early only when the spot is beyond the rest of a fall. - Art: VesselModels.ship() (two-masted packet, tanned square sails, a salt-white boot-top, a bowsprit and the mortar on its bed, mirrored to face the island), the figure's gull-kite (figure.py), and a lifeline cord from the muzzle to each player still climbing. - Renamed barge to ship and wing-sail to gull-kite throughout code, tests, captures, docs and the tutorial text. make match now defaults to seed 2, where the scripted player still harvests and builds. Closes #72 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
## A gamepad works alongside them, in PadInput's fixed layout (A13), with AimAssist
|
||||
## on its right stick when the setting is on.
|
||||
##
|
||||
## With `autoplay` on, a simple script plays instead: it leaps from the barge over
|
||||
## land, glides, and walks about. That is for tests and for checking a connection with
|
||||
## With `autoplay` on, a simple script plays instead: it fires itself off the ship
|
||||
## towards the middle of the island, glides, and walks about. That is for tests and for checking a connection with
|
||||
## nobody at the keyboard.
|
||||
class_name ClientInput
|
||||
extends RefCounted
|
||||
@@ -172,8 +172,11 @@ func autoplay_command(tick: int, me: SimEntity, ground: SimGround) -> PlayerComm
|
||||
move = Vector2.ZERO
|
||||
buttons = 0
|
||||
if me.drop_state == Drop.ABOARD:
|
||||
# Over dry land, with a moment to look about first.
|
||||
if tick > 3 * Tuning.TICK_RATE_HZ and ground.terrain_height(me.position.x, me.position.z) > Tuning.ISLAND_BEACH_TOP + 2.0:
|
||||
# With a moment to look about first, fire the mortar most of the way to the
|
||||
# middle of the island.
|
||||
if tick > 3 * Tuning.TICK_RATE_HZ:
|
||||
var gap: float = Vector2(centre - me.position.x, centre - me.position.z).length()
|
||||
pitch = Drop.pitch_for_charge(Drop.aim_charge(gap * 0.7))
|
||||
buttons = PlayerCommand.BUTTON_JUMP
|
||||
elif me.drop_state != Drop.NONE:
|
||||
move = Vector2(0.0, 1.0)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## Draws what moves in a match: players with what they hold, the sky barge while it
|
||||
## Draws what moves in a match: players with what they hold, the packet ship while it
|
||||
## crosses, items lying in the world, thrown kegs and sea chests. `sync()` matches everything to the
|
||||
## simulation as it is now, and `animate()` steps the players' figures.
|
||||
##
|
||||
@@ -6,8 +6,9 @@
|
||||
## 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 the sea chests are VesselModels, generated in code. Nothing
|
||||
## here is ever used for collision.
|
||||
## looks. The ship and the sea chests are VesselModels, generated in code. The ship's
|
||||
## lifeline mortar faces the island, and a player it has just fired trails a line from
|
||||
## its muzzle until the arc tops out. Nothing here is ever used for collision.
|
||||
class_name EntityView
|
||||
extends Node3D
|
||||
|
||||
@@ -21,7 +22,7 @@ const SKIN: Color = Palette.SKIN
|
||||
## 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
|
||||
## How far apart passengers stand on the ship'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
|
||||
const DECK_ROWS: int = 4
|
||||
@@ -30,16 +31,19 @@ const PICKUP_SCALE: float = 1.4
|
||||
|
||||
## The entity drawn in the brightest oilskin, or 0.
|
||||
var local_id: int = 0
|
||||
## Where to draw the barge, when its owner knows better than the simulation's tick: a
|
||||
## Where to draw the ship, when its owner knows better than the simulation's tick: a
|
||||
## network client, which draws between ticks. Vector3.INF leaves it to the tick.
|
||||
var barge_at: Vector3 = Vector3.INF
|
||||
var ship_at: Vector3 = Vector3.INF
|
||||
|
||||
var _sim: Simulation
|
||||
## Entity ID -> its FigureRig.
|
||||
var _figures: Dictionary = {}
|
||||
## Whether _process steps the figures. Captures that pose figures exactly turn it off.
|
||||
var animate_live: bool = true
|
||||
var _barge: Node3D
|
||||
var _ship: Node3D
|
||||
## One line from the mortar to each player still climbing the arc, reused.
|
||||
var _lifelines: Array[MeshInstance3D] = []
|
||||
var _lifeline_mesh: ArrayMesh
|
||||
## Items lying in the world: one MultiMeshInstance3D per item model and tier.
|
||||
var _pickups: Node3D
|
||||
var _pickup_fields: Dictionary = {}
|
||||
@@ -48,9 +52,9 @@ var _chests: MultiMeshInstance3D
|
||||
|
||||
func setup(sim: Simulation) -> void:
|
||||
_sim = sim
|
||||
_barge = _build_barge()
|
||||
_barge.visible = false
|
||||
add_child(_barge)
|
||||
_ship = _build_ship()
|
||||
_ship.visible = false
|
||||
add_child(_ship)
|
||||
_pickups = Node3D.new()
|
||||
_pickups.name = "Pickups"
|
||||
add_child(_pickups)
|
||||
@@ -68,8 +72,8 @@ func figure_of(entity_id: int) -> FigureRig:
|
||||
return _figures.get(entity_id)
|
||||
|
||||
|
||||
func barge() -> Node3D:
|
||||
return _barge
|
||||
func ship() -> Node3D:
|
||||
return _ship
|
||||
|
||||
|
||||
## Items drawn lying in the world.
|
||||
@@ -106,10 +110,15 @@ func sync() -> void:
|
||||
if drop != null:
|
||||
var along: Vector3 = drop.finish - drop.start
|
||||
heading = atan2(along.x, along.z)
|
||||
_barge.visible = crossing
|
||||
_ship.visible = crossing
|
||||
if crossing:
|
||||
_barge.position = barge_at if barge_at != Vector3.INF else drop.barge_position(_sim.tick)
|
||||
_barge.rotation.y = heading
|
||||
_ship.position = ship_at if ship_at != Vector3.INF else drop.ship_position(_sim.tick)
|
||||
_ship.rotation.y = heading
|
||||
# The model's mortar faces its +x: mirror it if the island lies the other way.
|
||||
var starboard: Vector2 = Vector2(cos(heading), -sin(heading))
|
||||
var centre: Vector2 = Vector2.ONE * Tuning.WORLD_SIZE_METRES * 0.5
|
||||
_ship.scale.x = 1.0 if (centre - Vector2(drop.start.x, drop.start.z)).dot(starboard) >= 0.0 else -1.0
|
||||
var lines: int = 0
|
||||
|
||||
var seen: Dictionary = {}
|
||||
var aboard: int = 0
|
||||
@@ -133,7 +142,12 @@ func sync() -> void:
|
||||
figure.position += offset.rotated(Vector3.UP, heading)
|
||||
figure.rotation.y = heading
|
||||
aboard += 1
|
||||
elif crossing and entity.drop_state == Drop.FREEFALL and entity.velocity.y > 0.0 and not entity.eliminated:
|
||||
_draw_lifeline(lines, _ship.transform * VesselModels.muzzle(), entity.position + Vector3(0.0, 1.0, 0.0))
|
||||
lines += 1
|
||||
_hold(figure, entity)
|
||||
for index: int in range(lines, _lifelines.size()):
|
||||
_lifelines[index].visible = false
|
||||
for entity_id: int in _figures.keys():
|
||||
if not seen.has(entity_id):
|
||||
_figures[entity_id].queue_free()
|
||||
@@ -176,7 +190,7 @@ func hear(records: Array[Dictionary]) -> void:
|
||||
|
||||
|
||||
## Puts the held item's model in the figure's hand; the figure points it where the
|
||||
## player looks. Nothing is held aboard the barge, falling, gliding, swimming or down.
|
||||
## player looks. Nothing is held aboard the ship, falling, gliding, swimming or down.
|
||||
func _hold(figure: FigureRig, entity: SimEntity) -> void:
|
||||
var busy: bool = entity.drop_state != Drop.NONE or entity.swimming or entity.eliminated or entity.downed
|
||||
figure.hand().visible = not busy
|
||||
@@ -248,6 +262,35 @@ func _item_field(key: String) -> MultiMeshInstance3D:
|
||||
return field
|
||||
|
||||
|
||||
## Shows lifeline `index` from `from` to `to`, making it if there aren't enough yet.
|
||||
func _draw_lifeline(index: int, from: Vector3, to: Vector3) -> void:
|
||||
if _lifeline_mesh == null:
|
||||
_lifeline_mesh = VesselModels.lifeline()
|
||||
while _lifelines.size() <= index:
|
||||
var line: MeshInstance3D = MeshInstance3D.new()
|
||||
line.name = "Lifeline%d" % _lifelines.size()
|
||||
line.mesh = _lifeline_mesh
|
||||
line.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
|
||||
add_child(line)
|
||||
_lifelines.append(line)
|
||||
var line: MeshInstance3D = _lifelines[index]
|
||||
var length: float = from.distance_to(to)
|
||||
line.visible = length > 0.5
|
||||
if not line.visible:
|
||||
return
|
||||
var up: Vector3 = Vector3.UP if absf((to - from).normalized().y) < 0.99 else Vector3.RIGHT
|
||||
line.transform = Transform3D(Basis.looking_at(to - from, up) * Basis.from_scale(Vector3(1.0, 1.0, length)), (from + to) * 0.5)
|
||||
|
||||
|
||||
## Lifelines drawn now, for tests.
|
||||
func lifeline_count() -> int:
|
||||
var count: int = 0
|
||||
for line: MeshInstance3D in _lifelines:
|
||||
if line.visible:
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
func _build_figure(entity_id: int) -> FigureRig:
|
||||
var coat: Color = OILSKINS[0] if entity_id == local_id else OILSKINS[1 + entity_id % (OILSKINS.size() - 1)]
|
||||
var figure: FigureRig = FigureRig.new(coat)
|
||||
@@ -255,13 +298,13 @@ func _build_figure(entity_id: int) -> FigureRig:
|
||||
return figure
|
||||
|
||||
|
||||
## 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: MeshInstance3D = MeshInstance3D.new()
|
||||
barge.name = "Barge"
|
||||
barge.mesh = VesselModels.barge()
|
||||
return barge
|
||||
## The packet ship (VesselModels). Its deck is at the origin, where the simulation
|
||||
## carries the passengers.
|
||||
func _build_ship() -> Node3D:
|
||||
var ship: MeshInstance3D = MeshInstance3D.new()
|
||||
ship.name = "Ship"
|
||||
ship.mesh = VesselModels.ship()
|
||||
return ship
|
||||
|
||||
|
||||
func _chest_field() -> MultiMeshInstance3D:
|
||||
|
||||
@@ -188,7 +188,7 @@ static func _clips() -> Dictionary:
|
||||
[0.4, over(air, {"shoulder_r": Vector3(-20, 0, -46), "shoulder_l": Vector3(-20, 0, 46)})],
|
||||
]]
|
||||
|
||||
# Falling from the barge, belly down, spread out.
|
||||
# Climbing the mortar's arc and falling from it, belly down, spread out.
|
||||
var skydive: Dictionary = {
|
||||
"hips": Vector3(72, 0, 0), "waist": Vector3(6, 0, 0), "neck": Vector3(-55, 0, 0),
|
||||
"shoulder_r": Vector3(-70, 0, -70), "shoulder_l": Vector3(-70, 0, 70),
|
||||
@@ -201,7 +201,7 @@ static func _clips() -> Dictionary:
|
||||
[0.5, over(skydive, {"shoulder_r": Vector3(-74, 0, -64), "shoulder_l": Vector3(-74, 0, 64), "knee_r": Vector3(48, 0, 0), "knee_l": Vector3(34, 0, 0)})],
|
||||
]]
|
||||
|
||||
# Hanging under the wing-sail, both hands up on its lines.
|
||||
# Hanging under the gull-kite, both hands up on its lines.
|
||||
var glide: Dictionary = {
|
||||
"hips": Vector3(12, 0, 0), "waist": Vector3(-4, 0, 0), "neck": Vector3(10, 0, 0),
|
||||
"shoulder_r": Vector3(-158, 0, -16), "shoulder_l": Vector3(-158, 0, 16),
|
||||
|
||||
@@ -36,7 +36,7 @@ const ANIMATED: Array[String] = [
|
||||
const PARENT: Dictionary = {
|
||||
"hips": "", "waist": "hips", "spine": "waist", "neck": "spine",
|
||||
"shoulder_r": "spine", "elbow_r": "shoulder_r", "shoulder_l": "spine", "elbow_l": "shoulder_l",
|
||||
"hip_r": "hips", "knee_r": "hip_r", "hip_l": "hips", "knee_l": "hip_l", "sail": "",
|
||||
"hip_r": "hips", "knee_r": "hip_r", "hip_l": "hips", "knee_l": "hip_l", "kite": "",
|
||||
}
|
||||
## Part model -> the joint pivot it hangs on.
|
||||
const PART_JOINT: Dictionary = {
|
||||
@@ -44,7 +44,7 @@ const PART_JOINT: Dictionary = {
|
||||
"upper_arm_r": "shoulder_r", "forearm_r": "elbow_r",
|
||||
"upper_arm_l": "shoulder_l", "forearm_l": "elbow_l",
|
||||
"thigh_r": "hip_r", "shin_r": "knee_r", "thigh_l": "hip_l", "shin_l": "knee_l",
|
||||
"sail": "sail",
|
||||
"kite": "kite",
|
||||
}
|
||||
## Material names in the part models -> Palette colours. COAT and COAT_DARK are the
|
||||
## player's own oilskin.
|
||||
@@ -52,6 +52,7 @@ const COLOURS: Dictionary = {
|
||||
"TAR": Palette.TAR, "TAR_WEATHERED": Palette.TAR_WEATHERED, "SKIN": Palette.SKIN,
|
||||
"INK": Palette.INK, "BARK": Palette.BARK, "CANVAS": Palette.CANVAS, "GILT": Palette.GILT,
|
||||
"PLANK": Palette.PLANK, "OCHRE_RED": Palette.OCHRE_RED, "TANNED_SAIL": Palette.TANNED_SAIL,
|
||||
"SALT": Palette.SALT,
|
||||
}
|
||||
const COAT_SHADE: float = 0.28
|
||||
## The states of `move`, in input order.
|
||||
@@ -88,7 +89,7 @@ var speed: float = 0.0
|
||||
|
||||
var _hand: Node3D
|
||||
var _held: MeshInstance3D
|
||||
var _sail: Node3D
|
||||
var _kite: Node3D
|
||||
var _pitch: float = 0.0
|
||||
var _holding: bool = true
|
||||
var _airborne: float = 0.0
|
||||
@@ -124,8 +125,8 @@ func _init(coat_colour: Color = Palette.OILSKIN) -> void:
|
||||
instance.name = part
|
||||
instance.mesh = mesh
|
||||
(joints[PART_JOINT[part]] as Node3D).add_child(instance)
|
||||
_sail = joints["sail"]
|
||||
_sail.visible = false
|
||||
_kite = joints["kite"]
|
||||
_kite.visible = false
|
||||
_hand = Node3D.new()
|
||||
_hand.name = "hand_r"
|
||||
_hand.position = _vector(layout.get("hand_r", [-0.24, 0.86, 0.03])) - _vector(at.get("elbow_r", [0, 0, 0]))
|
||||
@@ -163,7 +164,7 @@ static func part_mesh(part: String, coat_colour: Color) -> ArrayMesh:
|
||||
|
||||
## H1: one surface per finish instead of one per colour, with each Palette colour
|
||||
## carried as a vertex colour. The model's surfaces are separate draw calls in every
|
||||
## pass, and 24 figures crowded on the barge passed the draw-call budget; merged, a
|
||||
## pass, and 24 figures crowded on the ship passed the draw-call budget; merged, a
|
||||
## figure costs a third of the draws and looks the same. Each surface is named after
|
||||
## its finish: FINISH_COAT, FINISH_GILT or FINISH_PLAIN.
|
||||
static func _merged(source: Mesh, coat_colour: Color) -> ArrayMesh:
|
||||
@@ -256,8 +257,8 @@ func held() -> MeshInstance3D:
|
||||
return _held
|
||||
|
||||
|
||||
func sail() -> Node3D:
|
||||
return _sail
|
||||
func kite() -> Node3D:
|
||||
return _kite
|
||||
|
||||
|
||||
## Sets the tree from an entity's replicated state. `delta` is the time since the last
|
||||
@@ -283,7 +284,7 @@ func drive(entity: SimEntity, delta: float) -> void:
|
||||
flinch()
|
||||
_last_health = entity.health
|
||||
_pitch = float(entity.pitch) / PlayerCommand.PITCH_MAX * (PI * 0.5)
|
||||
_sail.visible = state == "glide"
|
||||
_kite.visible = state == "glide"
|
||||
_hand.visible = _holding
|
||||
tree.set("parameters/move/transition_request", state)
|
||||
tree.set("parameters/ground/blend_position", speed)
|
||||
|
||||
@@ -1,31 +1,42 @@
|
||||
## Generated meshes for the drop barge and the sea chests, built in code from Palette
|
||||
## Generated meshes for the packet ship 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;
|
||||
## - the packet ship (#72): a tarred, lofted hull with a sheer, an ochre rubbing strake
|
||||
## and a salt-white boot-top at the waterline, a planked deck, rails, two masts with
|
||||
## tanned square sails on yards, a bowsprit, shrouds, and the lifeline mortar on its
|
||||
## timber bed, in the folk-art manner of docs/STYLE.md. Its deck top is at the origin,
|
||||
## where the simulation carries the passengers, and the waterline SHIP_DECK_HEIGHT
|
||||
## below it; it points along +z, and the mortar faces +x;
|
||||
## - 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
|
||||
## Hull half-length, half-breadth at the deck, and depth amidships, in metres. The keel
|
||||
## sits HULL_DEPTH under the deck, below the waterline.
|
||||
const HULL_HALF_LENGTH: float = 12.0
|
||||
const HULL_HALF_BREADTH: float = 3.8
|
||||
const HULL_DEPTH: float = Tuning.SHIP_DECK_HEIGHT + 1.8
|
||||
## Masts: where along the deck (z), and how tall above it.
|
||||
const MASTS: Array[Vector2] = [Vector2(6.6, 17.0), Vector2(-5.8, 14.5)]
|
||||
## Where the mortar stands on the deck: forward of the passengers, aft of the foremast,
|
||||
## pointing out to +x.
|
||||
const MORTAR_AT: Vector3 = Vector3(1.4, 0.0, 4.7)
|
||||
|
||||
## The mortar's barrel: its breech above MORTAR_AT, the way it points, and its length.
|
||||
const MORTAR_BREECH: Vector3 = Vector3(-0.15, 0.55, 0.0)
|
||||
const MORTAR_AIM: Vector3 = Vector3(0.62, 0.78, 0.0)
|
||||
const MORTAR_LENGTH: float = 1.25
|
||||
|
||||
## The lifeline cord's thickness, in metres.
|
||||
const LIFELINE_WIDTH: float = 0.07
|
||||
|
||||
## 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:
|
||||
static func ship() -> ArrayMesh:
|
||||
var tool: SurfaceTool = SurfaceTool.new()
|
||||
tool.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
tool.set_smooth_group(-1)
|
||||
@@ -43,30 +54,117 @@ static func barge() -> ArrayMesh:
|
||||
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 rail: Vector3 = Vector3(0.0, 0.8, 0.0)
|
||||
for side: int in [0, 6]:
|
||||
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)
|
||||
# Bowsprit, raking up from the bow.
|
||||
var bow: Vector3 = Vector3(0.0, _sheer(1.0) + 0.3, HULL_HALF_LENGTH - 0.4)
|
||||
var sprit_end: Vector3 = bow + Vector3(0.0, 2.4, 6.0)
|
||||
_line(tool, bow, sprit_end, 0.28, Palette.PLANK.darkened(0.15))
|
||||
for mast: Vector2 in MASTS:
|
||||
_mast(tool, mast.x, mast.y, sprit_end if mast == MASTS[0] else Vector3.INF)
|
||||
_mortar(tool)
|
||||
tool.generate_normals()
|
||||
var mesh: ArrayMesh = tool.commit()
|
||||
mesh.surface_set_material(0, _material(0.85))
|
||||
return mesh
|
||||
|
||||
|
||||
## Height of the sheer at `t`, from -1 (stern) to 1 (bow).
|
||||
static func _sheer(t: float) -> float:
|
||||
return 0.9 * t * t
|
||||
|
||||
|
||||
## A mast at `z` rising `height` above the deck: a tarred pole, two yards with tanned
|
||||
## square sails between them, an ochre band on the lower sail, and shrouds to the rails.
|
||||
## A forestay runs to `stay_to` unless it is Vector3.INF.
|
||||
static func _mast(tool: SurfaceTool, z: float, height: float, stay_to: Vector3) -> void:
|
||||
var foot: Vector3 = Vector3(0.0, 0.0, z)
|
||||
var top: Vector3 = Vector3(0.0, height, z)
|
||||
_line(tool, foot, top, 0.36, Palette.PLANK.darkened(0.25))
|
||||
var yards: Array[float] = [height * 0.36, height * 0.66, height * 0.92]
|
||||
var spans: Array[float] = [4.6, 3.8, 2.8]
|
||||
for level: int in yards.size():
|
||||
var y: float = yards[level]
|
||||
var half: float = spans[level]
|
||||
_line(tool, Vector3(-half, y, z + 0.3), Vector3(half, y, z + 0.3), 0.2, Palette.TAR)
|
||||
for level: int in 2:
|
||||
var y_top: float = yards[level + 1]
|
||||
var y_foot: float = yards[level] + 0.25
|
||||
var half_top: float = spans[level + 1]
|
||||
var half_foot: float = spans[level]
|
||||
# The sail bellies forward in the middle: three panels across, the middle one
|
||||
# further out.
|
||||
var columns: int = 4
|
||||
for column: int in columns:
|
||||
var u0: float = float(column) / columns * 2.0 - 1.0
|
||||
var u1: float = float(column + 1) / columns * 2.0 - 1.0
|
||||
var belly0: float = 0.55 + 0.9 * (1.0 - u0 * u0)
|
||||
var belly1: float = 0.55 + 0.9 * (1.0 - u1 * u1)
|
||||
var colour: Color = Palette.TANNED_SAIL if column % 2 == 0 else Palette.TANNED_SAIL.lightened(0.08)
|
||||
_quad(tool,
|
||||
Vector3(u0 * half_top, y_top, z + 0.45), Vector3(u1 * half_top, y_top, z + 0.45),
|
||||
Vector3(u1 * half_foot, y_foot, z + belly1), Vector3(u0 * half_foot, y_foot, z + belly0), colour)
|
||||
if level == 0:
|
||||
# An ochre band across the lower sail, a little above its foot.
|
||||
var yb: float = lerpf(y_foot, y_top, 0.2)
|
||||
var yb2: float = lerpf(y_foot, y_top, 0.3)
|
||||
var hb: float = lerpf(half_foot, half_top, 0.2)
|
||||
var hb2: float = lerpf(half_foot, half_top, 0.3)
|
||||
_quad(tool, Vector3(-hb2, yb2, z + 1.42), Vector3(hb2, yb2, z + 1.42), Vector3(hb, yb, z + 1.47), Vector3(-hb, yb, z + 1.47), Palette.OCHRE_RED)
|
||||
# Shrouds from the top of the lower sail to each rail.
|
||||
for side: float in [-1.0, 1.0]:
|
||||
for step: float in [-0.8, 0.0, 0.8]:
|
||||
_line(tool, Vector3(side * (HULL_HALF_BREADTH - 0.3), 0.7, z + step - 0.6), Vector3(0.0, yards[1], z), 0.05, Palette.TAR)
|
||||
if stay_to != Vector3.INF:
|
||||
_line(tool, top, stay_to, 0.06, Palette.TAR)
|
||||
|
||||
|
||||
## The lifeline mortar: a squat tarred barrel with gilt bands on a timber bed, cocked up
|
||||
## towards +x, and a coil of line beside it.
|
||||
static func _mortar(tool: SurfaceTool) -> void:
|
||||
var at: Vector3 = MORTAR_AT
|
||||
PieceMesher.add_box(tool, AABB(at + Vector3(-0.8, 0.0, -0.7), Vector3(1.6, 0.45, 1.4)), Palette.PLANK.darkened(0.2))
|
||||
var breech: Vector3 = at + MORTAR_BREECH
|
||||
var aim: Vector3 = MORTAR_AIM.normalized()
|
||||
_line(tool, breech, breech + aim * MORTAR_LENGTH, 0.72, Palette.TAR)
|
||||
for band: float in [0.25, 0.95]:
|
||||
_line(tool, breech + aim * band, breech + aim * (band + 0.12), 0.8, Palette.GILT)
|
||||
# A coil of line on the deck behind it, as a ring of short segments.
|
||||
var coil: Vector3 = at + Vector3(-1.6, 0.18, 0.9)
|
||||
for turn: int in 3:
|
||||
var radius: float = 0.55 - turn * 0.1
|
||||
var segments: int = 10
|
||||
for segment: int in segments:
|
||||
var a0: float = TAU * segment / segments
|
||||
var a1: float = TAU * (segment + 1) / segments
|
||||
var p0: Vector3 = coil + Vector3(cos(a0) * radius, turn * 0.07, sin(a0) * radius)
|
||||
var p1: Vector3 = coil + Vector3(cos(a1) * radius, turn * 0.07, sin(a1) * radius)
|
||||
_line(tool, p0, p1, 0.09, Palette.CANVAS.darkened(0.15))
|
||||
|
||||
|
||||
## The middle of the mortar's muzzle, in the ship model's own space.
|
||||
static func muzzle() -> Vector3:
|
||||
return MORTAR_AT + MORTAR_BREECH + MORTAR_AIM.normalized() * MORTAR_LENGTH
|
||||
|
||||
|
||||
## A length of lifeline: a square cord LIFELINE_WIDTH thick and one metre long along
|
||||
## -z, centred on the origin, for EntityView to stretch between the mortar and a player.
|
||||
static func lifeline() -> ArrayMesh:
|
||||
var tool: SurfaceTool = SurfaceTool.new()
|
||||
tool.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
_line(tool, Vector3(0.0, 0.0, 0.5), Vector3(0.0, 0.0, -0.5), LIFELINE_WIDTH, Palette.CANVAS.darkened(0.15))
|
||||
tool.generate_normals()
|
||||
var mesh: ArrayMesh = tool.commit()
|
||||
mesh.surface_set_material(0, _material(0.9))
|
||||
return mesh
|
||||
|
||||
|
||||
static func chest() -> ArrayMesh:
|
||||
var tool: SurfaceTool = SurfaceTool.new()
|
||||
tool.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
@@ -89,65 +187,56 @@ static func chest() -> ArrayMesh:
|
||||
return mesh
|
||||
|
||||
|
||||
## The hull as rings of five points (rail, bilge, keel, bilge, rail) along z. Returns
|
||||
## the rings, for the rails.
|
||||
## The hull as rings of seven points along z: rail, boot-top, waterline, keel and back
|
||||
## up the other side (indices 0 to 6), with the deck at y = 0 and the sea at
|
||||
## -SHIP_DECK_HEIGHT. Returns the rings, for the rails.
|
||||
static func _hull(tool: SurfaceTool) -> Array[PackedVector3Array]:
|
||||
var stations: int = 12
|
||||
var stations: int = 16
|
||||
var water: float = -Tuning.SHIP_DECK_HEIGHT
|
||||
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 breadth: float = HULL_HALF_BREADTH * sqrt(maxf(1.0 - pow(absf(t), 3.0), 0.01))
|
||||
var keel: float = -HULL_DEPTH * (1.0 - 0.3 * pow(absf(t), 3.0))
|
||||
var sheer: float = _sheer(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),
|
||||
Vector3(-breadth, sheer, z),
|
||||
Vector3(-breadth * 0.97, water + 0.6, z),
|
||||
Vector3(-breadth * 0.93, water, z),
|
||||
Vector3(0.0, keel, z),
|
||||
Vector3(breadth * 0.93, water, z),
|
||||
Vector3(breadth * 0.97, water + 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:
|
||||
for side: int in 6:
|
||||
var colour: Color = Palette.TAR_WEATHERED
|
||||
if side == 1 or side == 4:
|
||||
colour = Palette.SALT
|
||||
elif side == 2 or side == 3:
|
||||
colour = Palette.TAR
|
||||
else:
|
||||
# The topsides, a painted strake every other station a shade lighter.
|
||||
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)
|
||||
# Transom and stem: close the ends.
|
||||
for end: int in [0, stations]:
|
||||
var ring: PackedVector3Array = rings[end]
|
||||
for side: int in 3:
|
||||
_quad(tool, ring[side], ring[side + 1], ring[5 - side], ring[6 - side], Palette.TAR)
|
||||
# Rubbing strake: an ochre band along the top of the hull.
|
||||
for station: int in stations:
|
||||
for side: int in [0, 4]:
|
||||
for side: int in [0, 6]:
|
||||
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)
|
||||
var out: Vector3 = Vector3(0.04 * signf(a.x), 0.0, 0.0)
|
||||
var drop: Vector3 = Vector3(0.0, -0.3, 0.0)
|
||||
_quad(tool, a + out, b + out, b + drop + out, a + drop + out, 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()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## The island as a hand-drawn nautical chart (A11): paper land with ink contours every
|
||||
## CONTOUR_METRES, a heavier coastline, the sea in the sea's ink, place names, the
|
||||
## barge's route, the player's own mark, and the tide forecast: land the coming tide
|
||||
## ship's route, the player's own mark, and the tide forecast: land the coming tide
|
||||
## will flood is hatched, and land the sea has already taken is washed with the sea.
|
||||
##
|
||||
## The forecast comes from the client's own Flood (Flood.forecast), the same spreading
|
||||
@@ -28,7 +28,7 @@ var mode: Mode = Mode.FULL
|
||||
var world: Simulation = null
|
||||
## Place names and where they are, in world metres (x, z).
|
||||
var places: Array[Dictionary] = []
|
||||
## The barge's route ends, in world metres (x, z), or empty when there's no drop.
|
||||
## The ship's route ends, in world metres (x, z), or empty when there's no drop.
|
||||
var route: PackedVector2Array = PackedVector2Array()
|
||||
## The player: position (x, z) in metres, facing (radians, the simulation's yaw), and
|
||||
## whether to draw them.
|
||||
@@ -54,7 +54,7 @@ func _init(chart_mode: Mode = Mode.FULL) -> void:
|
||||
|
||||
|
||||
## Draws the chart of `simulation`'s island and names its places from `match_seed`.
|
||||
## `drop` is the match's barge route, or null. `share` is another ChartMap already set
|
||||
## `drop` is the match's ship route, or null. `share` is another ChartMap already set
|
||||
## up for the same world, whose paper and contours are used rather than drawn again.
|
||||
func setup(simulation: Simulation, match_seed: int, drop: Drop = null, share: ChartMap = null) -> void:
|
||||
world = simulation
|
||||
|
||||
@@ -122,7 +122,7 @@ func follow(entity_id: int, pitch: float = NAN, look_yaw: float = NAN) -> bool:
|
||||
return false
|
||||
var yaw: float = look_yaw if not is_nan(look_yaw) else float(player.yaw) / PlayerCommand.YAW_STEPS * TAU
|
||||
var look_pitch: float = pitch if not is_nan(pitch) else float(player.pitch) / PlayerCommand.PITCH_MAX * (PI * 0.5)
|
||||
# Where the figure is drawn: on the barge's deck that is its own place, not the
|
||||
# Where the figure is drawn: on the ship's deck that is its own place, not the
|
||||
# one point the simulation carries every passenger at.
|
||||
var feet: Vector3 = player.position
|
||||
var figure: Node3D = entities.figure_of(entity_id)
|
||||
|
||||
Reference in New Issue
Block a user