RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
mesh.h File Reference

Caller-owned GLB scenes, shareable geometry and caller-owned poses. More...

#include <stddef.h>
#include <stdint.h>
#include "fb.h"

Data Structures

struct  rmgui_mesh_limits_t
 Optional hostile-input budgets. More...
struct  rmgui_mesh_vertex_t
 Renderer-independent vertex: local position, normal and atlas UV. More...
struct  rmgui_mesh_primitive_t
 Triangle-list range; indices are absolute offsets into model.vertices. More...
struct  rmgui_mesh_material_t
 Linear RGBA factor; blend selects straight-alpha blending, textured selects the model's sole nearest-sampled PNG atlas. More...
struct  rmgui_mesh_node_t
 Local TRS, normalized XYZW quaternion and int parent/mesh indices (-1 for none). More...
struct  rmgui_mesh_channel_t
 Strictly increasing finite seconds; STEP when step is nonzero, otherwise linear vectors/shortest-path normalized slerp. More...
struct  rmgui_mesh_clip_t
 One glTF animation in file order. More...
struct  rmgui_mesh_model_t
 Immutable after loading. More...
struct  rmgui_mesh_instance_t
 Mutable pose borrowing a live immutable model. More...

Enumerations

enum  rmgui_mesh_result_t {
  RMGUI_MESH_OK = 0 , RMGUI_MESH_INVALID = -1 , RMGUI_MESH_UNSUPPORTED = -2 , RMGUI_MESH_LIMIT = -3 ,
  RMGUI_MESH_ARGUMENT = -4 , RMGUI_MESH_STORAGE = -5 , RMGUI_MESH_MEMORY = -6
}
 Stable results: success, malformed bytes, unsupported glTF feature, exceeded budget, invalid caller argument, insufficient storage, allocation failure. More...
enum  rmgui_mesh_path_t { RMGUI_MESH_TRANSLATION , RMGUI_MESH_ROTATION , RMGUI_MESH_SCALE }
 Animation path values for translation, XYZW rotation and scale. More...
enum  { RMGUI_MESH_REST = -2 }
 Explicit selector for the authored node transforms, not the first pose of any clip. More...

Functions

rmgui_mesh_result_t rmgui_mesh_measure (const uint8_t *bytes, size_t length, const rmgui_mesh_limits_t *limits, size_t *model_bytes)
 Validate and report complete caller model buffer bytes.
rmgui_mesh_result_t rmgui_mesh_load (rmgui_mesh_model_t *out, size_t storage_size, const uint8_t *bytes, size_t length, const rmgui_mesh_limits_t *limits)
 Decode into caller-owned max_align_t-aligned storage including the header.
void rmgui_mesh_release (rmgui_mesh_model_t *model)
 Release the atlas and zero a loaded or zero-initialized model.
size_t rmgui_mesh_instance_size (const rmgui_mesh_model_t *model)
 Return complete aligned instance buffer bytes, or zero on overflow/NULL.
rmgui_mesh_result_t rmgui_mesh_instance_init (rmgui_mesh_instance_t *out, size_t storage_size, const rmgui_mesh_model_t *model)
 Initialize a caller-owned max_align_t-aligned instance buffer at rest.
int rmgui_mesh_node_find (const rmgui_mesh_model_t *model, const char *name)
 Find an exact node name, or return -1 for no match/NULL inputs.
int rmgui_mesh_clip_find (const rmgui_mesh_model_t *model, const char *name)
 Return the ID of a unique exact, case-sensitive C-string match.
rmgui_mesh_result_t rmgui_mesh_sample_clip (rmgui_mesh_instance_t *instance, int clip, float seconds, int loop)
 Evaluate the selected clip from the authored rest TRS without resetting visibility or UVs.
rmgui_mesh_result_t rmgui_mesh_visible (rmgui_mesh_instance_t *instance, int node, int visible)
 Override one node's visibility; hidden parents hide descendants at paint.
rmgui_mesh_result_t rmgui_mesh_badge (rmgui_mesh_instance_t *instance, int count)
 Clamp count to 0..99; zero hides NotificationBadge, one digit hides tens.

Detailed Description

Caller-owned GLB scenes, shareable geometry and caller-owned poses.

Enumeration Type Documentation

◆ rmgui_mesh_result_t

Stable results: success, malformed bytes, unsupported glTF feature, exceeded budget, invalid caller argument, insufficient storage, allocation failure.

Every failure leaves published records and destination pixels intact; caller scratch contents are unspecified.

Enumerator
RMGUI_MESH_OK 

Operation completed.

RMGUI_MESH_INVALID 

Malformed GLB/JSON/data, or an unrenderable pose.

RMGUI_MESH_UNSUPPORTED 

Valid syntax using a feature outside the supported glTF subset.

RMGUI_MESH_LIMIT 

A documented byte, geometry, tree or animation budget was exceeded.

RMGUI_MESH_ARGUMENT 

NULL, nonfinite or otherwise invalid caller argument.

RMGUI_MESH_STORAGE 

Caller-provided record or scratch storage is too small.

RMGUI_MESH_MEMORY 

A temporary loader allocation failed; PNG decode refusal is INVALID.

