Created
October 6, 2015 11:24
-
-
Save zeffii/2c66f940996f9a686b4b 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 bpy | |
import json | |
obj = bpy.data.objects['XW'] | |
with open('/home/zeffii/Desktop/sw/geom_file3.tkg', 'w') as ofile: | |
geom_dict = {} | |
geom_dict['verts'] = [] | |
geom_dict['edges'] = [] | |
geom_dict['faces'] = [] | |
# verts | |
add_component = geom_dict['verts'].extend | |
for v in obj.data.vertices: | |
add_component([round(v.co.x, 5), round(v.co.y, 5), round(v.co.z, 5)]) | |
# faces | |
add_component = geom_dict['faces'].extend | |
for face in obj.data.polygons: | |
add_component(list(face.vertices[:])) | |
# edges | |
add_component = geom_dict['edges'].extend | |
edges_subset = [e for e in obj.data.edges if e.crease == 1.0] | |
for edge in edges_subset: | |
add_component(list(edge.vertices[:])) | |
ofile.write('var obj = ') | |
ofile.write(json.dumps(geom_dict)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment