-
Notifications
You must be signed in to change notification settings - Fork 574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
obj file loaded as Scene object instead of Trimesh object #507
Comments
I have the same issue. One thing bothers me. How can a load function return a trimesh object or a Scene? When does it return one and when the other? It's really ambiguous. Also, where is the documentation for older versions? |
My understanding is that some import trimesh
def as_mesh(scene_or_mesh):
"""
Convert a possible scene to a mesh.
If conversion occurs, the returned mesh has only vertex and face data.
"""
if isinstance(scene_or_mesh, trimesh.Scene):
if len(scene_or_mesh.geometry) == 0:
mesh = None # empty scene
else:
# we lose texture information here
mesh = trimesh.util.concatenate(
tuple(trimesh.Trimesh(vertices=g.vertices, faces=g.faces)
for g in scene_or_mesh.geometry.values()))
else:
assert(isinstance(mesh, trimesh.Trimesh))
mesh = scene_or_mesh
return mesh |
Thank you for the answer! For now I just locked the version of trimesh to an older one, but when we'll update I'll use your solution. |
Same! Trying a previous version at the moment. |
Yeah, this was one of the larger API changes in #467, and is an unfortunate consequence of better texture support: meshes with multiple materials get put into different mesh objects. The solution I would recommend (after I fix a bug in texture concatenation, sigh) is:
If we had a nice "combine textured meshes" method, we could possibly return the default behavior to return a single mesh, or a have a load kwarg |
I just pushed a version ( |
Got frustrated w/ PyMesh not building on the cluster, Pytorch3d's mesh loader was too slow, so here's a short snippet using trimesh:
|
Nice! There are some convenience methods we added since this issue was closed that also might be helpful:
|
That's incredibly useful. Since I only need the geometry, I wonder if there is a way to bypass the texture/material concat step. |
Yeah the material concatenation is pretty expensive, we could add Yet Another Keyword Argument™️ to the OBJ loader haha. It still complains about concatenation because it's still loading UV coordinates, but speeds it up by an order of magnitude:
Happy to include in the next release if that's useful. |
I would be super grateful. |
Also would appreciate a merge of the texture skipping. |
Oh that was merged, I just renamed it to trimesh/trimesh/exchange/obj.py Lines 26 to 45 in fef8efb
|
Nice, there's a lot of flags in there. |
Hi,
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')
ortrimesh.load_mesh('/path/to/file.obj')
, the object class returned is Scene, which is incompatible withrepair. 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?
The text was updated successfully, but these errors were encountered: