lv_gltf.h

Defines

LV_GLTF_ANIM_SPEED_TENTH
LV_GLTF_ANIM_SPEED_QUARTER
LV_GLTF_ANIM_SPEED_HALF
LV_GLTF_ANIM_SPEED_NORMAL
LV_GLTF_ANIM_SPEED_2X
LV_GLTF_ANIM_SPEED_3X
LV_GLTF_ANIM_SPEED_4X

Enums

enum lv_gltf_aa_mode_t

Values:

enumerator LV_GLTF_AA_MODE_OFF
enumerator LV_GLTF_AA_MODE_ON

Anti aliasing off

enumerator LV_GLTF_AA_MODE_DYNAMIC

Anti aliasing on

enum lv_gltf_bg_mode_t

Values:

enumerator LV_GLTF_BG_MODE_SOLID
enumerator LV_GLTF_BG_MODE_ENVIRONMENT

Solid background. Use lv_obj_set_style_bg_color to set the background color

Functions

lv_obj_t *lv_gltf_create(lv_obj_t *parent)

Create a GLTF viewer object

Parameters:

parent – pointer to the parent object

Returns:

pointer to the created GLTF viewer object

lv_gltf_model_t *lv_gltf_load_model_from_file(lv_obj_t *obj, const char *path)

Load a GLTF model from a file into the viewer

Parameters:
  • obj – pointer to a GLTF viewer object

  • path – file path to the GLTF model to load

Returns:

pointer to the loaded GLTF model, or NULL on failure

size_t lv_gltf_get_model_count(lv_obj_t *obj)

Get the number of models loaded in the GLTF viewer

Parameters:

obj – pointer to a GLTF viewer object

Returns:

the total number of models in the viewer

lv_gltf_model_t *lv_gltf_get_model_by_index(lv_obj_t *obj, size_t id)

Get a specific model by its index

Parameters:
  • obj – pointer to a GLTF viewer object

  • id – index of the model to retrieve (0-based)

Returns:

pointer to the model at the specified index, or NULL if index is invalid

lv_gltf_model_t *lv_gltf_get_primary_model(lv_obj_t *obj)

Get the primary model from the GLTF viewer The primary model is the first model added to the viewer and can be used for camera selection and other primary operations

Parameters:

obj – pointer to a GLTF viewer object

Returns:

pointer to the primary model, or NULL if no models are loaded

void lv_gltf_set_yaw(lv_obj_t *obj, float yaw)

Set the yaw (horizontal rotation) of the camera

Parameters:
  • obj – pointer to a GLTF viewer object

  • yaw – yaw angle in degrees

float lv_gltf_get_yaw(const lv_obj_t *obj)

Get the yaw (horizontal rotation) of the camera

Parameters:

obj – pointer to a GLTF viewer object

Returns:

yaw angle in degrees

void lv_gltf_set_pitch(lv_obj_t *obj, float pitch)

Set the pitch (vertical rotation) of the camera

Parameters:
  • obj – pointer to a GLTF viewer object

  • pitch – pitch angle in degrees

float lv_gltf_get_pitch(const lv_obj_t *obj)

Get the pitch (vertical rotation) of the camera

Parameters:

obj – pointer to a GLTF viewer object

Returns:

pitch angle in degrees

void lv_gltf_set_distance(lv_obj_t *obj, float value)

Set the camera distance from the focal point

Parameters:
  • obj – pointer to a GLTF viewer object

  • value – distance value

float lv_gltf_get_distance(const lv_obj_t *obj)

Get the camera distance from the focal point

Parameters:

obj – pointer to a GLTF viewer object

Returns:

distance value

void lv_gltf_set_fov(lv_obj_t *obj, float value)

Set the field of view

Parameters:
  • obj – pointer to a GLTF viewer object

  • value – vertical FOV in degrees. If zero, the view will be orthographic (non-perspective)

float lv_gltf_get_fov(const lv_obj_t *obj)

Get the field of view

Parameters:

obj – pointer to a GLTF viewer object

Returns:

vertical FOV in degrees

void lv_gltf_set_focal_x(lv_obj_t *obj, float value)

Set the X coordinate of the camera focal point

Parameters:
  • obj – pointer to a GLTF viewer object

  • value – X coordinate

float lv_gltf_get_focal_x(const lv_obj_t *obj)

Get the X coordinate of the camera focal point

Parameters:

obj – pointer to a GLTF viewer object

Returns:

X coordinate

void lv_gltf_set_focal_y(lv_obj_t *obj, float value)

Set the Y coordinate of the camera focal point

Parameters:
  • obj – pointer to a GLTF viewer object

  • value – Y coordinate

float lv_gltf_get_focal_y(const lv_obj_t *obj)

Get the Y coordinate of the camera focal point

Parameters:

obj – pointer to a GLTF viewer object

Returns:

Y coordinate

void lv_gltf_set_focal_z(lv_obj_t *obj, float value)

Set the Z coordinate of the camera focal point

Parameters:
  • obj – pointer to a GLTF viewer object

  • value – Z coordinate

float lv_gltf_get_focal_z(const lv_obj_t *obj)

Get the Z coordinate of the camera focal point

Parameters:

obj – pointer to a GLTF viewer object

Returns:

Z coordinate

void lv_gltf_recenter(lv_obj_t *obj, lv_gltf_model_t *model)

Set the focal coordinates to the center point of the model object

Parameters:
  • obj – pointer to a GLTF viewer object

  • model – a model attached to this viewer or NULL for the first model

void lv_gltf_set_camera(lv_obj_t *obj, uint32_t value)

Set the active camera index The camera is selected from the first GLTF model added to the viewer

Note

Values higher than the scene's camera count will be clamped to the maximum available camera index

Parameters:
  • obj – pointer to a GLTF viewer object

  • value – camera index (0 for default camera, 1+ for scene camera index)

uint32_t lv_gltf_get_camera(const lv_obj_t *obj)

Get the active camera index

Parameters:

obj – pointer to a GLTF viewer object

Returns:

active camera index

uint32_t lv_gltf_get_camera_count(const lv_obj_t *obj)

Get the number of cameras in the first GLTF model added to the viewer This count represents the valid range for the camera index parameter used with lv_gltf_set_camera()

To get the camera count of other models, call lv_gltf_model_get_camera_count(model) directly with the specific model

Parameters:

obj – pointer to a GLTF viewer object

Returns:

number of available cameras

void lv_gltf_set_animation_speed(lv_obj_t *obj, 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:
  • obj – pointer to a GLTF viewer object

  • value – speed-up ratio of the animation

uint32_t lv_gltf_get_animation_speed(const lv_obj_t *obj)

Get the animation speed ratio

The actual ratio is the return value / LV_GLTF_ANIM_SPEED_NORMAL

Parameters:

obj – pointer to a GLTF viewer object

void lv_gltf_set_background_mode(lv_obj_t *obj, lv_gltf_bg_mode_t value)

Set the background mode

Parameters:
  • obj – pointer to a GLTF viewer object

  • value – background mode

lv_gltf_bg_mode_t lv_gltf_get_background_mode(const lv_obj_t *obj)

Get the background mode

Parameters:

obj – pointer to a GLTF viewer object

Returns:

background mode

void lv_gltf_set_background_blur(lv_obj_t *obj, uint32_t value)

Set the background blur amount

Parameters:
  • obj – pointer to a GLTF viewer object

  • value – blur amount between 0 and 100

uint32_t lv_gltf_get_background_blur(const lv_obj_t *obj)

Get the background blur amount

Parameters:

obj – pointer to a GLTF viewer object

Returns:

blur amount between 0 and 100

void lv_gltf_set_env_brightness(lv_obj_t *obj, uint32_t value)

Set the environmental brightness/power

Parameters:
  • obj – pointer to a GLTF viewer object

  • value – brightness multiplier

uint32_t lv_gltf_get_env_brightness(const lv_obj_t *obj)

Get the environmental brightness/power

Parameters:

obj – pointer to a GLTF viewer object

Returns:

brightness multiplier

void lv_gltf_set_image_exposure(lv_obj_t *obj, float value)

Set the image exposure level

Parameters:
  • obj – pointer to a GLTF viewer object

  • value – exposure level (1.0 is default)

float lv_gltf_get_image_exposure(const lv_obj_t *obj)

Get the image exposure level

Parameters:

obj – pointer to a GLTF viewer object

Returns:

exposure level

void lv_gltf_set_antialiasing_mode(lv_obj_t *obj, lv_gltf_aa_mode_t value)

Set the anti-aliasing mode

Parameters:
  • obj – pointer to a GLTF viewer object

  • value – anti-aliasing mode

lv_gltf_aa_mode_t lv_gltf_get_antialiasing_mode(const lv_obj_t *obj)

Get the anti-aliasing mode

Parameters:

obj – pointer to a GLTF viewer object

Returns:

anti-aliasing mode