C API: Props: held and worn objects¶
Your own meshes and glTF files, and the catalogue's stock props and pets, in an avatar's hands or on any joint: Props.
sona_prop_part_defaults¶
void sona_prop_part_defaults(sona_prop_part *p);
| Parameter and type | Meaning |
|---|---|
psona_prop_part * |
The sona_prop_part to fill with the defaults (required) |
Returns Nothing.
Example:
sona_prop_part x_prop_part;
sona_prop_part_defaults(&x_prop_part);
sona_prop_part_defaults(&x_prop_part);
size set; colour 0xffffffff.
sona_prop_load_defaults¶
void sona_prop_load_defaults(sona_prop_load_options *o);
| Parameter and type | Meaning |
|---|---|
osona_prop_load_options * |
The sona_prop_load_options to fill with the defaults (required) |
Returns Nothing.
Example:
sona_prop_load_options x_prop_load_options;
memset(&x_prop_load_options, 0, sizeof x_prop_load_options);
x_prop_load_options.size = sizeof x_prop_load_options;
sona_prop_load_defaults(&x_prop_load_options);
size set; scale 1.
sona_prop_mesh_create¶
sona_result sona_prop_mesh_create(sona_ctx *ctx,
const sona_prop_part *parts,
uint32_t count, sona_prop_mesh **out);
| Parameter and type | Meaning |
|---|---|
ctxsona_ctx * |
The context (required) |
partsconst sona_prop_part * |
A sona_prop_part (required) |
countuint32_t |
How many entries the array holds |
outsona_prop_mesh ** |
Receives the new prop mesh (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_LIMIT, SONA_E_MEMORY (what each means).
A mesh from the host's triangles; the data is copied. SONA_E_ARGUMENT for a bad part, SONA_E_LIMIT past 64 parts.
sona_prop_mesh_load¶
sona_result sona_prop_mesh_load(sona_ctx *ctx, const void *bytes,
size_t len, const sona_prop_load_options *o,
sona_prop_mesh **out, char *why,
size_t why_cap);
| Parameter and type | Meaning |
|---|---|
ctxsona_ctx * |
The context (required) |
bytesconst void * |
The file's bytes (required) |
lensize_t |
How many bytes there are |
oconst sona_prop_load_options * |
The options, a sona_prop_load_options (required) |
outsona_prop_mesh ** |
Receives the new prop mesh (required) |
whychar * |
Receives what was refused, NUL-terminated; may be NULL (NULL: not written) |
why_capsize_t |
How many bytes why holds |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_NOT_FOUND, SONA_E_UNSUPPORTED, SONA_E_LIMIT, SONA_E_CORRUPT (what each means).
A glTF 2.0 file (.glb, or .gltf with its buffers embedded) as a prop: every triangle primitive of the scene's nodes, their transforms applied, one part per primitive with its base colour (factor, texture, vertex colours), alpha mode BLEND as transparent, +Y up, z negated into the avatar's left-handed space (the same mirror as the glTF export and the clip importer). Skins and morph targets are ignored (the bind pose is drawn). Images are PNG or JPEG. why (may be NULL) gets the reason for a refusal: SONA_E_CORRUPT, SONA_E_UNSUPPORTED (this build reads no glTF), SONA_E_LIMIT (a primitive over 65536 vertices or 64 parts), SONA_E_NOT_FOUND (no triangles). o may be NULL.
sona_prop_mesh_open¶
sona_result sona_prop_mesh_open(sona_ctx *ctx, const char *path,
const sona_prop_load_options *o,
sona_prop_mesh **out, char *why,
size_t why_cap);
| Parameter and type | Meaning |
|---|---|
ctxsona_ctx * |
The context (required) |
pathconst char * |
A file path (required) |
oconst sona_prop_load_options * |
The options, a sona_prop_load_options (required) |
outsona_prop_mesh ** |
Receives the new prop mesh (required) |
whychar * |
Receives what was refused, NUL-terminated; may be NULL (NULL: not written) |
why_capsize_t |
How many bytes why holds |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_IO (what each means).
The same from a path (UTF-8): a .gltf's buffers and images next to it are read too. SONA_E_IO when it cannot be read.
sona_prop_mesh_stock¶
sona_result sona_prop_mesh_stock(sona_ctx *ctx, const char *item_id,
sona_prop_mesh **out);
| Parameter and type | Meaning |
|---|---|
ctxsona_ctx * |
The context (required) |
item_idconst char * |
An item id as text (required) |
outsona_prop_mesh ** |
Receives the new prop mesh (required) |
Returns SONA_OK, SONA_PENDING while it is still working. Errors SONA_E_ARGUMENT, SONA_E_NOT_FOUND, SONA_E_MEMORY (what each means).
A stock prop item (a carryable: mask 0x1000, such as the pets of sona_prop_pet) with its own skeleton and clip, read through the ctx's sources like a worn item. Returns at once; sona_prop_mesh_state is SONA_PENDING until it has loaded. It can be attached meanwhile and is drawn once it is ready. Attached with SONA_PROP_JOINT_AUTO it sits as the site's held props do: in the hand its clip grips it in at its grip frame, or, for one no hand holds (most pets), where its clip puts it beside the avatar. SONA_E_ARGUMENT for an id that is not a prop item.
sona_prop_mesh_state¶
sona_result sona_prop_mesh_state(const sona_prop_mesh *m);
| Parameter and type | Meaning |
|---|---|
mconst sona_prop_mesh * |
The prop mesh (required) |
Returns SONA_OK, SONA_PENDING while it is still working. Errors SONA_E_ARGUMENT, SONA_E_NOT_FOUND (what each means).
SONA_OK, SONA_PENDING, or why it failed (SONA_E_NOT_FOUND: no source has it).
sona_prop_mesh_release¶
void sona_prop_mesh_release(sona_prop_mesh *m);
| Parameter and type | Meaning |
|---|---|
msona_prop_mesh * |
The prop mesh (required) |
Returns Nothing.
The host's reference goes; avatars it is attached to keep it until they detach it.
sona_prop_mesh_info_get¶
sona_result sona_prop_mesh_info_get(const sona_prop_mesh *m,
sona_prop_mesh_info *out);
| Parameter and type | Meaning |
|---|---|
mconst sona_prop_mesh * |
The prop mesh (required) |
outsona_prop_mesh_info * |
Receives the sona_prop_mesh_info (required) |
Returns SONA_OK, SONA_PENDING while it is still working. Errors SONA_E_ARGUMENT (what each means).
SONA_PENDING (only kind and item set) until the mesh is ready.
sona_prop_mesh_data¶
sona_result sona_prop_mesh_data(const sona_prop_mesh *m,
sona_prop_data *out);
| Parameter and type | Meaning |
|---|---|
mconst sona_prop_mesh * |
The prop mesh (required) |
outsona_prop_data * |
Receives the sona_prop_data (required) |
Returns SONA_OK, SONA_PENDING while it is still working. Errors SONA_E_ARGUMENT (what each means).
SONA_PENDING until ready.
sona_prop_attach_defaults¶
void sona_prop_attach_defaults(sona_prop_attach *o);
| Parameter and type | Meaning |
|---|---|
osona_prop_attach * |
The sona_prop_attach to fill with the defaults (required) |
Returns Nothing.
Example:
sona_prop_attach x_prop_attach;
sona_prop_attach_defaults(&x_prop_attach);
sona_prop_attach_defaults(&x_prop_attach);
size set; position 0, rotation 0 0 0 1, scale 1, hand_weight 1, fade_seconds 0.2, speed 1.
sona_avatar_prop_attach¶
sona_result sona_avatar_prop_attach(sona_avatar *a, sona_prop_mesh *m,
const sona_prop_attach *o,
uint32_t *id);
| Parameter and type | Meaning |
|---|---|
asona_avatar * |
The avatar (required) |
msona_prop_mesh * |
The prop mesh (required) |
oconst sona_prop_attach * |
A sona_prop_attach (required) |
iduint32_t * |
Receives the new prop's id (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_LIMIT, SONA_E_MEMORY (what each means).
Attaches m to the avatar (READY or not; a prop on an avatar that is not READY waits for it). *id (may be NULL) names it on this avatar from then on. The hand, when set, takes that hand's IK target (sona_avatar_ik_target) while the prop has it. NULL o: defaults. SONA_E_LIMIT past SONA_PROP_MAX; SONA_E_ARGUMENT for a bad size, flag, joint, hand, quaternion or scale, or a mesh of another ctx.
sona_avatar_prop_set¶
sona_result sona_avatar_prop_set(sona_avatar *a, uint32_t id,
const sona_prop_attach *o);
| Parameter and type | Meaning |
|---|---|
asona_avatar * |
The avatar (required) |
iduint32_t |
The id, as the call that made it gave it |
oconst sona_prop_attach * |
A sona_prop_attach (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_FOUND (what each means).
Example:
sona_prop_attach x_prop_attach;
sona_prop_attach_defaults(&x_prop_attach);
sona_result result = sona_avatar_prop_set(avatar, 0, &x_prop_attach);
if (result != SONA_OK) printf("sona_avatar_prop_set: %s\n",
sona_result_name(result));
New placement, flags or hand for an attached prop (each frame for one that moves on the joint).
sona_avatar_prop_swap¶
sona_result sona_avatar_prop_swap(sona_avatar *a, uint32_t id,
sona_prop_mesh *m);
| Parameter and type | Meaning |
|---|---|
asona_avatar * |
The avatar (required) |
iduint32_t |
The id, as the call that made it gave it |
msona_prop_mesh * |
The prop mesh (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_FOUND (what each means).
Another mesh in the same place: a sword for a stick, an item for a placeholder. The prop clock starts again.
sona_avatar_prop_get¶
sona_result sona_avatar_prop_get(const sona_avatar *a, uint32_t id,
sona_prop_attach *out,
sona_prop_mesh **mesh);
| Parameter and type | Meaning |
|---|---|
aconst sona_avatar * |
The avatar (required) |
iduint32_t |
The id, as the call that made it gave it |
outsona_prop_attach * |
Receives the sona_prop_attach (required) |
meshsona_prop_mesh ** |
Receives the new prop mesh (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_FOUND (what each means).
What the prop was attached with, and its mesh (either may be NULL). SONA_E_NOT_FOUND for an id it does not have.
sona_avatar_prop_detach¶
sona_result sona_avatar_prop_detach(sona_avatar *a, uint32_t id);
| Parameter and type | Meaning |
|---|---|
asona_avatar * |
The avatar (required) |
iduint32_t |
The id, as the call that made it gave it |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_FOUND (what each means).
Example:
sona_result result = sona_avatar_prop_detach(avatar, 0);
if (result != SONA_OK) printf("sona_avatar_prop_detach: %s\n",
sona_result_name(result));
Takes the prop off at once (its hand's IK target eases off). SONA_E_NOT_FOUND for an id it does not have.
sona_avatar_prop_detach_all¶
void sona_avatar_prop_detach_all(sona_avatar *a);
| Parameter and type | Meaning |
|---|---|
asona_avatar * |
The avatar (required) |
Returns Nothing.
Example:
sona_avatar_prop_detach_all(avatar);
Takes every prop off the avatar at once.
sona_avatar_prop_list¶
uint32_t sona_avatar_prop_list(const sona_avatar *a, uint32_t *ids,
uint32_t max);
| Parameter and type | Meaning |
|---|---|
aconst sona_avatar * |
The avatar (required) |
idsuint32_t * |
Receives the ids; may be NULL to count (NULL: not written) |
maxuint32_t |
How many entries out holds |
Returns uint32_t.
The ids of the avatar's props in attach order: writes up to max (ids may be NULL), returns how many it has.
sona_avatar_prop_frame¶
sona_result sona_avatar_prop_frame(const sona_avatar *a, uint32_t id,
sona_prop_frame *out);
| Parameter and type | Meaning |
|---|---|
aconst sona_avatar * |
The avatar (required) |
iduint32_t |
The id, as the call that made it gave it |
outsona_prop_frame * |
Receives the sona_prop_frame (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_READY, SONA_E_NOT_FOUND (what each means).
Example:
sona_prop_frame x_prop_frame;
memset(&x_prop_frame, 0, sizeof x_prop_frame);
x_prop_frame.size = sizeof x_prop_frame;
sona_result result = sona_avatar_prop_frame(avatar, 0, &x_prop_frame);
if (result != SONA_OK) printf("sona_avatar_prop_frame: %s\n",
sona_result_name(result));
Where an attached prop is this frame: the joint it is on, the time into its own clip, its frame in the world and in avatar space, how far the second hand is from its point on the prop (metres), and the palette of a skinned prop, valid until the next sona_update.
sona_avatar_prop_vertices¶
sona_result sona_avatar_prop_vertices(sona_avatar *a, uint32_t id,
uint32_t mesh, uint32_t space,
float *positions, float *normals,
size_t stride_floats);
| Parameter and type | Meaning |
|---|---|
asona_avatar * |
The avatar (required) |
iduint32_t |
The id, as the call that made it gave it |
meshuint32_t |
A mesh index of the pose data |
spaceuint32_t |
SONA_SPACE_*: the space the vertices come back in |
positionsfloat * |
Receives the positions (required) |
normalsfloat * |
Receives the normals, or NULL (NULL: not written) |
stride_floatssize_t |
Floats from one vertex to the next in the output |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_DESTROYED, SONA_E_NOT_READY, SONA_E_NOT_FOUND (what each means).
sona_pose_vertices for one of the prop's meshes (sona_prop_data.meshes): CPU skinning, SONA_SPACE_AVATAR or _WORLD. SONA_E_NOT_READY before it has been posed with a ready mesh.
sona_prop_pet_count¶
uint32_t sona_prop_pet_count(void);
Returns uint32_t.
Example:
uint32_t x_got = sona_prop_pet_count();
printf("sona_prop_pet_count: %lld\n", (long long)x_got);
How many of the catalogue's pets there are: stock prop items that are animals or creature companions, as the site's pet mode lists them, for sona_prop_mesh_stock.
sona_prop_pet¶
sona_result sona_prop_pet(uint32_t index, sona_guid *out);
| Parameter and type | Meaning |
|---|---|
indexuint32_t |
Which one, from 0 |
outsona_guid * |
Receives the sona_guid (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).
Example:
sona_guid x_guid;
memset(&x_guid, 0, sizeof x_guid);
sona_result result = sona_prop_pet(0, &x_guid);
if (result != SONA_OK) printf("sona_prop_pet: %s\n",
sona_result_name(result));
SONA_E_ARGUMENT past the last.
sona_prop_is_pet¶
int sona_prop_is_pet(const char *item_id);
| Parameter and type | Meaning |
|---|---|
item_idconst char * |
An item id as text (required) |
Returns int.
Example:
int x_got = sona_prop_is_pet("00400000-0003-0003-c1c8-f109a19cb2e0");
printf("sona_prop_is_pet: %lld\n", (long long)x_got);
1 when the item id is one of the pets.
This page as Markdown · All the docs as one file (llms-full.txt)