lv_gltf_model.h

Functions

lv_gltf_model_t *lv_gltf_data_load_from_file(const char *file_path, lv_gltf_model_loader_t *loader)

Load a glTF model from a file

Note

If loader is NULL, an internal loader will be created and managed automatically

Parameters:
  • file_path – path to the glTF file to load

  • loader – pointer to the glTF model loader instance, or NULL to create a new one

Returns:

pointer to the loaded glTF model, or NULL on failure

lv_gltf_model_t *lv_gltf_data_load_from_bytes(const uint8_t *data, size_t data_size, lv_gltf_model_loader_t *loader)

Load a glTF model from a byte array

Note

If loader is NULL, an internal loader will be created and managed automatically

Parameters:
  • data – pointer to the glTF data buffer

  • data_size – size of the data buffer in bytes

  • loader – pointer to the glTF model loader instance, or NULL to create a new one

Returns:

pointer to the loaded glTF model, or NULL on failure

void lv_gltf_model_delete(lv_gltf_model_t *model)

Delete a glTF model

Parameters:

model – the gltf model to delete

size_t lv_gltf_model_get_image_count(const lv_gltf_model_t *model)

Get the number of images in the glTF model.

Images in glTF are used as sources for textures and can be stored either as external files or embedded as base64-encoded model within the glTF file.

Parameters:

model – Pointer to the glTF model data structure

Returns:

Number of images in the model

size_t lv_gltf_model_get_texture_count(const lv_gltf_model_t *model)

Get the number of textures in the glTF model.

Textures define how images are sampled and applied to materials. Each texture references an image and may specify sampling parameters like filtering and wrapping modes.

Parameters:

model – Pointer to the glTF model data structure

Returns:

Number of textures in the model

size_t lv_gltf_model_get_material_count(const lv_gltf_model_t *model)

Get the number of materials in the glTF model.

Materials define the visual appearance of mesh primitives, including properties like base color, metallic/roughness values, normal maps, and other surface characteristics.

Parameters:

model – Pointer to the glTF model data structure

Returns:

Number of materials in the model

size_t lv_gltf_model_get_camera_count(const lv_gltf_model_t *model)

Get the number of cameras in the glTF model.

Cameras define viewpoints within the 3D scene and can be either perspective or orthographic. They are typically attached to nodes in the scene graph.

Parameters:

model – Pointer to the glTF model data structure

Returns:

Number of cameras in the model

size_t lv_gltf_model_get_mesh_count(const lv_gltf_model_t *model)

Get the number of meshes in the glTF model.

Meshes contain the geometric model for 3D objects, including vertex positions, normals, texture coordinates, and indices. Each mesh can have multiple primitives with different materials.

Parameters:

model – Pointer to the glTF model data structure

Returns:

Number of meshes in the model

size_t lv_gltf_model_get_scene_count(const lv_gltf_model_t *model)

Get the number of scenes in the glTF model.

Scenes define the root nodes of the scene graph. A glTF file can contain multiple scenes, though typically only one is designated as the default scene to be displayed.

Parameters:

model – Pointer to the glTF model data structure

Returns:

Number of scenes in the model

size_t lv_gltf_model_get_animation_count(const lv_gltf_model_t *model)

Get the number of animations in the glTF model.

Animations define keyframe-based motion for nodes in the scene, including transformations like translation, rotation, and scaling over time.

Parameters:

model – Pointer to the glTF model data structure

Returns:

Number of animations in the model

lv_result_t lv_gltf_model_play_animation(lv_gltf_model_t *model, size_t index)

Select and start playing an animation.

Parameters:
  • model – Pointer to the glTF model structure

  • index – Animation number to start playing

Returns:

LV_RESULT_OK if the animation was started else LV_RESULT_INVALID

void lv_gltf_model_pause_animation(lv_gltf_model_t *model)

Pause the current animation.

Parameters:

model – Pointer to the glTF model structure

bool lv_gltf_model_is_animation_paused(lv_gltf_model_t *model)

Check if an animation is currently being played.

Parameters:

model – Pointer to the glTF model structure

size_t lv_gltf_model_get_animation(lv_gltf_model_t *model)

Get the current selected animation. To see if it's playing see lv_gltf_model_is_animation_paused

Parameters:

model – Pointer to the glTF model structure

void lv_gltf_model_set_animation_speed(lv_gltf_model_t *model, uint32_t value)

Set the animation speed ratio

The actual ratio is the value parameter / LV_GLTF_ANIM_SPEED_NORMAL Values greater than LV_GLTF_ANIM_SPEED_NORMAL will speed-up the animation Values less than LV_GLTF_ANIM_SPEED_NORMAL will slow down the animation

Parameters:
  • model – pointer to a glTF model

  • value – speed-up ratio of the animation

uint32_t lv_gltf_model_get_animation_speed(const lv_gltf_model_t *model)

Get the animation speed ratio

The actual ratio is the return value / LV_GLTF_ANIM_SPEED_NORMAL

Parameters:

model – pointer to a glTF model