MaterialUtils#

class omni.kit.material.library.MaterialUtils#

Bases: object

Material library MaterialUtils class. Provides upto date cache of known materials in stage.

Methods

__init__()

add_cache_changed_fn(cache_changed_fn)

Adds callback to material cache changed list.

add_materials_from_stage_filter_func(filter_fn)

Add filter callback function to get_materials_from_stage_async() callback.

destroy()

Destroy class and cleanup.

flush_material_cache()

Clear material cache.

get_materials_from_stage([ext_filter_func])

Get list of materials for stage.

get_materials_from_stage_async(update_func, ...)

Get list of materials for stage asynchronously.

is_valid_material(prim, filter_funcs[, ...])

Is prim a valid material.

remove_cache_changed_fn(cache_changed_fn)

Remove callback to material cache changed list.

remove_materials_from_stage_filter_func(...)

Remove filter callback function from get_materials_from_stage_async() callback.

stop()

Stop traversing the stage

__init__()#
add_cache_changed_fn(cache_changed_fn: callable)#

Adds callback to material cache changed list.

Parameters:

cache_changed_fn (callable) – Callback.

add_materials_from_stage_filter_func(
filter_fn: callable,
)#

Add filter callback function to get_materials_from_stage_async() callback.

Parameters:

filter_fn (callable) – Filter function.

destroy()#

Destroy class and cleanup.

flush_material_cache()#

Clear material cache.

get_materials_from_stage(ext_filter_func=None)#

Get list of materials for stage. NOTE: This function can block on large stages.

Parameters:

ext_filter_func (callable) – filter function to remove material names from list. Optional.

Returns:

list of materials names

Return type:

(list)

get_materials_from_stage_async(
update_func: callable,
wait_frames: int,
ext_filter_func: callable,
)#

Get list of materials for stage asynchronously.

Parameters:
  • update_func (callable) – function to call when new material names are available.

  • wait_frames (int) – number of frames to wait before starting to get materials list.

  • ext_filter_func (callable) – filter function to remove material names from list. Optional.

static is_valid_material(
prim,
filter_funcs,
ext_filter_func=None,
)#

Is prim a valid material.

Parameters:
  • filter_funcs (list) – List of additional functions to validate material prim.

  • ext_filter_func (callable) – Additional function to validate material prim.

Returns:

True if valid material otherwise False.

Return type:

(bool)

remove_cache_changed_fn(cache_changed_fn: callable)#

Remove callback to material cache changed list.

Parameters:

cache_changed_fn (callable) – Callback.

remove_materials_from_stage_filter_func(
filter_fn: callable,
)#

Remove filter callback function from get_materials_from_stage_async() callback.

Parameters:

filter_fn (callable) – Filter function.

stop()#

Stop traversing the stage