◆ rmgui_mesh_path_t

Animation path values for translation, XYZW rotation and scale.

Enumerator
RMGUI_MESH_TRANSLATION 

Three-component local translation.

RMGUI_MESH_ROTATION 

Four-component normalized XYZW local quaternion.

RMGUI_MESH_SCALE 

Three-component local axis scale.

◆ anonymous enum

anonymous enum

Explicit selector for the authored node transforms, not the first pose of any clip.

Distinct from the -1 returned by a failed name lookup.

Enumerator
RMGUI_MESH_REST 

Function Documentation

◆ rmgui_mesh_measure()

rmgui_mesh_result_t rmgui_mesh_measure ( const uint8_t * bytes,
size_t length,
const rmgui_mesh_limits_t * limits,
size_t * model_bytes )

Validate and report complete caller model buffer bytes.

NULL limits selects representation ceilings; nonzero budgets refuse with LIMIT. Temporary heap allocations are released. Output is unchanged on failure.

◆ rmgui_mesh_load()

rmgui_mesh_result_t rmgui_mesh_load ( rmgui_mesh_model_t * out,
size_t storage_size,
const uint8_t * bytes,
size_t length,
const rmgui_mesh_limits_t * limits )

Decode into caller-owned max_align_t-aligned storage including the header.

Pass the measured size as storage_size. Temporary heap storage and PNG decoding allocate; atlas pixels are the sole retained allocation. Refusal preserves the entire caller buffer. NULL limits means type ceilings. One default scene, triangle lists, f32 attributes/u16 indices, TRS, any number of supported LINEAR/STEP clips, and one embedded PNG are supported. Clips can target translation, rotation, or scale. Two channels in one clip cannot target the same node/path; different clips can. Unsupported interpolation, morph weights and other unsupported paths refuse the load. Textures require explicit CLAMP_TO_EDGE wrapping and nearest filtering; NEAREST_MIPMAP_NEAREST deliberately samples base-level NEAREST (no mipmaps), and omitted filter modes select nearest. Skins, sparse data, external URIs, required extensions and other sampler modes are refused. Named BadgeDigitOnes/Tens meshes must be unshared, with U in [0,1] confined to one atlas cell per primitive; unsupported badge layouts are refused. Embedded PNG decoding inherits image.h's trusted-compressed-stream contract; the loader additionally applies the caller's PNG budgets.

◆ rmgui_mesh_release()

void rmgui_mesh_release ( rmgui_mesh_model_t * model)

Release the atlas and zero a loaded or zero-initialized model.

NULL is safe.

◆ rmgui_mesh_instance_size()

size_t rmgui_mesh_instance_size ( const rmgui_mesh_model_t * model)

Return complete aligned instance buffer bytes, or zero on overflow/NULL.

◆ rmgui_mesh_instance_init()

rmgui_mesh_result_t rmgui_mesh_instance_init ( rmgui_mesh_instance_t * out,
size_t storage_size,
const rmgui_mesh_model_t * model )

Initialize a caller-owned max_align_t-aligned instance buffer at rest.

The model must be loader-validated and immutable. No allocation. Failure preserves the header and published pose; scratch storage is unspecified. The loaded instance cannot be relocated by copying its header.

◆ rmgui_mesh_node_find()

int rmgui_mesh_node_find ( const rmgui_mesh_model_t * model,
const char * name )

Find an exact node name, or return -1 for no match/NULL inputs.

◆ rmgui_mesh_clip_find()

int rmgui_mesh_clip_find ( const rmgui_mesh_model_t * model,
const char * name )

Return the ID of a unique exact, case-sensitive C-string match.

Return -1 for no match, duplicate matches or NULL arguments.

◆ rmgui_mesh_sample_clip()

rmgui_mesh_result_t rmgui_mesh_sample_clip ( rmgui_mesh_instance_t * instance,
int clip,
float seconds,
int loop )

Evaluate the selected clip from the authored rest TRS without resetting visibility or UVs.

Pass RMGUI_MESH_REST to restore those transforms without evaluating a clip. Finite time in seconds clamps to [0, duration] or wraps if loop != 0. A loop seam maps exactly to the clip's first pose. Rotation components within 1e-6 of zero snap to zero before normalization, making full-turn endpoints exact. A zero-duration clip evaluates its keyed pose at every time. Nonfinite time or an invalid clip ID returns RMGUI_MESH_ARGUMENT. No allocation; failure leaves the published pose unchanged, with scratch contents unspecified.

◆ rmgui_mesh_visible()

rmgui_mesh_result_t rmgui_mesh_visible ( rmgui_mesh_instance_t * instance,
int node,
int visible )

Override one node's visibility; hidden parents hide descendants at paint.

Refuses an invalid node without changing the instance.

◆ rmgui_mesh_badge()

rmgui_mesh_result_t rmgui_mesh_badge ( rmgui_mesh_instance_t * instance,
int count )

Clamp count to 0..99; zero hides NotificationBadge, one digit hides tens.

Set private digit U=(digit+local_u)/10 preserving V and immutable model UVs. Refuses a model lacking the three named badge nodes without mutation.