Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visualization 3d objects with Trimesh

I loaded a 3d object into the program using the function mesh = trimesh.load('test.obj'). I want to see what the object looks like now. How can I display the 3d model? What options do I have?

like image 880
Interpreter67 Avatar asked Oct 18 '25 13:10

Interpreter67


2 Answers

Let's keep it simple, you can use the show method. Note that this requires pyglet.

mesh.show()

should do the trick.

like image 190
LNiederha Avatar answered Oct 20 '25 02:10

LNiederha


You can plot a Trimesh object as any other 3d object.

First, create a subplot for your 3D object. Check out the documentation. Then use a plot_trisurf method.

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(projection='3d')


ax.plot_trisurf(trim.vertices[:, 0], trim.vertices[:,1], trim.vertices[:,2], triangles=trim.faces);

where trim is a Trimesh object.

You can also use plotly for this purpose, but this example is simple and concise.

like image 44
user12628549 Avatar answered Oct 20 '25 02:10

user12628549



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!