phy_export/phy_export.py
josh 62b0450b0c taking absolute values of shape sizes to avoid ODE errors
git-svn-id: svn://anubis/misc/phy_export@208 bd8a9e45-a331-0410-811e-c64571078777
2009-11-16 02:30:37 +00:00

49 lines
1.7 KiB
Python

#!BPY
"""
Name: 'Joshs Physics Information (.phy) Exporter'
Blender: 244
Group: 'Export'
Tooltip: 'Joshs Physics Information (.phy) Exporter'
"""
import Blender
import bpy
def write(filename):
out = file(filename, "w")
sce = bpy.data.scenes.active
for ob in sce.objects:
if ob.name[0] == '_':
continue
if ob.type == 'Mesh':
if len(ob.data.faces) == 1:
# found a plane
e = ob.getEuler()
out.write("plane \"%s\" %f %f %f %f %f %f\n" %
((ob.name,) + ob.getLocation() + (e[0], e[1], e[2])))
elif len(ob.data.faces) == 6:
# found a cube
e = ob.getEuler()
size = ob.getSize()
out.write("cube \"%s\" %f %f %f %f %f %f %f %f %f\n" %
((ob.name,
2 * abs(size[0]),
2 * abs(size[1]),
2 * abs(size[2])) +
ob.getLocation() +
(e[0], e[1], e[2])))
elif len(ob.data.faces) < 256:
# found a capsule
e = ob.getEuler()
out.write("capsule \"%s\" %f %f %f %f %f %f %f %f\n" %
((ob.name,)
+ (abs(ob.getSize()[0]), abs(ob.getSize()[2]) * 2)
+ ob.getLocation()
+ (e[0], e[1], e[2])))
elif len(ob.data.faces) >= 256:
# found a sphere
out.write("sphere \"%s\" %f %f %f %f\n" %
((ob.name, abs(ob.SizeX)) + ob.getLocation()))
Blender.Window.FileSelector(write, "Export")