Created
August 23, 2011 22:53
-
-
Save philogb/1166835 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sys | |
import json | |
import struct | |
FILES = ['surf_reg_model_both_inflate_high.json', | |
'surf_reg_model_both_inflate_middle.json', | |
'surf_reg_model_both_inflate_low.json', | |
'surf_reg_model_both_normal.json'] | |
def bin(): | |
for name in FILES: | |
with open(name, 'r') as f: | |
obj = json.loads(f.read()) | |
with open(name + '.bin', 'w') as f: | |
ncomp = len(obj[0]) | |
dat = struct.pack('f', float(ncomp)) | |
f.write(dat) | |
for vertex in obj[0]: | |
f.write(struct.pack('f', vertex)) | |
for normal in obj[1]: | |
f.write(struct.pack('f', normal)) | |
for index in obj[2]: | |
f.write(struct.pack('I', index)) | |
if __name__ == '__main__': | |
bin() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment