Skip to content

Instantly share code, notes, and snippets.

@beothorn
Last active August 29, 2015 14:21
Show Gist options
  • Save beothorn/65e52b66cfb8496cef0e to your computer and use it in GitHub Desktop.
Save beothorn/65e52b66cfb8496cef0e to your computer and use it in GitHub Desktop.
This is a blender script to convert an object to a literal java array
import bpy
'''
This is a blender script to convert an object to a literal java array
'''
result = "static float coords[] = {\n"
current_obj = bpy.context.active_object
for face in current_obj.data.polygons:
verts_in_face = face.vertices[:]
for vert in verts_in_face:
local_point = current_obj.data.vertices[vert].co
world_point = current_obj.matrix_world * local_point
result = result + "\t" + str(world_point.x) + "f, " +str(world_point.y) + "f, " +str(world_point.z) + "f, \n"
result = result[:-1] + "\n};"
print(result)
with open('/home/you/model.txt', 'a') as f:
f.write(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment