Skip to content

Commit

Permalink
Load collada files
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderFabisch committed Jul 27, 2023
1 parent 31a0aaf commit 7d9541e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pytransform3d/visualizer/_artists.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,23 @@ class Mesh(Artist):
"""
def __init__(self, filename, A2B=np.eye(4), s=np.ones(3), c=None,
convex_hull=False):
mesh = o3d.io.read_triangle_mesh(filename)
if filename.endswith(".dae"):
import collada
mesh = o3d.geometry.TriangleMesh()
try:
model = collada.Collada(filename)
for geometry in model.geometries:
for primitive in geometry.primitives:
p = o3d.geometry.TriangleMesh()
vertices = primitive.vertex
p.vertices = o3d.utility.Vector3dVector(vertices)
triangles = primitive.vertex_index
p.triangles = o3d.utility.Vector3iVector(triangles)
mesh += p
except:
warnings.warn("Parsing collada file '%s' failed" % filename)
else:
mesh = o3d.io.read_triangle_mesh(filename)
if convex_hull:
self.mesh = mesh.compute_convex_hull()[0]
else:
Expand Down

0 comments on commit 7d9541e

Please sign in to comment.