C API: Ragdolls¶
Bodies fitted to the avatar for the host's physics engine, and the handoff to a ragdoll and back: Physics-ready avatars.
sona_ragdoll_defaults¶
void sona_ragdoll_defaults(sona_ragdoll_options *o);
| Parameter and type | Meaning |
|---|---|
osona_ragdoll_options * |
The sona_ragdoll_options to fill with the defaults (required) |
Returns Nothing.
Example:
sona_ragdoll_options x_ragdoll_options;
memset(&x_ragdoll_options, 0, sizeof x_ragdoll_options);
x_ragdoll_options.size = sizeof x_ragdoll_options;
sona_ragdoll_defaults(&x_ragdoll_options);
size set; coverage 0.9.
sona_avatar_ragdoll¶
sona_result sona_avatar_ragdoll(sona_avatar *a,
const sona_ragdoll_options *o,
sona_ragdoll_body *out, uint32_t cap,
uint32_t *count);
| Parameter and type | Meaning |
|---|---|
asona_avatar * |
The avatar (required) |
oconst sona_ragdoll_options * |
The options, a sona_ragdoll_options (required) |
outsona_ragdoll_body * |
Receives the sona_ragdoll_body (required) |
capuint32_t |
How many entries out holds |
countuint32_t * |
Receives how many entries there are; may be NULL (NULL: not written) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_READY, SONA_E_MEMORY (what each means).
Fits the bodies to the avatar as it is now (its rig, body shape and outfit) and writes up to cap of them; count (may be NULL) gets SONA_RAGDOLL_BODIES. The same avatar and options give the same bits. From this call on, each pose keeps the bodies' last two transforms for sona_avatar_ragdoll_state. SONA_E_NOT_READY before the avatar is READY and posed; SONA_E_ARGUMENT for a bad size, flag, mass or coverage.
sona_avatar_ragdoll_state¶
sona_result sona_avatar_ragdoll_state(const sona_avatar *a,
sona_ragdoll_state *out, uint32_t cap,
uint32_t *count);
| Parameter and type | Meaning |
|---|---|
aconst sona_avatar * |
The avatar (required) |
outsona_ragdoll_state * |
Receives the sona_ragdoll_state (required) |
capuint32_t |
How many entries out holds |
countuint32_t * |
Receives how many entries there are; may be NULL (NULL: not written) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_READY (what each means).
The bodies at the last pose, with velocities from the last two poses (on the scene clock; zero until there have been two). For the host's bodies when it takes over. SONA_E_NOT_READY before sona_avatar_ragdoll.
sona_avatar_ragdoll_drive¶
sona_result sona_avatar_ragdoll_drive(sona_avatar *a,
const sona_ragdoll_state *bodies,
uint32_t count, float weight,
uint32_t flags);
| Parameter and type | Meaning |
|---|---|
asona_avatar * |
The avatar (required) |
bodiesconst sona_ragdoll_state * |
A sona_ragdoll_state (required) |
countuint32_t |
How many entries the array holds |
weightfloat |
How much of the host's bodies to show over the clip, 0 to 1 |
flagsuint32_t |
Option bits for the call; 0: none (0: none) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_MEMORY (what each means).
Example:
sona_ragdoll_state x_ragdoll_state;
memset(&x_ragdoll_state, 0, sizeof x_ragdoll_state);
sona_result result = sona_avatar_ragdoll_drive(avatar, &x_ragdoll_state, 1,
0.5f, 0);
if (result != SONA_OK) printf("sona_avatar_ragdoll_drive: %s\n",
sona_result_name(result));
The host's simulated bodies onto the avatar: from the next pose it draws them, until released. count is SONA_RAGDOLL_BODIES; velocities are not read. weight 0..1 blends from the clip's pose (0.3: a hit reaction); every joint between bodies (fingers, toes, the neck, the face) keeps its clip pose relative to its body. Call it after each physics step. SONA_RAGDOLL_KEEP_LENGTHS: only the bodies' turns and the hips' position are taken, so the bones keep their lengths. SONA_E_ARGUMENT for a bad count, weight or flag, or a body that is not finite.
sona_avatar_ragdoll_release¶
sona_result sona_avatar_ragdoll_release(sona_avatar *a,
float blend_seconds);
| Parameter and type | Meaning |
|---|---|
asona_avatar * |
The avatar (required) |
blend_secondsfloat |
Seconds over which the ragdoll blends back to the clip |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED (what each means).
Example:
sona_result result = sona_avatar_ragdoll_release(avatar, 0.5f);
if (result != SONA_OK) printf("sona_avatar_ragdoll_release: %s\n",
sona_result_name(result));
Back to the animation: the last drawn ragdoll pose stays where it is in the world and blends into the clip's pose over blend_seconds (smoothstep; 0: at once), turn by turn down the body, so limbs stay joined. Play the get-up clip and move the placement to sona_ragdoll_info's getup_position and getup_turn_deg first.
sona_avatar_ragdoll_info¶
sona_result sona_avatar_ragdoll_info(const sona_avatar *a,
sona_ragdoll_info *out);
| Parameter and type | Meaning |
|---|---|
aconst sona_avatar * |
The avatar (required) |
outsona_ragdoll_info * |
Receives the sona_ragdoll_info (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_READY (what each means).
Example:
sona_ragdoll_info x_ragdoll_info;
memset(&x_ragdoll_info, 0, sizeof x_ragdoll_info);
x_ragdoll_info.size = sizeof x_ragdoll_info;
sona_result result = sona_avatar_ragdoll_info(avatar, &x_ragdoll_info);
if (result != SONA_OK) printf("sona_avatar_ragdoll_info: %s\n",
sona_result_name(result));
SONA_E_NOT_READY before the avatar has been posed since sona_avatar_ragdoll.
sona_avatar_ragdoll_clear¶
void sona_avatar_ragdoll_clear(sona_avatar *a);
| Parameter and type | Meaning |
|---|---|
asona_avatar * |
The avatar (required) |
Returns Nothing.
Example:
sona_avatar_ragdoll_clear(avatar);
Off at once: no tracking, no drive, no blend.
sona_avatar_ragdoll_motors¶
sona_result sona_avatar_ragdoll_motors(const sona_avatar *a,
sona_ragdoll_motor *out,
uint32_t cap, uint32_t *count);
| Parameter and type | Meaning |
|---|---|
aconst sona_avatar * |
The avatar (required) |
outsona_ragdoll_motor * |
Receives the sona_ragdoll_motor (required) |
capuint32_t |
How many entries out holds |
countuint32_t * |
Receives how many entries there are; may be NULL (NULL: not written) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_READY (what each means).
The targets of the last pose, velocities from the last two (zero until there have been two). count (may be NULL) gets SONA_RAGDOLL_BODIES. SONA_E_NOT_READY before sona_avatar_ragdoll. The stock get-up clips are "getup_back" and "getup_front" (physics guide, "Getting up").
This page as Markdown · All the docs as one file (llms-full.txt)