Invert an .obj file with Python

41 Views Asked by At

I have an .obj file, but when I render it to video using the kire package, it is upside down.

Now I need the mesh to be inverted, so that it works normally with the rest of my system.

How can I achieve this with Python?

Update: this is the minimal code for inversing the vertices of the mesh and visualizing it with matplotlib

from pywavefront import Wavefront
import numpy as np
import matplotlib.pyplot as plt

path = '00000.obj'

verts = Wavefront(path).vertices

xs = []
ys = []
zs = []

for v in verts:
    xs.append(v[0])
    ys.append(-v[1])    # inverse the coordinate
    zs.append(v[2])

# visualization
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(xs, ys, zs, color='b', marker='o')
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show() 

and this is the .obj file I use to test the code.

0

There are 0 best solutions below