luvcraft/body.lisp
The most box-equivalents (36 vertices) the body and its held item may emit per frame; a rounded slab counts for several.
The eye bobs with the body. The head is highest passing over the standing leg and lowest at each footfall, so the eye rises twice per bob cycle and sways once; the arms above already follow the same phase, so the two motions read as one body walking. These are knobs so the gait can be tuned from play without a rebuild.
--------------------------------------------------------------------- What a hand can hold.
A short lowercase noun for item, as the title shows it.
Call function for each textured box of item as held by body.
function receives (X Y Z HALF-X HALF-Y HALF-Z TILE &KEY TILT STRETCH-P
EMISSION), like map-critter-boxes with three extras: TILT is a (PITCH YAW
ROLL) triple of radians turning the box about its own centre, STRETCH-P
stretches the whole atlas tile over each face instead of keeping texels
cell-sized, and EMISSION is the face's own light. Coordinates are in the
grip frame: origin at the palm, x across the fingers, y up the item, z away
from the player.
How many boxes map-hand-item-boxes emits for item.
Append item's geometry, held by body, to vertices.
palm is the world point of the grip and right up forward its unit frame.
The default method emits the item's map-hand-item-boxes; an item whose
shape is not a heap of boxes -- a slab with genuinely round corners --
adds to that here.
Where body holds item: (X Y Z PITCH YAW ROLL) of the grip in the view
frame, before walking bob is added.
Notify item that body has just taken it in hand.
Notify item that body has just pocketed it.
The player clicked button while body held item. Return true when the
item did something with the click, so it does not go on to edit the world;
the default hand holds things but does nothing with them.
Let item ease its own state by seconds while body holds it.
--------------------------------------------------------------------- The body.
Items the body owns but is not holding. A pocketed item keeps its state -- the phone keeps its shell -- and comes back out as it was.
How far the held item has come up into view, 0 (pocketed) to 1 (held). Eased toward its target every frame so taking something out is a motion rather than a cut.
The walking bob, accumulated from ground speed so standing still stands still.
The landing: the last downward speed seen while airborne, whether the body was on the ground last frame, and how deep and how far along the current landing dip is.
A time base for the small breathing sway of a body that is not walking anywhere.
The lower-screen proxy and live shader are render resources owned by the body itself once it is attached to a session.
The first-person body: two arms and what they hold.
Publish body's current view-local palms to its SDF instance buffer.
Attach session's first-person SDF body and its owned GPU resources.
ADD owns BODY and its installed resources from this point, including the terminal-rejection cleanup path.
Pocket whatever body holds and return it, or NIL when the hand was empty.
Put item in body's hand, pocketing whatever was there, and return it.
An item whose display or other live attachment failed to open is not nevertheless published in the hand as an inert shell. Pocket it so the next take-out is a real retry.
Take out body's item of type -- from the pocket, or newly made -- or put
it away when it is already the thing in hand. Returns what is now held.
Ease body's held item and walking bob by seconds.
The eye's displacement from the player's nominal eye point, as (SWAY LIFT): SWAY along the camera's right, LIFT along world up.
Put camera at player's eye, displaced by body's walking bob and landing.
--------------------------------------------------------------------- Boxes in a frame.
Return right up forward turned by yaw about up, then pitch about the new
right, then roll about the new forward. A positive yaw turns forward toward
the right; a positive pitch tips the top away from the viewer.
Append one box centred on origin with axes right up forward to vertices.
The box's local x, y, z are those axes; right up forward must be a unit
orthonormal frame, so the face normals come out unit too.
--------------------------------------------------------------------- The body's boxes.
The normalized sky and block light where the eye is.
Where side's (:LEFT or :RIGHT) palm is in the view frame, and its tilt.
Returns (X Y Z PITCH YAW ROLL). The right hand is where a held item lives; the left just hangs into the corner of the view.
The world-space frame of the right hand's grip this frame.
Returns the palm point and the unit RIGHT, UP, and FORWARD of the grip. A held item's boxes are placed in this frame, and a display drawn on a held item (the phone's terminal) expresses the camera in it.
Append session's held item; its arms and hands are the SDF scene overlay.
--------------------------------------------------------------------- A slab with round corners.
Return the (X . Y) corners of a rounded rectangle, counter-clockwise
from the right side's lower end, with segments arcs per corner.
Corner centres and the angle each arc starts at: lower right, upper right, upper left, lower left, each arc turning a quarter.
Append a slab centred on origin with axes right up forward whose four
corners are rounded to radius in the RIGHT/UP plane: two flat faces and a
band of quads around the edge, all wearing tile stretched once around.
The two flat faces, as fans from the centre. The front (-z) face is wound to face the eye; the back the other way.
The rim: one quad per outline edge, its normal the edge's outward perpendicular, the tile running once around it.
Build the block-pipeline stream for the player's held item this frame.
A comically large phone: a graphite slab with a live terminal on its face toward the player. Held in the right hand; TAB focuses its display.
The most box-equivalents (36 vertices) the body and its held item may emit per frame; a rounded slab counts for several.
Multiplication and scalar scaling.
How quickly a held item rises into view or drops out of it, per second.
Radians of walking bob per second at full walking speed.
Peak-to-trough rise of the eye over one step, in cells.
Sideways amplitude of the eye over one stride, in cells.
Eye dip per cell-per-second of landing speed, in cells.
How long the landing dip takes to go down and come back.
(name (&key label (group :grading) documentation
(class ''scalar-knob)
quantity (type 'single-float)
unit-label minimum maximum step)
place)Define NAME as a knob of CLASS over the setf-able PLACE. PLACE may refer to SESSION, so a knob can live on the session -- its sky clock, its player -- as well as in a special. QUANTITY is a quantity plist as DEFINE-QUANTITY-CONSTANT takes, (:quantity ... :unit ...); it and TYPE make the knob's declaration, which…
(item body function)Call FUNCTION for each textured box of ITEM as held by BODY. FUNCTION receives (X Y Z HALF-X HALF-Y HALF-Z TILE &KEY TILT STRETCH-P EMISSION), like MAP-CRITTER-BOXES with three extras: TILT is a (PITCH YAW ROLL) triple of radians turning the box about its own centre, STRETCH-P stretches the whole atlas tile over each…
(critter function)Call FUNCTION for each textured box of CRITTER's model. Each call passes the box centre and half extents in the animal's own frame -- X to its right, Y up from the ground it stands on, Z ahead of it -- and the atlas tile its faces wear: (X Y Z HALF-X HALF-Y HALF-Z TILE). The emitter turns the boxes by the critter's…
(item body vertices palm right up forward
sky-level block-level)Append ITEM's geometry, held by BODY, to VERTICES. PALM is the world point of the grip and RIGHT UP FORWARD its unit frame. The default method emits the item's MAP-HAND-ITEM-BOXES; an item whose shape is not a heap of boxes -- a slab with genuinely round corners -- adds to that here.
(item body)Where BODY holds ITEM: (X Y Z PITCH YAW ROLL) of the grip in the view frame, before walking bob is added.
(item body session button)The player clicked BUTTON while BODY held ITEM. Return true when the item did something with the click, so it does not go on to edit the world; the default hand holds things but does nothing with them.
(item body seconds)Let ITEM ease its own state by SECONDS while BODY holds it.
The first-person body: two arms and what they hold.
(overlay)Return where OVERLAY draws: :SCENE, :WORLD-PANEL, :VIEWMODEL, :HUD, or :NONE. Scene overlays inhabit world depth; viewmodels are first-person geometry above the world but below held items and the crosshair. World panels retain world projection and depth while drawing analytic application graphics at native…
(overlay)The live shader pipelines OVERLAY owns, so the session can count them among its own; none by default.
(body side)Where SIDE's (:LEFT or :RIGHT) palm is in the view frame, and its tilt. Returns (X Y Z PITCH YAW ROLL). The right hand is where a held item lives; the left just hangs into the corner of the view.
Addition over compatible quantities.
(overlay session pass surface-texture)Encode OVERLAY into SESSION's open scene PASS for SURFACE-TEXTURE.
An explicitly owned AVFrame.
(pass-encoder pipeline)(pass-encoder slot buffer &key (offset 0))(pass-encoder index bind-group)(pass-encoder vertex-count
&optional (instance-count 1) (first-vertex 0) (first-instance 0))(overlay)Release resources owned by an object attached to luvcraft.
(artifact)(handle)Logically invalidate HANDLE immediately. Native teardown may be deferred until submitted work which captured HANDLE has completed.
(session)(device descriptor)Asks the DEVICE for a handle to newly created instance of some object fulfilling the DESCRIPTOR.
(&key role (stage :fragment) vertex-role label device layout vertex-module
vertex-buffers target-format target-blend primitive depth-stencil)Create and install a live mathematical render pipeline. VERTEX-MODULE is borrowed when VERTEX-ROLE is NIL and STAGE is not :VERTEX. Every module compiled from ROLE or VERTEX-ROLE is owned by the returned artifact and retired on replacement or explicit release.
The linear HDR attachment format shared by every scene-stage pipeline.
(session overlay)Attach OVERLAY at SESSION's next native frame boundary and return it. ADD consumes a newly offered OVERLAY on both success and terminal rejection. Once SESSION begins stopping, the rejected overlay is released exactly once before APPLICATION-ATTACHMENT-CLOSED is signalled.
Logical disjunction of tests and raw truth values.
(body session)(session)(body session item)(body session type)Take out BODY's item of TYPE -- from the pocket, or newly made -- or put it away when it is already the thing in hand. Returns what is now held.
Headings, paragraphs, figures and their IDs, mentions, marks.
(body session seconds)Compare compatible quantities and produce dimensionless values.
Test whether one compatible scalar is greater than another.
The minimum of compatible quantities.
Test whether one compatible scalar is less than another.
The maximum of compatible quantities.
Subtraction or unary negation.
Logical conjunction of tests and raw truth values.
The componentwise square root of a raw value.
Raise a dimensionless value to a dimensionless power.
Division of two represented quantities.
Logical negation of one test or raw truth value.
(player)(focus)Whether FOCUS moves the player itself instead of the player controller. A terminal on a wall leaves the player standing in front of it and the ordinary scalar controller keeps running. A mount does not: it carries the player, so the controller must stand down for as long as the interaction lasts.
(body player camera)(body)The eye's displacement from the player's nominal eye point, as (SWAY LIFT): SWAY along the camera's right, LIFT along world up.
(camera player)(right up forward pitch yaw roll)Return RIGHT UP FORWARD turned by YAW about up, then PITCH about the new right, then ROLL about the new forward. A positive yaw turns forward toward the right; a positive pitch tips the top away from the viewer.
(x y z)(origin right up forward x y z)(vertices origin right up forward half-x half-y half-z tile
sky-level block-level emission stretch-p)Append one box centred on ORIGIN with axes RIGHT UP FORWARD to VERTICES. The box's local x, y, z are those axes; RIGHT UP FORWARD must be a unit orthonormal frame, so the face normals come out unit too.
(tile &optional (domain *block-atlas-tile-domain*))(normal-y)Return the ambient shade of a critter face with world normal lane NORMAL-Y. An animal carries no baked neighbourhood, but its underside is genuinely more occluded than its shell, and saying so is what keeps it from reading as a paper cut-out standing on the grass.
(face half-x half-y half-z)Return how much of FACE's tile the face's two in-plane extents deserve. The in-plane axes are the ones BLOCK-FACE-LOCAL-UV projects onto, read from the same face normal it reads.
(face corner)Project CORNER onto FACE's plane as tile-local UV coordinates. The rule is read from the face's own outward normal rather than its name: horizontal faces map world X,Z straight across the tile, and lateral faces keep the world-horizontal axis as U while flipping world Y into V so tiles hang upright.
(vertices px py pz local-u local-v shade nx ny nz
sky-level block-level emission tile
edge-u-low edge-u-high edge-v-low edge-v-high)Append one interleaved vertex without constructing tuple objects. The fourth lane carries normalized raw light readings, not an art-directed bake: shader edits can change the response curve without remeshing the world. The final two scalars carry the atlas tile offset under the atlas mapping and the face's four…
(session)(world x y z)(camera)(camera)(camera)(a b amount)The componentwise absolute value of a raw value.
(session)The world-space frame of the right hand's grip this frame. Returns the palm point and the unit RIGHT, UP, and FORWARD of the grip. A held item's boxes are placed in this frame, and a display drawn on a held item (the phone's terminal) expresses the camera in it.
(camera)(vertices session)(half-x half-y radius segments)Return the (X . Y) corners of a rounded rectangle, counter-clockwise from the right side's lower end, with SEGMENTS arcs per corner.
(vertices origin right up forward half-x half-y half-z radius tile
sky-level block-level &key (segments 6) (emission 0.0))Append a slab centred on ORIGIN with axes RIGHT UP FORWARD whose four corners are rounded to RADIUS in the RIGHT/UP plane: two flat faces and a band of quads around the edge, all wearing TILE stretched once around.
Test whether two compatible scalars are equal.
The non-negative remainder of integer division.
(session)Test whether one compatible scalar is at most another.
The player's own body as seen from inside it, and what its hands hold.
#S27JKR is the design; this is what it turned into.
The camera has always been a disembodied eye. This gives it a pair of arms hanging into the bottom of the view, hands on the ends of them, and a grip protocol so that a hand can hold something: brought up out of a pocket, held while walking, put away again.
The body is an SDF like the embodied agents. In first person its visible slice is the arms and hands, sphere-traced in the
*view*frame -- x to the right, y up, z forward, origin at the eye -- so the body stays attached to the camera while the head looks around. Held things retain their own geometry and grip protocol: an analytic hand can still hold a round-corner phone with a live terminal on it.The first thing a hand can hold is a phone (
phone.LISP). It is deliberately a little too large: a slab of near-black glass with a live terminal on it, held up in front of the face like everyone holds theirs.