Created
April 29, 2011 16:24
-
-
Save stevenlr/948566 to your computer and use it in GitHub Desktop.
blender exporter (triangles only)
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 Blender | |
objects = [] | |
for o in bpy.data.objects: | |
if o.type == "Mesh": | |
objects.append(o) | |
data = "" | |
n = 0 | |
for o in objects: | |
ox = o.loc[0] | |
oy = o.loc[1] | |
oz = o.loc[2] | |
sx = o.size[0] | |
sy = o.size[1] | |
sz = o.size[2] | |
m = o.getData(mesh = 1) | |
for f in m.faces: | |
n += 1 | |
mat = m.materials[f.mat].rgbCol | |
data += "%f %f %f\n" % (mat[0], mat[1], mat[2]) | |
for i in range(0, 3): | |
v = m.verts[f.v[i].index].co | |
x = v.x * sx + ox | |
y = v.y * sy + oy | |
z = v.z * sz + oz | |
data += "%f %f %f\n" % (x, y, z) | |
data = str(n) + "\n" + data | |
fp = open("3d_output.dat", "wb") | |
fp.write(data) | |
fp.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment