Asset Converter

Asset Converter is extension that works for providing python interfaces for converting other formats into USD, and also supporting to convert USD to those assets.

Programming Guide

"""
This is the simple sample that utilizes omni.kit.asset_converter to convert assets.
"""

import asyncio
import omni.kit.asset_converter

def progress_callback(current_step: int, total: int):
    # Show progress
    print(f"{current_step} of {total}")

async def convert(input_asset_path, output_asset_path):
    task_manager = converter.get_instance()
    task = task_manager.create_converter_task(input_asset_path, output_asset_path, progress_callback)
    success = await task.wait_until_finished()
    if not success:
        detailed_status_code = task.get_status()
        detailed_status_error_string = task.get_error_message()
        ...

...
asyncio.ensure_future(convert(input_path, output_path))
...

create_converter_task supports a fourth param omni.kit.asset_converter.AssetConverterContext, which you can use to customize the import/export. By default, it will import/export all supported props. Following is its definition:

class AssetConverterContext:
    ignore_materials = False    # Don't import/export materials
    ignore_animations = False   # Don't import/export animations
    ignore_camera = False       # Don't import/export cameras
    ignore_light = False        # Don't import/export lights
    single_mesh = False         # By default, instanced props will be export as single USD for reference. If
                                # this flag is true, it will export all props into the same USD without instancing.
    smooth_normals = True       # Smoothing normals, which is only for assimp backend.
    export_preview_surface = False      # Imports material as UsdPreviewSurface instead of MDL for USD export
    support_point_instancer = False     # Deprecated
    embed_mdl_in_usd = True     # Deprecated.
    use_meter_as_world_unit = False     # Sets world units to meters, this will also scale asset if it's centimeters model.
    create_world_as_default_root_prim = True    # Creates /World as the root prim for Kit needs.
    embed_textures = True   # Embedding textures into output. This is only enabled for FBX and glTF export.
    convert_fbx_to_y_up = False   # Always use Y-up for fbx import.
    convert_fbx_to_z_up = False   # Always use Z-up for fbx import.
    keep_all_materials = False    # If it's to remove non-referenced materials.
    merge_all_meshes = False      # Merges all meshes to single one if it can.
    use_double_precision_to_usd_transform_op = False   # Uses double precision for all transform ops.
    ignore_pivots = False         # Don't export pivots if assets support that.
    disabling_instancing = False  # Don't export instancing assets with instanceable flag.
    export_hidden_props = False   # By default, only visible props will be exported from USD exporter.
    baking_scales = False         # Only for FBX. It's to bake scales into meshes.
    ignore_flip_rotations = False # Don't ignore animation's flip rotation value.
    ignore_unbound_bones = False  # Only for FBX. Don't ignore unbound bones.
    bake_mdl_material = False     # Bake mdl material when export
    export_separate_gltf = False  # Export gltf with separate bin file if true, else export one standalone gltf.
    export_mdl_gltf_extension = False # Only for glTF. Export materials as NV_materials_mdl extension materials.

Features Supported

  • Supports OBJ/FBX/glTF to USD and USD to those formats. Asset converter will fallback into Assimp if the format is not recognized. So all formats that are supported by Assimp should be supported too. But only OBJ/FBX/glTF are mainly supported and tested.

  • Supports both glTF (text) and glb (binary) with/without embedding textures.

  • Supports meshes/cameras/lights import.

  • Supports rigid and skeletal animations.

  • Supports to convert glTF materials into MDL with extensions KHR_materials_pbrSpecularGlossiness, KHR_materials_clearcoat, KHR_draco_mesh_compression, KHR_texture_transform, KHR_materials_volume, KHR_materials_emissive_strength, KHR_materials_ior, KHR_materials_sheen, KHR_materials_transmission.

Limitations

  • It does not support recursive skeleton for glTF.

  • Only OmniPBR, UsdPreviewSurface, and specified gltf.mdl are supported for exporting USD to other formats. It does not support to bake any MDLs into other material surfaces.