kaolin.io.obj

API

Functions

kaolin.io.obj.load_mtl(mtl_path, error_handler)

Load and parse a Material file.

Followed format described in: https://people.sc.fsu.edu/~jburkardt/data/mtl/mtl.html. Currently only support diffuse, ambient and specular parameters (Kd, Ka, Ks) through single RGB values or texture maps.

Parameters:mtl_path (str) – Path to the mtl file.
Returns:Dictionary of materials, which are dictionary of properties with optional torch.Tensor values:
  • Kd: diffuse color of shape (3)
  • map_Kd: diffuse texture map of shape (H, W, 3)
  • Ks: specular color of shape (3)
  • map_Ks: specular texture map of shape (H’, W’, 3)
  • Ka: ambient color of shape (3)
  • map_Ka: ambient texture map of shape (H’‘, W’‘, 3)
Return type:(dict)
Raises:MaterialLoadError – Failed to load material, very often due to path to map_Kd/map_Ka/map_Ks being invalid.

Exceptions

exception kaolin.io.obj.MaterialError
exception kaolin.io.obj.MaterialLoadError
exception kaolin.io.obj.MaterialNotFoundError

Error handlers

kaolin.io.obj.default_error_handler(error, **kwargs)

Simple error handle to use in load_obj() that raises all errors.

kaolin.io.obj.skip_error_handler(error, **kwargs)

Simple error handler to use in load_obj() that skips all errors and logs them as warnings.