Bindings: C++¶
81 public names in bindings/cpp/sona.hpp.
Functions¶
| Declaration | What it does |
|---|---|
sona_result check_layout(std::string *what = 0) |
Compares the size of every public struct and the offset of every field with the library's; SONA_OK when they all match, else SONA_E_UNSUPPORTED with the first that differs named in *what. Calls sona_struct_size, sona_struct_offset. |
sona_result abi(sona_abi_info &out) |
The loaded library's ABI and version. Calls sona_abi_query. |
sona_result emote_from_text(const char *text, sona_emote &out) |
A sentence to stock clips, a speed and a face; the same text gives the same answer. Calls sona_emote_from_text. |
sona_route slot_of(const sona_guid &id, uint32_t *mask = 0) |
Where an item id goes; its slot mask in *mask when mask is given. Calls sona_slot_of. |
std::string format_guid(const sona_guid &g) |
The id in its lowercase 36-character form. Calls sona_guid_format. |
View<uint8_t> shader_source(sona_shader_lang lang, sona_program prog, int stage) |
Text, or SPIR-V bytes; empty when that language is not in this build. Calls sona_shader_source. |
void camera_orbit(sona_view &v, const double target[3], double yaw_deg, double pitch_deg, double distance) |
Places the eye on an orbit around target. Calls sona_camera_orbit. |
View<uint8_t> vertices(const sona_mesh &m) |
The 76-byte vertices and the indices of one mesh. |
View¶
class View: A read-only view over memory the core owns: valid as long as the call that gave it says.
| Declaration | What it does |
|---|---|
View()View(const T *p, size_t n) |
A read-only view over memory the core owns: valid as long as the call that gave it says. |
Error¶
class Error : public std::exception: What a call throws when it fails: code (a sona_result), message and fix, as sona_last_error gives them.
| Declaration | What it does |
|---|---|
Error(sona_result c, const std::string &m, const std::string &f) |
Makes the exception from a code, its message and its fix; its message reads "<code name>: <message> (<fix>)". Calls sona_result_name. |
~Error() throw() |
An empty destructor: an Error owns nothing of the library's. |
Manifest¶
class Manifest: An AvatarDescription and its edit verbs (pure; no ctx).
| Declaration | What it does |
|---|---|
sona_result parse(const uint8_t bytes[SONA_MANIFEST_BYTES], Manifest &out) |
Reads 1000 bytes into a sona_manifest. Calls sona_manifest_parse. |
sona_result parse_base64(const std::string &b64, Manifest &out) |
base64 text, as the web's add: at most 4096 characters. Calls sona_base64_decode. |
std::vector<uint8_t> bytes() const |
The manifest's SONA_MANIFEST_BYTES bytes, packed as the console stores them. |
sona_result wear(const sona_guid &item, const uint32_t colours[3], uint32_t flags = 0) |
Puts an item on, with its three colours. Calls sona_manifest_wear. |
Request¶
class Request: One read in flight.
| Declaration | What it does |
|---|---|
Request(sona_request *r = 0) |
One read in flight. |
Source¶
class Source: A host-written source.
| Declaration | What it does |
|---|---|
~Source() |
A source is ended through the context; destroying it frees the binding's side. |
void cancel(Request) |
Optional. The C field sona_source. |
sona_source c_source() |
The sona_source that calls this object's read and cancel: put it in a source description of kind SONA_SOURCE_CUSTOM. |
Config¶
class Config: sona_config with owned strings.
| Declaration | What it does |
|---|---|
Config() |
Sets abi and leaves everything else at its default. Calls sona_config_defaults. |
Config &licence(const void *bytes, size_t len) |
Sona-licence. |
bool licence_file(const std::string &path) |
false when the file could not be read. |
const sona_config *get() |
The sona_config, its pointers into this object. |
Pose¶
class Pose: A view over sona_pose_data: valid until the next Context::update.
| Declaration | What it does |
|---|---|
Pose()Pose(const sona_pose_data *p) |
A view over sona_pose_data: valid until the next Context:: |
Avatar¶
class Avatar: A handle to one avatar.
| Declaration | What it does |
|---|---|
Avatar()Avatar(sona_avatar *a, sona_ctx *ctx) |
A handle to one avatar. |
sona_result ragdoll_motors(std::vector<sona_ragdoll_motor> &out) const |
The joint motor targets of the last pose; SONA_E_NOT_READY before sona_avatar_ragdoll. Calls sona_avatar_ragdoll_motors. |
sona_result play(const char *clip, const sona_play_options *opts = 0) |
Plays a clip. Calls sona_avatar_play. |
void remove() |
Removes the avatar and frees what only it used. Calls sona_avatar_remove. |
sona_result pose(Pose &out) constPose pose() const |
The avatar's pose data, valid until the next sona_update. Calls sona_pose. |
sona_result pose_vertices(uint32_t mesh, uint32_t space, float *positions, float *normals = 0, size_t stride = 3) |
CPU skinning of one mesh; positions (and normals) hold vertex_count * stride floats. Calls sona_pose_vertices. |
sona_result camera_preset(sona_preset p, sona_view &view) const |
Sets view->eye and view->target to one of the console's framings on one ready avatar. Calls sona_camera_preset. |
sona_result set_override(uint32_t joint, const float rotation[4], float weight = 1, uint32_t mode = SONA_OVERRIDE_REPLACE) |
rotation (x, y, z, w) after the clip; weight 0 or a NULL rotation clears the joint. Calls sona_avatar_override. |
sona_result crossfade(const char *clip, float seconds, const sona_play_options *opts = 0) |
sona_avatar_play, blending from the current pose over seconds. Calls sona_avatar_crossfade. |
sona_result queue(const char *clip, float fade_seconds = 0, const sona_play_options *opts = 0) |
Plays clip when the current one ends; SONA_E_LIMIT past SONA_QUEUE_MAX. Calls sona_avatar_queue. |
sona_result expression_counts(uint32_t counts[3]) const |
counts0 mouth, 1 eyebrows, 2 eyes. Calls sona_avatar_expression_counts. |
std::vector<sona_clip_event> clip_events() |
Every waiting clip event, oldest first. Calls sona_avatar_clip_events. |
sona_result preview_view(uint32_t width, uint32_t height, sona_view &out) |
The framed camera for a width x height picture: the slot's view preset gives the angle, the item's box the target and the distance. Calls sona_item_preview_view. |
Context¶
class Context: Owns a sona_ctx; move-only.
| Declaration | What it does |
|---|---|
Context()Context(sona_ctx *adopt) |
Owns a sona_ctx; move-only. |
Context &operator=(Context &&o) noexcept |
Moves the handle from another object, which is left empty. |
sona_result open(Config &cfg, Context &out) |
Checks the struct layout first: a header that does not match the library gives SONA_E_UNSUPPORTED. Calls sona_open. |
void close() |
Closes a context. Calls sona_close. |
sona_result add(const uint8_t manifest[SONA_MANIFEST_BYTES], Avatar &out, const sona_add_options *opts = 0)Avatar add(const uint8_t manifest[SONA_MANIFEST_BYTES], const sona_add_options &opts = add_defaults())Avatar add(const Manifest &m, const sona_add_options &opts = add_defaults()) |
Queues an avatar and returns at once. Calls sona_avatar_add. |
sona_result add_base64(const char *b64, Avatar &out, const sona_add_options *opts = 0)Avatar add_base64(const std::string &b64, const sona_add_options &opts = add_defaults()) |
The same, from base64 text of at most 4096 characters, as the web. Calls sona_avatar_add_base64. |
sona_result item_colourways(const char *item_id, std::vector<std::array<uint32_t, 3> > &out) |
An item's colourways (0xFFRRGGBB); SONA_PENDING until it has loaded. Calls sona_item_colourways. |
sona_result custom_item_pack_mesh(const sona_mesh_item_spec &spec, std::vector<uint8_t> &out, std::string *why = 0) |
A.sonaitem (format 1.1) of your own skinned mesh; SONA_PENDING while the template loads; why gets the refusal. Calls sona_custom_item_pack_mesh, sona_free. |
sona_result award_unlock(const char *player_token, const char *key, uint32_t &ticket) |
player_token: the signed-in player's access token (Sign in with 360sona). Calls sona_award_unlock. |
sona_result update(double dt_seconds, const sona_view *view = 0, sona_frame_stats *out = 0) |
view may be NULL: nothing is culled and every avatar poses. Calls sona_update. |
bool poll(Event &out) |
True when an event was written to out, false when there are none; call it until it is false. Calls sona_poll_event. |
std::vector<sona_clip_info> clips() const |
One clip by index, 0.. Calls sona_clip_get. |
sona_scene_stats stats() const |
The scene statistics. Calls sona_stats. |
sona_result png_encode(const uint8_t *rgba, uint32_t w, uint32_t h, std::vector<uint8_t> &out) |
PNG bytes of an RGBA8 picture, with the web's three tEXt chunks after IHDR: Software "360sona", Source "https:/ Calls sona_png_encode, sona_free. |
sona_result add_item_preview(const char *item_id, Avatar &out, const sona_preview_options *opts = 0)Avatar add_item_preview(const std::string &item_id, const sona_preview_options &opts = preview_defaults()) |
One item worn alone on a stand-in body; it reaches READY like an avatar and Avatar::remove frees it. Calls sona_item_preview_add. |
sona_lod_stats lod_stats() const |
The level-of-detail statistics: avatars in view at each step, those fading, the baked looks and the bakes of the last draw. Calls sona_lod_stats_get. |
Renderer¶
class Renderer: Owns a sona_renderer; move-only.
| Declaration | What it does |
|---|---|
Renderer() |
Owns a sona_renderer; move-only. |
Renderer &operator=(Renderer &&o) noexcept |
Moves the handle from another object, which is left empty. |
sona_result create(Context &ctx, const sona_device_desc &dev, Renderer &out) |
SONA_PENDING until the shading data has arrived through Context:: Calls sona_renderer_create. |
void destroy() |
Frees the renderer and its GPU objects. Calls sona_renderer_destroy. |
sona_result draw(const sona_view &view, const sona_target &target, const sona_draw_options *opts = 0) |
Draws every visible ready avatar, as posed by the last sona_update, folding each palette with this view. Calls sona_draw. |
sona_result snapshot(const sona_view &view, uint32_t w, uint32_t h, std::vector<uint8_t> &rgba, const sona_draw_options *opts = 0) |
Straight RGBA8, row 0 at the top. Calls sona_snapshot. |
sona_result preview_draw(const Avatar &preview, const sona_target &target, const sona_view *view = 0, const sona_draw_options *opts = 0) |
Only this preview in the frame. Calls sona_item_preview_draw. |
sona_result preview_snapshot(const Avatar &preview, uint32_t w, uint32_t h, std::vector<uint8_t> &rgba, const sona_draw_options *opts = 0) |
sona_snapshot of this preview alone, framed for width x height. Calls sona_item_preview_snapshot. |
Catalogue¶
class Catalogue: Every item id with its name, slots, game and source, from sona-catalogue.bin, so pickers need no web call. The C type sona_catalogue.
| Declaration | What it does |
|---|---|
Catalogue() |
Every item id with its name, slots, game and source, from sona-catalogue. |
Catalogue &operator=(Catalogue &&o) noexcept |
Moves the handle from another object, which is left empty. |
sona_result load(const std::string &path, Catalogue &out, const Context *ctx = 0) |
ctx may be NULL (then malloc, and no message beyond the code). Calls sona_catalogue_load. |
sona_result load_memory(const void *bytes, size_t len, Catalogue &out, const Context *ctx = 0) |
The same from bytes in memory. Calls sona_catalogue_load_memory. |
void free() |
Frees it and every string it handed out. Calls sona_catalogue_free. |
sona_result search(const sona_catalogue_query *q, std::vector<uint32_t> &out, uint32_t max, uint32_t *total = 0) const |
Up to max matching indexes in id order, after q->offset; total (may be NULL) is every match. Calls sona_catalogue_search. |
sona_result game(uint32_t index, const char *&name, uint32_t &items) const |
One game, sorted by name, and its item count. Calls sona_catalogue_game. |
sona_result item_name(uint32_t index, const char *lang, const char *&name) const |
SONA_E_NOT_FOUND when the item has no name in lang (show sona_item_info. Calls sona_catalogue_item_name. |
Types¶
| Declaration | What it does |
|---|---|
class Event |
The C type sona_event. |
This page as Markdown · All the docs as one file (llms-full.txt)