Created
November 25, 2019 17:47
-
-
Save 1f0/96b18a6be2bdf078a1e15fa3abb68251 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 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