Last active
August 29, 2015 14:21
-
-
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
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 | |
''' | |
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