Skip to content

Instantly share code, notes, and snippets.

@1f0
Created November 25, 2019 17:47
Show Gist options
  • Save 1f0/96b18a6be2bdf078a1e15fa3abb68251 to your computer and use it in GitHub Desktop.
Save 1f0/96b18a6be2bdf078a1e15fa3abb68251 to your computer and use it in GitHub Desktop.
import argparse
p = argparse.ArgumentParser(description='off to obj.')
p.add_argument('input')
p.add_argument('out')
args = p.parse_args()
with open(args.input) as f:
lines = f.readlines()
meta = lines[1].split()
vn = int(meta[0])
fn = int(meta[1])
with open(args.out, 'w') as f:
for i in range(2, 2 + vn):
f.write('v ' + lines[i])
for i in range(2 + vn, 2 + vn + fn):
face = [str(int(s)+1) for s in lines[i].split()[1:]]
s = ' '.join(face)
f.write('f ' + s + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment