0

I'm trying to load a mesh from an .obj file (from ShapeNet dataset) using Trimesh, and then use the repair.fix_winding(mesh) function.

But when I load the mesh, via

trimesh.load('/path/to/file.obj') or trimesh.load_mesh('/path/to/file.obj'),

the object class returned is Scene, which is incompatible with repair.fix_winding(mesh), only Trimesh object are accepted.

How can I force it to load and return a Trimesh object or parse the Scene object to Trimesh object? Or any other way to fix winding of the triangles?

Using:

Python 3.6.5

Trimesh 3.0.14

MacOS 10.14.5

Blueko
  • 111
  • 3
  • 10

3 Answers3

2

With the current trimesh version (3.9.42), you need to use trimesh.load with force='mesh':

trimesh.load('/path/to/file.obj', force='mesh')

https://trimsh.org/trimesh.html?highlight=load#trimesh.load

pete-sk
  • 21
  • 2
0

I have the same problem. You can access the "geometry" member of the scene, but I have no idea how the original mesh is split into multiple ones. Following.

0

The load_mesh has an option to be passed as aa Trimesh constructor as explained in the documentation.

https://trimsh.org/trimesh.html?highlight=load_mesh#trimesh.load_mesh

here is an example code

mesh= t.load_mesh('./test.stl',process=False)
mesh.is_watertight

the second line ".is_watertight" is an attribute of Trimesh so you will get True if it is successfully imported as Trimesh.

Roman Kovtuh
  • 561
  • 8
  • 14