trimesh.exchange.obj¶
Functions:
|
Export a mesh as a Wavefront OBJ file. |
|
Load a Wavefront OBJ file into kwargs for a trimesh.Scene object. |
|
Parse a loaded MTL file. |
-
trimesh.exchange.obj.
export_obj
(mesh, include_normals=True, include_color=True, include_texture=True, return_texture=False, write_texture=True, resolver=None, digits=8)¶ Export a mesh as a Wavefront OBJ file. TODO: scenes with textured meshes
- Parameters
mesh (trimesh.Trimesh) – Mesh to be exported
include_normals (bool) – Include vertex normals in export
include_color (bool) – Include vertex color in export
bool (include_texture) – Include vt texture in file text
return_texture (bool) – If True, return a dict with texture files
write_texture (bool) – If True and a writable resolver is passed write the referenced texture files with resolver
resolver (None or trimesh.resolvers.Resolver) – Resolver which can write referenced text objects
digits (int) – Number of digits to include for floating point
- Returns
export (str) – OBJ format output
texture (dict) – [OPTIONAL] Contains files that need to be saved in the same directory as the exported mesh: {file name : bytes}
-
trimesh.exchange.obj.
load_obj
(file_obj, resolver=None, split_object=False, group_material=True, skip_materials=False, maintain_order=False, **kwargs)¶ Load a Wavefront OBJ file into kwargs for a trimesh.Scene object.
- Parameters
file_obj (file like object) – Contains OBJ data
resolver (trimesh.visual.resolvers.Resolver) – Allow assets such as referenced textures and material files to be loaded
split_object (bool) – Split meshes at each o declared in file
group_material (bool) – Group faces that share the same material into the same mesh.
skip_materials (bool) – Don’t load any materials.
maintain_order (bool or None) – Do not reorder faces or vertices which may result in visual artifacts.
- Returns
kwargs – Keyword arguments which can be loaded by trimesh.exchange.load.load_kwargs into a trimesh.Scene
- Return type
dict
-
trimesh.exchange.obj.
parse_mtl
(mtl, resolver=None)¶ Parse a loaded MTL file.
- Parameters
mtl (str or bytes) – Data from an MTL file
resolver (trimesh.Resolver) – Fetch assets by name from file system, web, or other
- Returns
mtllibs – Each dict has keys: newmtl, map_Kd, Kd
- Return type
list of dict