mikedh / trimesh

Python library for loading and using triangular meshes.
https://trimesh.org
MIT License
3k stars 581 forks source link

Fix inconsistent face orientations #1858

Open RaabeM opened 1 year ago

RaabeM commented 1 year ago

Hi everyone, I am doing vision research in mujoco. Therefore I want to import ShapeNet meshes into mujoco. Unfortunately this error appears:

Error: faces have inconsistent orientation

So what I would like to do is the following:

  1. Import an .obj with trimesh
  2. Concatinate all subgroups of meshes into one group
  3. Fix the face orientations
  4. Export the mesh to a new .obj

Simply import the .obj (1), concat the subgroups with this thread (2) and export the mesh to a new .obj (4) does not help to fix the error massage.

Do you guys have any idea, what I could do? Thanks in advance!

Currently my code looks like this:

import trimesh
mesh = trimesh.load(PATH+FILE)
print(type(mesh))

trimesh.scene.scene.Scene

dump = mesh.dump()
concat = dump.sum()
print(type(concat))

trimesh.base.Trimesh

resolver = trimesh.resolvers.FilePathResolver(PATH)
output = trimesh.exchange.obj.export_obj(concat, resolver=resolver)
file = open(PATH + 'test.obj', 'w')
file.write(output)
file.close()
shayan-nikoo commented 7 months ago

Did you try mesh.fix_normals()?