1

i want to load a mesh file (.obj), then want to use the trimesh.sample.sample_surface_even() function to get some points on the surface, turn the resulting points back into a mesh and save them back as an .obj file.

My problem is, that i dont know how to turn the samples back into a mesh that can be saved. Can somebody tell me what i should do step by step, to achieve that goal?

Here is my code so far:

import numpy as np
import trimesh

mesh = trimesh.load_mesh('mesh10.obj')
sampledmesh= trimesh.sample.sample_surface_even(mesh,500)

#? How to turn sampledmesh back into a mesh?
sampledmesh.export('mesh10_export.obj')
David
  • 11
  • 1

1 Answers1

0

You can use the submesh function on the sampled face indices, which is the second element in the returned tuple:

sampledmesh = trimesh.sample.sample_surface_even(mesh,500)
sampled_submesh = mesh.submesh([sampledmesh[1]])[0]

submesh returns an array of meshes, but here we just have one, so we take the first mesh.

wwwslinger
  • 936
  • 8
  • 14