C API: Two-avatar interactions and seats¶
High fives, handshakes, hugs, holding hands and sitting, with the avatars placed and their hands and hips meeting: Two-avatar interactions.
sona_seat_defaults¶
void sona_seat_defaults(sona_seat *s, uint32_t kind);
| Parameter and type | Meaning |
|---|---|
ssona_seat * |
The sona_seat to fill with the defaults (required) |
kinduint32_t |
Which kind, one of the header's constants for it |
Returns Nothing.
Example (also in Two-avatar interactions and seats):
sona_interaction_defaults(&d, SONA_INTERACT_SIT);
d.a = adult; d.b = child; /* b NULL: one sitter */
d.flags = SONA_INTERACT_HANDS; /* two sitters: the near hands hold */
sona_seat_defaults(&d.seat, SONA_SEAT_BENCH);
/* the front edge's middle, on top */
d.seat.position[0] = 4; d.seat.position[1] = 0.45f;
d.seat.position[2] = 0.3f;
d.seat.turn_deg = 0; /* the way they face */
sona_interaction_start(ctx, &d, &it);
size set and a seat of that kind: height 0.45 (0 for GROUND), depth 0.45 (unlimited for GROUND), width 0.5 for a chair, 1.4 for a bench and unlimited on the ground.
sona_interaction_defaults¶
void sona_interaction_defaults(sona_interaction_desc *d, uint32_t kind);
| Parameter and type | Meaning |
|---|---|
dsona_interaction_desc * |
The sona_interaction_desc to fill with the defaults (required) |
kinduint32_t |
Which kind, one of the header's constants for it |
Returns Nothing.
Example (also in Two-avatar interactions and seats):
sona_interaction_defaults(&d, SONA_INTERACT_SIT);
d.a = adult; d.b = child; /* b NULL: one sitter */
d.flags = SONA_INTERACT_HANDS; /* two sitters: the near hands hold */
sona_seat_defaults(&d.seat, SONA_SEAT_BENCH);
/* the front edge's middle, on top */
d.seat.position[0] = 4; d.seat.position[1] = 0.45f;
d.seat.position[2] = 0.3f;
d.seat.turn_deg = 0; /* the way they face */
sona_interaction_start(ctx, &d, &it);
Sets size, kind, the kind's default timings in seconds (high five 0.8, 0.15, 0.7; handshake 0.9, 1.6, 0.8; hug 1.1, 2.5, 1.0; hold hands 0.8, 0, 0.6; sit 1.3, 0, 1.4) and a default seat.
sona_interaction_layout¶
sona_result sona_interaction_layout(const sona_interaction_desc *d,
sona_interaction_plan *out);
| Parameter and type | Meaning |
|---|---|
dconst sona_interaction_desc * |
The options, a sona_interaction_desc (required) |
outsona_interaction_plan * |
Receives the sona_interaction_plan (required) |
Returns SONA_OK, SONA_PENDING while it is still working. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_READY, SONA_E_NOT_FOUND, SONA_E_LIMIT, SONA_E_MEMORY, SONA_E_IO, SONA_E_CORRUPT (what each means).
Example:
sona_interaction_desc x_interaction_desc;
memset(&x_interaction_desc, 0, sizeof x_interaction_desc);
x_interaction_desc.size = sizeof x_interaction_desc;
sona_interaction_plan x_interaction_plan2;
memset(&x_interaction_plan2, 0, sizeof x_interaction_plan2);
x_interaction_plan2.size = sizeof x_interaction_plan2;
sona_result result = sona_interaction_layout(&x_interaction_desc,
&x_interaction_plan2);
if (result != SONA_OK) printf("sona_interaction_layout: %s\n",
sona_result_name(result));
SONA_E_ARGUMENT for a bad desc (sizes, kind, flags, timings, a missing or repeated avatar, a seat too narrow for two), SONA_E_NOT_READY until both avatars are READY, and for SIT SONA_PENDING until the stock sit clip has been read (the call asks the sources for it; call again). Owner thread only, like sona_interaction_start: it measures both bodies (a few milliseconds) and may read the clip into the ctx.
sona_interaction_start¶
sona_result sona_interaction_start(sona_ctx *ctx,
const sona_interaction_desc *d,
sona_interaction **out);
| Parameter and type | Meaning |
|---|---|
ctxsona_ctx * |
The context (required) |
dconst sona_interaction_desc * |
The options, a sona_interaction_desc (required) |
outsona_interaction ** |
Receives the new interaction (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_READY, SONA_E_NOT_FOUND, SONA_E_LIMIT, SONA_E_MEMORY, SONA_E_IO, SONA_E_CORRUPT (what each means).
Example (also in Two-avatar interactions and seats):
sona_interaction_defaults(&d, SONA_INTERACT_SIT);
d.a = adult; d.b = child; /* b NULL: one sitter */
d.flags = SONA_INTERACT_HANDS; /* two sitters: the near hands hold */
sona_seat_defaults(&d.seat, SONA_SEAT_BENCH);
/* the front edge's middle, on top */
d.seat.position[0] = 4; d.seat.position[1] = 0.45f;
d.seat.position[2] = 0.3f;
d.seat.turn_deg = 0; /* the way they face */
sona_interaction_start(ctx, &d, &it);
Starts it: the avatars are placed (eased over the first part of the start phase when they are near), their clips started together and their IK targets driven from now on. An avatar in another running interaction is refused (SONA_E_ARGUMENT); SONA_E_LIMIT when the ctx holds 64, finished ones included: an interaction is freed only by sona_interaction_remove (or sona_close), so a handle stays valid until the host removes it.
sona_interaction_end¶
sona_result sona_interaction_end(sona_interaction *it);
| Parameter and type | Meaning |
|---|---|
itsona_interaction * |
The interaction (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_FOUND (what each means).
Begins the end phase now (a hold of 0 waits for this). No effect once ending.
sona_interaction_move¶
sona_result sona_interaction_move(sona_interaction *it,
const float position[3], float turn_deg);
| Parameter and type | Meaning |
|---|---|
itsona_interaction * |
The interaction (required) |
positionconst float [3] |
Where to move it, world space (required) |
turn_degfloat |
Which way it faces, degrees |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED (what each means).
Moves the place (and the seat with it) while it runs, for a pair walking hand in hand; contacts follow.
sona_interaction_remove¶
void sona_interaction_remove(sona_interaction *it);
| Parameter and type | Meaning |
|---|---|
itsona_interaction * |
The interaction (required) |
Returns Nothing.
Example (also in Cookbook: recipes for game moments):
sona_interaction_desc d;
sona_interaction *it;
sona_interaction_defaults(&d, SONA_INTERACT_HIGH_FIVE);
d.a = avatar;
d.b = other;
if (sona_interaction_start(ctx, &d, &it) == SONA_OK) {
/* each frame: sona_interaction_events(it, ...); when it ends,
sona_interaction_remove(it) */
}
Stops at once and frees it: its IK targets go, the avatars stay where they are and keep their clip.
sona_interaction_status_get¶
sona_result sona_interaction_status_get(const sona_interaction *it,
sona_interaction_status *out);
| Parameter and type | Meaning |
|---|---|
itconst sona_interaction * |
The interaction (required) |
outsona_interaction_status * |
Receives the sona_interaction_status (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).
Where an interaction is: its kind and phase, the time in the phase and how far through it, whether the contacts are together, the widest gap at a contact, the clearance between the two bodies (negative: into each other), the contact points now and the IK hit bits of both avatars' limbs.
sona_interaction_events¶
uint32_t sona_interaction_events(sona_interaction *it,
sona_interaction_event *out, uint32_t max);
| Parameter and type | Meaning |
|---|---|
itsona_interaction * |
The interaction (required) |
outsona_interaction_event * |
Receives the sona_interaction_event (required) |
maxuint32_t |
How many entries out holds |
Returns uint32_t.
Example (also in Cookbook: recipes for game moments):
sona_interaction_desc d;
sona_interaction *it;
sona_interaction_defaults(&d, SONA_INTERACT_HIGH_FIVE);
d.a = avatar;
d.b = other;
if (sona_interaction_start(ctx, &d, &it) == SONA_OK) {
/* each frame: sona_interaction_events(it, ...); when it ends,
sona_interaction_remove(it) */
}
Moves up to max events since the last call into out (SONA_INTERACT_EV_*: contact, a handshake pump, release, end, cancel) and returns how many.
This page as Markdown · All the docs as one file (llms-full.txt)