A2: Player figure and animation

The islander is built in headless Blender (tools/models/figure.py,
`make figure`, `make art`) as twelve rigid parts with their origins at
their joints: an oilskin coat, a sou'wester, sea boots, a bedding roll
and the canvas wing-sail. Debian's Blender can't write glTF, so the
figure is jointed rather than skinned.

FigureRig hangs the parts on pivots, paints them from Palette with the
coat in the player's own oilskin, and plays FigurePoses' hand-written
key poses through one AnimationTree: idle, walk and run by speed,
crouch and creep, air, skydive, glide, swim and aboard; long, short and
carried holds; reload and use layers; fire, boathook swing, keg throw
and building as one-shots; and a flinch when health drops. The chest
takes a third of the pitch and the held item all of it.

Figures animate from replicated state only: positions, look, health,
the held item and the FLAG_ bits (reloading and using now reach
mirrored players), with actions from FX. Every boathook swing is now a
sim "swing" event, sent as a SHOT with no item, so misses are seen and
heard; the new FX kind PLACE shows pieces placed. Protocol version 4.

Tests: test_figure_rig (15), plus swing and PLACE cases in test_harvest
and test_net_fx. make check passes (604 tests); make client-check
passes. Captures: figure_states, figure_actions, figure_close
(make figure-captures), client_glide and client_landed.

Closes #42

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 17:35:53 -05:00
co-authored by Claude Opus 5.5
parent da0c65f3ce
commit 07738330b5
66 changed files with 6230 additions and 88 deletions
+7
View File
@@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/figure_scene.gd" id="1"]
[node name="CaptureFigure" type="Node3D"]
script = ExtResource("1")
stage = "actions"
+7
View File
@@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/figure_scene.gd" id="1"]
[node name="CaptureFigure" type="Node3D"]
script = ExtResource("1")
stage = "close"
+168
View File
@@ -0,0 +1,168 @@
## Capture scenario for the player figure (A2), on seed 2's island in the real
## MatchView. Each stage stands a row of figures, each frozen at a chosen moment of one
## animation, seen from in front and to their right:
##
## - states: idle, walk, run, crouched, creeping, in the air, skydiving, gliding,
## swimming. (Aboard the barge is the idle with the feet set wider; the deck
## placement would pull it out of the row.)
## - actions: carrying a longgun, a revolver and a tonic, firing each kind, a boathook
## swing, a keg thrown, building, reloading, drinking and a flinch.
## - close: one figure holding the dock carbine, close up, three-quarter front.
extends Node3D
@export var stage: String = "states"
@export var match_seed: int = 2
## [label, item id or "", setup, seconds to run, action or ""]. Setup names a state.
const STATES: Array = [
["idle", "", "ground", 0.6, ""],
["walk", "", "walk", 0.2, ""],
["run", "", "run", 0.15, ""],
["crouch", "", "crouch", 0.8, ""],
["creep", "", "creep", 0.25, ""],
["air", "", "air", 0.5, ""],
["skydive", "", "skydive", 0.8, ""],
["glide", "", "glide", 0.8, ""],
["swim", "", "swim", 0.35, ""],
]
const ACTIONS: Array = [
["long", "whalers_longgun", "ground", 0.6, ""],
["short", "signal_revolver", "ground", 0.6, ""],
["carry", "brine_tonic", "ground", 0.6, ""],
["fire_long", "dock_carbine", "ground", 0.04, "fire_long"],
["fire_short", "signal_revolver", "ground", 0.04, "fire_short"],
["swing_back", "", "ground", 0.16, "swing"],
["swing", "", "ground", 0.26, "swing"],
["throw", "powder_keg", "ground", 0.2, "throw"],
["build", "", "ground", 0.1, "build"],
["reload", "dock_carbine", "reload", 0.5, ""],
["use", "brine_tonic", "use", 0.5, ""],
["flinch", "dock_carbine", "flinch", 0.06, ""],
]
var sim: Simulation
var view: MatchView
func _ready() -> void:
sim = Simulation.new(match_seed)
var spot: Vector3 = _open_ground()
var rows: Array = STATES if stage == "states" else ACTIONS
if stage == "close":
rows = [["close", "dock_carbine", "ground", 0.6, ""]]
var players: Array[SimEntity] = []
for index: int in rows.size():
players.append(_stand(_at(spot, index, rows.size()), rows[index]))
view = MatchView.new()
view.setup(sim, 0)
add_child(view)
view.entities.animate_live = false
view.sync()
for index: int in rows.size():
_pose(players[index], rows[index])
var middle: Vector3 = _at(spot, (rows.size() - 1) * 0.5 + (1.0 if rows.size() > 1 else 0.0), rows.size())
if stage == "close":
view.look_from(middle + Vector3(-2.0, 1.55, 2.6), middle + Vector3(0.0, 1.0, 0.0))
else:
var back: float = 2.0 + rows.size() * 0.42
view.look_from(middle + Vector3(-back, 1.7, back * 0.3), middle + Vector3(0.0, 1.0, 0.0))
view.settle()
func _at(spot: Vector3, index: float, count: int) -> Vector3:
var at: Vector3 = spot + Vector3(0.0, 0.0, (index - (count - 1) * 0.5) * 1.5 + 1.0)
at.y = sim.ground.terrain_height(at.x, at.z)
return at
func _stand(at: Vector3, row: Array) -> SimEntity:
var player: SimEntity = sim.entities.find(sim.add_player())
player.position = at
player.drop_state = Drop.NONE
player.on_ground = true
player.health = 100
player.yaw = 0
var id: String = row[1]
if id != "":
player.slot_items[0] = ItemCatalog.code_of(id)
player.slot_counts[0] = 1
player.slot_tiers[0] = 2
player.selected = 1
else:
player.selected = 0
match String(row[2]):
"walk":
player.velocity = Vector3(0.0, 0.0, Tuning.WALK_SPEED)
"run":
player.velocity = Vector3(0.0, 0.0, Tuning.SPRINT_SPEED)
"crouch":
player.crouching = true
"creep":
player.crouching = true
player.velocity = Vector3(0.0, 0.0, Tuning.CROUCH_SPEED)
"air":
player.on_ground = false
player.position.y += 0.5
"skydive":
player.drop_state = Drop.FREEFALL
player.on_ground = false
player.position.y += 0.6
"glide":
player.drop_state = Drop.GLIDING
player.on_ground = false
player.position.y += 0.4
"swim":
player.swimming = true
player.on_ground = false
"aboard":
player.drop_state = Drop.ABOARD
player.on_ground = false
"reload":
player.reload_ticks = 10
"use":
player.use_ticks = 10
return player
func _pose(player: SimEntity, row: Array) -> void:
var figure: FigureRig = view.entities.figure_of(player.id)
# The barge's deck isn't drawn here: put the passenger back where it stands.
figure.position = player.position
figure.drive(player, 0.0)
figure.drive(player, 1.0)
figure.advance(0.0)
if String(row[2]) == "flinch":
figure.advance(0.4)
player.health = 70
figure.drive(player, 0.0)
if String(row[4]) != "":
figure.advance(0.4)
figure.act(row[4])
var left: float = float(row[3])
while left > 0.0:
var step: float = minf(left, 1.0 / 60.0)
figure.advance(step)
left -= step
## Fairly flat, open ground above the sea near the middle of the island.
func _open_ground() -> Vector3:
var size: float = Tuning.WORLD_SIZE_METRES
var best: Vector3 = Vector3(size * 0.5, 0.0, size * 0.5)
for ring: int in 60:
for step: int in 24:
var angle: float = TAU * step / 24.0
var x: float = size * 0.5 + cos(angle) * ring * 12.0
var z: float = size * 0.5 + sin(angle) * ring * 12.0
var feet: Vector3 = Vector3(x, sim.ground.terrain_height(x, z), z)
if feet.y < sim.sea_level + 3.0 or sim.ground.terrain_normal(x, z).y < 0.985:
continue
if not sim.props.near(feet, 12.0).is_empty():
continue
var level: bool = true
for dz: float in [-7.0, 0.0, 9.0]:
if absf(sim.ground.terrain_height(x - 2.0, z + dz) - feet.y) > 0.8:
level = false
if level:
return feet
return best
+1
View File
@@ -0,0 +1 @@
uid://mbpyawoimo5k
+7
View File
@@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/figure_scene.gd" id="1"]
[node name="CaptureFigure" type="Node3D"]
script = ExtResource("1")
stage = "states"