NVIDIAGameWorks/kaolin

USD/OBJ meshes strange results

albertotono opened this issue · 2 comments

This is the mesh in MeshLAB
Screenshot from 2023-03-17 16-06-05

and this is in Kaolin.
Screenshot from 2023-03-17 16-03-05

USD and OBJ attached
1.zip
new_stage.zip

When I import the obj on Create it works well, so I guess the issue is on my code?

def create_stage(file_path, up_axis='Z'):
    r"""Create a new USD file and return an empty stage.
    Args:
        file_path (str): Path to usd file (\*.usd, \*.usda).
        up_axis (['Y', 'Z']): Specify the stage up axis. Choose from ``['Y', 'Z']``.
    Returns:
        (Usd.Stage)
    Example:
        >>> stage = create_stage('./new_stage.usd', up_axis='Z')
        >>> type(stage)
        <class 'pxr.Usd.Stage'>
    """
    assert os.path.exists(os.path.dirname(file_path)), f'Directory {os.path.dirname(file_path)} not found.'
    stage = Usd.Stage.CreateNew(str(file_path))
    world = stage.DefinePrim('/World', 'Xform')
    stage.SetDefaultPrim(world)
    UsdGeom.SetStageUpAxis(stage, up_axis)
    return stage

#path = '/home/alberto/Documents/test_onecube.obj'
mesh = kaolin.io.obj.import_mesh(path, with_materials=False, with_normals=False, error_handler=None, heterogeneous_mesh_handler=None)
stage = create_stage('./new_stage.usd')
scene_path = './new_stage.usd'
vertices = mesh.vertices
faces = mesh.faces
kaolin.io.usd.add_mesh(stage, '/World/mesh', vertices, faces, uvs=None, face_uvs_idx=None, face_normals=None, materials_order=None, materials=None, time=None)

I found a workaround thanks to Mati. But it would be great to have a robust obj import and usd export. :-)