OBJ export nurbs curves now export again.

This commit is contained in:
2010-08-27 04:43:42 +00:00
parent 3cdcff9859
commit fb66c93b90

View File

@@ -184,50 +184,48 @@ def copy_images(dest_dir):
# paths= bpy.util.copy_images(uniqueImages.values(), dest_dir) # paths= bpy.util.copy_images(uniqueImages.values(), dest_dir)
print('\tCopied %d images' % copyCount) print('\tCopied %d images' % copyCount)
# print('\tCopied %d images' % copyCount)
# XXX not converted
def test_nurbs_compat(ob): def test_nurbs_compat(ob):
if ob.type != 'Curve': if ob.type != 'CURVE':
return False return False
for nu in ob.data: for nu in ob.data.splines:
if (not nu.knotsV) and nu.type != 1: # not a surface and not bezier if nu.point_count_v == 1 and nu.type != 'BEZIER': # not a surface and not bezier
return True return True
return False return False
# XXX not converted
def write_nurb(file, ob, ob_mat): def write_nurb(file, ob, ob_mat):
tot_verts = 0 tot_verts = 0
cu = ob.data cu = ob.data
# use negative indices # use negative indices
Vector = Blender.mathutils.Vector for nu in cu.splines:
for nu in cu: if nu.type == 'POLY':
DEG_ORDER_U = 1
else:
DEG_ORDER_U = nu.order_u - 1 # odd but tested to be correct
if nu.type==0: DEG_ORDER_U = 1 if nu.type == 'BEZIER':
else: DEG_ORDER_U = nu.orderU-1 # Tested to be correct
if nu.type==1:
print("\tWarning, bezier curve:", ob.name, "only poly and nurbs curves supported") print("\tWarning, bezier curve:", ob.name, "only poly and nurbs curves supported")
continue continue
if nu.knotsV: if nu.point_count_v > 1:
print("\tWarning, surface:", ob.name, "only poly and nurbs curves supported") print("\tWarning, surface:", ob.name, "only poly and nurbs curves supported")
continue continue
if len(nu) <= DEG_ORDER_U: if len(nu.points) <= DEG_ORDER_U:
print("\tWarning, orderU is lower then vert count, skipping:", ob.name) print("\tWarning, order_u is lower then vert count, skipping:", ob.name)
continue continue
pt_num = 0 pt_num = 0
do_closed = (nu.flagU & 1) do_closed = nu.use_cyclic_u
do_endpoints = (do_closed==0) and (nu.flagU & 2) do_endpoints = (do_closed == 0) and nu.use_endpoint_u
for pt in nu: for pt in nu.points:
pt = Vector(pt[0], pt[1], pt[2]) * ob_mat pt = ob_mat * pt.co.copy().resize3D()
file.write('v %.6f %.6f %.6f\n' % (pt[0], pt[1], pt[2])) file.write('v %.6f %.6f %.6f\n' % (pt[0], pt[1], pt[2]))
pt_num += 1 pt_num += 1
tot_verts += pt_num tot_verts += pt_num
@@ -390,16 +388,13 @@ def write_file(filepath, objects, scene,
for ob, ob_mat in obs: for ob, ob_mat in obs:
# XXX postponed # Nurbs curve support
# # Nurbs curve support if EXPORT_CURVE_AS_NURBS and test_nurbs_compat(ob):
# if EXPORT_CURVE_AS_NURBS and test_nurbs_compat(ob): if EXPORT_ROTX90:
# if EXPORT_ROTX90: ob_mat = ob_mat * mat_xrot90
# ob_mat = ob_mat * mat_xrot90 totverts += write_nurb(file, ob, ob_mat)
continue
# totverts += write_nurb(file, ob, ob_mat) # END NURBS
# continue
# end nurbs
if ob.type != 'MESH': if ob.type != 'MESH':
continue continue