an.ir.holds#
Holding things: grasp, place, release, handover and swap (an#502, catalogue A4).
A hold says what carries an item over a span of a shot: a hand (any point of a body), a socket of another body (a figurine’s hand), the ground, a point of the stage, or nothing (it is in flight). These five action kinds change holds, and each one moves the holder the way a hand would, so the change reads as handled rather than teleported:
grasp: the holder’s point (by) reaches the item’s grip overreachseconds, takes it at the instant it arrives (the item keeps the pose it has at that instant: no slide, no jump), and retracts to where the shot would have it overretractseconds, carrying it. The item is taken from whatever held it: the ground, a socket, another hand (a hand-over between two hands is the receiver’sgrasp).place: the hand that holds the item brings itontoa target overreachseconds (its contact point onto the ground at floor height, its grip into a socket, aligned with the socket’s frame), lets it go there, and retracts empty.release: the hand lets go atat; the item falls under gravity with the velocity it had and lands on the ground at its rest angle, or is tossedonto: ground@xon an arc of heightarc.handover:placeinto another holder’s point (to), or, withmeetbelow 1, both hands reach toward each other and the receiver takes it where they meet.swap: a hand takes the item a holder has (take) and the hand holding another item gives it in its place (give), a beat later.
A reach that cannot arrive is never cheated: the body it hangs from may bend
(lean, degrees; the chain’s root turns about its own pivot, the way a
figure bends at the hip), and beyond that an validate says how far the
hand stays short and where to stand instead.
None of these makes a clip: the solve compile pass reads them
(an.stage.hold) and emits the holders’ and the items’ keys.
>>> from an.ir.compose import flatten, sequence, delay
>>> [(f.start, f.end, f.action.kind) for f in flatten(sequence(delay(1.0), grasp("paul/arm_r", "cup")))]
[(1.0, 1.75, 'grasp')]
>>> [(f.start, f.action.kind) for f in flatten(sequence(delay(2.0), release("cup", at=0.5)))]
[(2.5, 'release')]
>>> [(round(f.start, 2), f.action.kind) for f in flatten(swap("nap/hand", take="musket", give="sword", by="stu@hand_r"))]
[(0.0, 'grasp'), (0.25, 'place')]
These kinds are the core’s (ADR 0001’s test: a robot arm putting a box on a
shelf needs them without saying character), registered when an.ir loads.
Module Attributes
a deliberate reach at arm's length, about two thirds of a second there and back. |
|
How long the hand takes to come back to where the shot has it (s). |
|
a figure bent well over at the hip. |
|
How high a toss rises above the higher of its two ends (scene px). |
|
In a |
|
The name of the floor in a target ( |
|
The point name of a body's supporting surface in a target (an#536): |
|
The kinds' names. |
|
The kinds that move a hand (a reach and a retract), as flattened leaves. |
Functions
|
|
|
The hand holding |
|
Let |
|
Give |
|
|
Classes
|
|
|
The hand holding |
|
The hand holding |
|
The hand holding |
|
|
- an.ir.holds.DFLT_LEAN_DEG: float = 60.0#
a figure bent well over at the hip.
0never bends.- Type:
How far the body a hand hangs from may turn to reach (degrees)
- an.ir.holds.DFLT_REACH: float = 0.4#
a deliberate reach at arm’s length, about two thirds of a second there and back.
- Type:
How long a hand takes to reach what it takes or where it puts it (s)
- an.ir.holds.DFLT_RETRACT: float = 0.35#
How long the hand takes to come back to where the shot has it (s).
- an.ir.holds.DFLT_SWAP_LAG: float = 0.25#
In a
swap, how long after the taking hand starts the giving hand starts (s): it arrives a beat after the socket is empty.
- an.ir.holds.DFLT_TOSS_ARC: float = 0.0#
How high a toss rises above the higher of its two ends (scene px).
0: it is let fall, never thrown up (a let-go item does not rise; a positivearcis a throw).
- an.ir.holds.GESTURE_KINDS: tuple[str, ...] = ('grasp', 'place', 'handover')#
The kinds that move a hand (a reach and a retract), as flattened leaves.
- class an.ir.holds.GraspAction(*, name=None, kind='grasp', by, item, reach=0.4, retract=0.35, lean=60.0, align=True, carry=None, **extra_data)[source]#
Bases:
ExtensionActionby(a body’s point: a hand) reachesitem’s grip and takes it.itemis an entity id, with@<point>the grip (a bone of its rig, oru,va fraction of its drawing); unset: itsgripbone, else its stage point.bywith no@is the far end of the body (an arm’s hand). The item is held fromstart + reachon, and over the retract it turns to how the hand holds things (align): drawn as it is, upright along the hand’s part, the way a socket holds it;align: falsekeeps the angle it was taken at.carry(degrees) turns the aligned item by that much from how the hand holds it, about the grip, mirrored with the hand: a long musket carried atcarry: -60points up and clears the floor a hand near the ground would sink it through (an#864). It needsalign.>>> GraspAction(by="stu@hand_r", item="musket").reach == DFLT_REACH True >>> GraspAction(by="stu@hand_r", item="musket", carry=-60).carry -60.0
- an.ir.holds.HOLD_ACTION_KINDS: tuple[str, ...] = ('grasp', 'place', 'release', 'handover', 'swap')#
The kinds’ names.
- class an.ir.holds.HandoverAction(*, name=None, kind='handover', item, to, by=None, meet=1.0, reach=0.4, retract=0.35, lean=60.0, align=True, **extra_data)[source]#
Bases:
ExtensionActionThe hand holding
itemgives it toto(a hand, or a socket).meetis where the two meet, as a fraction of the way from the giver’s hand to the receiver’s:1(the default) puts it into the receiver’s point, which does not move (a figurine’s hand, a waiting hand); below 1 both hands reach and the receiver takes it where they meet (and turns it as agraspdoes,align).>>> HandoverAction(item="sword", to="nap/arm_r/weapon").meet 1.0
- class an.ir.holds.PlaceAction(*, name=None, kind='place', item, onto, by=None, rotation=None, reach=0.4, retract=0.35, lean=60.0, **extra_data)[source]#
Bases:
ExtensionActionThe hand holding
itemputs itontoa target and lets it go.ontoisground(straight down, at floor height),ground@x(at stagex), a body’s point (a socket: the item’s grip goes there, its frame aligned with the socket’s), a body’s surface (crate@surface, orcrate@surface@fat that fraction along it: lying on its top as on the ground, held by that body from then on, an#536) orworld@x,y(hung on a point).item@<point>names the item’s point that touches the target (default: its grip on a socket, its lowest point on the ground).rotation: the item’s rotation where it rests (radians, the stage’s; on a surface, relative to the surface, whose tilt is added; default: the angle it last rested at, else the nearest quarter turn; in a socket, the socket’s own). In a socket it is the angle the item comes to rest at (a musket aimed at someone, a sabre raised), held relative to the socket from then on, so it turns with it.>>> PlaceAction(item="musket", onto="nap/arm_r/weapon").by is None True
- class an.ir.holds.ReleaseAction(*, name=None, kind='release', item, at=0.0, onto=None, arc=0.0, rotation=None, bounce=None, **extra_data)[source]#
Bases:
ExtensionActionThe hand holding
itemlets it go atat: it falls (never rising) onto the ground,onto: ground@xnudged to land there, or tossed up first whenarc(px above the hand) is positive; it lands one end first, tips onto its side atrotation(default: the side of it it falls nearest to) and bounces a little (bounce: the coefficient of restitution, defaultan.stage.rigid.DFLT_BOUNCE; 0 lands dead).>>> ReleaseAction(item="cup", at=1.0).onto is None True
- an.ir.holds.SURFACE: str = 'surface'#
The point name of a body’s supporting surface in a target (an#536):
crate@surface(below the hand),crate@surface@0.3(that fraction of the way along it), as on the ground but on the body’s top, following it.
- class an.ir.holds.SwapAction(*, name=None, kind='swap', holder, take, give, by, lag=0.25, rotation=None, reach=0.4, retract=0.35, lean=60.0, align=True, **extra_data)[source]#
Bases:
ExtensionActionbytakestakefromholderand the hand holdinggiveputs that there,lagseconds later: agraspand aplace.rotationis the place’s: the anglegivecomes to rest at in the holder (radians, the stage’s; default: the holder’s own).>>> SwapAction(holder="nap/hand", take="musket", give="sword", by="stu@hand_r").lag == DFLT_SWAP_LAG True
- an.ir.holds.grasp(by, item, *, reach=0.4, retract=0.35, lean=60.0, align=True, carry=None)[source]#
bytakesitem.>>> grasp("stu@hand_r", "musket@grip").item 'musket@grip'
- Return type:
- an.ir.holds.handover(item, to, *, by=None, meet=1.0, reach=0.4, retract=0.35, lean=60.0, align=True)[source]#
Give
itemtoto.>>> handover("cup", "jo@hand_l", meet=0.5).meet 0.5
- Return type:
- an.ir.holds.place(item, onto, *, by=None, rotation=None, reach=0.4, retract=0.35, lean=60.0)[source]#
The hand holding
itemputs itontoa target.>>> place("book", "ground@-860").onto 'ground@-860'
- Return type:
- an.ir.holds.release(item, *, at=0.0, onto=None, arc=0.0, rotation=None, bounce=None)[source]#
Let
itemgo atat(a drop;onto: ground@xto land there;arc> 0 to throw it up first).>>> release("musket", onto="ground@-620", arc=60).arc 60.0 >>> release("musket", onto="ground@-620").arc # let fall: no rise 0.0
- Return type: