Created
November 30, 2018 00:57
-
-
Save timknip/ea406a8034149fa22f3318ca04d5c8c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openmesh as om | |
import numpy as np | |
mesh = om.read_trimesh('earth.obj', vertex_normal=True, vertex_tex_coord=True) | |
# make mesh handle these attributes | |
mesh.request_vertex_normals() | |
mesh.request_vertex_texcoords2D() | |
# create decimater | |
decimator = om.TriMeshDecimater(mesh) | |
# Quadric decimater module (there's other modules as well..) | |
# print dir(om) | |
modQ = om.TriMeshModQuadricHandle() | |
# add it to the decimater | |
decimator.add(modQ) | |
# setup Quadric module | |
decimator.module(modQ).set_max_err(1e-5) | |
decimator.module(modQ).set_binary(False) | |
# initialize | |
decimator.initialize() | |
# go! | |
decimator.decimate_to(int(len(mesh.points()) * 0.1)) | |
# always needed after decimation | |
mesh.garbage_collection() | |
om.write_mesh('test.obj', mesh, vertex_normal=True, vertex_tex_coord=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just found it didn't work in my program and the model retained the same verts and faces.