LDK_KEYFRAME_PROPERTY_NAME_CAPACITY
#define LDK_KEYFRAME_PROPERTY_NAME_CAPACITY 96
Code-authored keyframe clips, relative target bindings, and TML I/O.
#define LDK_KEYFRAME_PROPERTY_NAME_CAPACITY 96
typedef struct LDKKeyframe{
float time;
LDKPropertyValue value;
}LDKKeyframe;
typedef struct LDKKeyframeTrack{
u64 target_path;
u32 component_type;
char property_name[LDK_KEYFRAME_PROPERTY_NAME_CAPACITY];
LDKFieldType value_type;
LDKKeyframe *keys;
u32 count;
u32 capacity;
}LDKKeyframeTrack;
typedef enum LDKKeyframeEventValueType{
LDK_KEYFRAME_EVENT_INTEGER=0,
LDK_KEYFRAME_EVENT_STRING
}LDKKeyframeEventValueType;
typedef struct LDKKeyframeEvent{
float time;
LDKKeyframeEventValueType type;
i32 number;
char *text;
}LDKKeyframeEvent;
typedef struct LDKKeyframeAnimation{
float duration;
LDKKeyframeTrack *tracks;
u32 track_count;
u32 track_capacity;
LDKKeyframeEvent *events;
u32 event_count;
u32 event_capacity;
}LDKKeyframeAnimation;
Called synchronously for an animation marker.
typedef void(*LDKKeyframeEventFn)(LDKEntity root, const LDKKeyframeEvent *event, void *user);
rooteventuserReturn the reserved path hash of an animation source root.
LDK_API u64 ldk_keyframe_path_root(void);
Stable root hash used for relative track bindings.
Extend a relative hierarchy path with a child name hash.
LDK_API u64 ldk_keyframe_path_child(
u64 parent_path,
u64 name_hash
);
u64 parent_pathu64 name_hashDeterministic path hash, or zero for invalid inputs.
Compute the path of a descendant relative to an animation root.
LDK_API bool ldk_keyframe_entity_path(
LDKEntity root,
LDKEntity target,
u64 *out_path
);
True if target belongs to the transform subtree rooted at root.
Resolve a relative path hash to exactly one descendant.
LDK_API bool ldk_keyframe_target_resolve(
LDKEntity root,
u64 path,
LDKEntity *out
);
True if the path resolves unambiguously. Duplicate matching paths fail.
Initialize a clip to an empty, one-second animation.
LDK_API void ldk_keyframe_animation_init(LDKKeyframeAnimation *clip);
LDKKeyframeAnimation *clipNothing. Call before any other clip operation.
Free a clip and reset it to the initialized state.
LDK_API void ldk_keyframe_animation_clear(LDKKeyframeAnimation *clip);
LDKKeyframeAnimation *clipNothing. Invalidates pointers into tracks, keys, and events.
Validate a clip independently of the ECS and reflected metadata.
LDK_API bool ldk_keyframe_animation_validate(const LDKKeyframeAnimation *clip);
const LDKKeyframeAnimation *clipTrue if the duration, tracks, keys and events are structurally valid.
Deep-copy all tracks, keys, events and owned event strings.
LDK_API bool ldk_keyframe_animation_copy(
LDKKeyframeAnimation *destination,
const LDKKeyframeAnimation *source
);
LDKKeyframeAnimation *destinationconst LDKKeyframeAnimation *sourceTrue on success; otherwise destination remains unchanged.
Set duration without discarding keys or events.
LDK_API bool ldk_keyframe_animation_duration_set(
LDKKeyframeAnimation *clip,
float duration
);
LDKKeyframeAnimation *clipfloat durationFalse if invalid or any key/event would lie beyond duration.
Find a track identified by relative path and reflected field.
LDK_API i32 ldk_keyframe_animation_track_find(
const LDKKeyframeAnimation *clip,
u64 path,
u32 component_type,
const char *property_name
);
const LDKKeyframeAnimation *clipu64 pathu32 component_typeconst char *property_nameZero-based track index, or -1 if not found.
Create a track for an editable reflected component field.
LDK_API i32 ldk_keyframe_animation_track_add(
LDKKeyframeAnimation *clip,
u64 path,
u32 component_type,
const char *property_name
);
LDKKeyframeAnimation *clipu64 pathu32 component_typeconst char *property_nameTrack index; existing track is reused, -1 if unavailable or unsupported. Note: Reflected component metadata must be registered when authoring.
Remove a track and all of its keyframes.
LDK_API bool ldk_keyframe_animation_track_remove(
LDKKeyframeAnimation *clip,
u32 track
);
LDKKeyframeAnimation *clipu32 trackTrue if the track existed. Later track indices shift.
Insert or update a typed keyframe at the specified second.
LDK_API bool ldk_keyframe_animation_key_set(
LDKKeyframeAnimation *clip,
u32 track,
float time,
LDKPropertyValue value
);
LDKKeyframeAnimation *clipu32 trackfloat timeLDKPropertyValue valueTrue on success; may extend clip duration. Requires available component metadata. Note: Reflected component metadata must be registered when authoring.
Remove a keyframe from a track.
LDK_API bool ldk_keyframe_animation_key_remove(
LDKKeyframeAnimation *clip,
u32 track,
u32 key
);
LDKKeyframeAnimation *clipu32 tracku32 keyTrue if removed. Subsequent key indices shift.
Move a keyframe in time while keeping its value and chronological order.
LDK_API bool ldk_keyframe_animation_key_move(
LDKKeyframeAnimation *clip,
u32 track,
u32 key,
float new_time,
u32 *out_index
);
LDKKeyframeAnimation *clipu32 tracku32 keyfloat new_timeu32 *out_indexTrue on success. Rejects collisions and times beyond duration.
Evaluate a single track at the requested time without changing entities.
LDK_API bool ldk_keyframe_animation_sample(
const LDKKeyframeAnimation *clip,
u32 track,
float time,
LDKPropertyValue *out_value
);
const LDKKeyframeAnimation *clipu32 trackfloat timeLDKPropertyValue *out_valueTrue if the track has keys and its values can be evaluated.
Sample and write all nonempty tracks to the subtree of a root entity.
LDK_API bool ldk_keyframe_animation_apply(
const LDKKeyframeAnimation *clip,
LDKEntity root,
float time
);
const LDKKeyframeAnimation *clipLDKEntity rootfloat timeTrue if all tracks applied successfully; missing bindings are reported by false.
Read the current component value addressed by a track.
LDK_API bool ldk_keyframe_animation_value_from_entity(
LDKEntity entity,
const LDKKeyframeTrack *track,
LDKPropertyValue *out_value
);
LDKEntity entityconst LDKKeyframeTrack *trackLDKPropertyValue *out_valueTrue if the editable reflected field exists and can be read.
Insert an integer event marker at the specified second.
LDK_API bool ldk_keyframe_animation_event_add_integer(
LDKKeyframeAnimation *clip,
float time,
i32 number
);
LDKKeyframeAnimation *clipfloat timei32 numberTrue on success; extends duration if needed.
Insert a string event marker, copying the supplied text.
LDK_API bool ldk_keyframe_animation_event_add_string(
LDKKeyframeAnimation *clip,
float time,
const char *text
);
LDKKeyframeAnimation *clipfloat timeconst char *textTrue on success; extends duration if needed.
Delete an event marker and its owned string.
LDK_API bool ldk_keyframe_animation_event_remove(
LDKKeyframeAnimation *clip,
u32 event_index
);
LDKKeyframeAnimation *clipu32 event_indexTrue if removed. Later event indices shift.
Change an event timestamp while preserving event ordering.
LDK_API bool ldk_keyframe_animation_event_move(
LDKKeyframeAnimation *clip,
u32 event_index,
float new_time,
u32 *out_index
);
LDKKeyframeAnimation *clipu32 event_indexfloat new_timeu32 *out_indexTrue on success; times beyond duration are rejected.
Replace an event payload with an integer.
LDK_API bool ldk_keyframe_animation_event_set_integer(
LDKKeyframeAnimation *clip,
u32 event_index,
i32 number
);
LDKKeyframeAnimation *clipu32 event_indexi32 numberTrue if the event existed.
Replace an event payload with a copied string.
LDK_API bool ldk_keyframe_animation_event_set_string(
LDKKeyframeAnimation *clip,
u32 event_index,
const char *text
);
LDKKeyframeAnimation *clipu32 event_indexconst char *textTrue on success; the old payload remains if allocation fails.
Synchronously deliver all events crossed in (previous_time, current_time].
LDK_API void ldk_keyframe_animation_events_dispatch(
const LDKKeyframeAnimation *clip,
LDKEntity root,
float previous_time,
float current_time,
LDKKeyframeEventFn fn,
void *user
);
const LDKKeyframeAnimation *clipLDKEntity rootfloat previous_timefloat current_timeLDKKeyframeEventFn fnvoid *userNothing. Event payloads are temporary snapshots valid during each callback. Note: Callbacks may mutate or destroy the source; do not keep event pointers.
Parse a version-2 TML animation into an initialized clip.
LDK_API bool ldk_keyframe_animation_from_tml(
LDKKeyframeAnimation *clip,
const char *source
);
LDKKeyframeAnimation *clipconst char *sourceTrue on success; clip remains unchanged on failure.
Serialize a structurally valid clip to TML version 2.
LDK_API bool ldk_keyframe_animation_to_tml(
const LDKKeyframeAnimation *clip,
char **out_source
);
const LDKKeyframeAnimation *clipchar **out_sourceTrue on success. Caller must free *out_source.
Load a clip from the configured asset source.
LDK_API bool ldk_keyframe_animation_load(
LDKKeyframeAnimation *clip,
const char *asset_path
);
LDKKeyframeAnimation *clipconst char *asset_pathTrue on success; existing clip remains unchanged on failure.
Save a clip as TML through the configured asset source.
LDK_API bool ldk_keyframe_animation_save(
const LDKKeyframeAnimation *clip,
const char *asset_path
);
const LDKKeyframeAnimation *clipconst char *asset_pathTrue if successfully serialized and written.