OBJ Import
* Wasn't setting the curve 3D option * The nurbs object name could be None which caused an error, check its set. OBJ Export * Off by 1 error on closed nurbs was incorrect, broke other importers but worked with blender. * Nurbs verts were not adding to the total vert count, scrambling meshes added after (somehow my first test case had all the curve objects last)
This commit is contained in:
parent
03de57c6d5
commit
2371c35afc
@ -193,6 +193,7 @@ def test_nurbs_compat(ob):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def write_nurb(file, ob, ob_mat):
|
def write_nurb(file, ob, ob_mat):
|
||||||
|
tot_verts = 0
|
||||||
cu = ob.data
|
cu = ob.data
|
||||||
|
|
||||||
# use negative indices
|
# use negative indices
|
||||||
@ -222,7 +223,7 @@ def write_nurb(file, ob, ob_mat):
|
|||||||
pt = Vector(pt[0], pt[1], pt[2]) * ob_mat
|
pt = Vector(pt[0], pt[1], pt[2]) * ob_mat
|
||||||
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
|
||||||
|
|
||||||
file.write('g %s\n' % (fixName(ob.name))) # fixName(ob.getData(1)) could use the data name too
|
file.write('g %s\n' % (fixName(ob.name))) # fixName(ob.getData(1)) could use the data name too
|
||||||
file.write('cstype bspline\n') # not ideal, hard coded
|
file.write('cstype bspline\n') # not ideal, hard coded
|
||||||
@ -236,7 +237,7 @@ def write_nurb(file, ob, ob_mat):
|
|||||||
pt_num += 1
|
pt_num += 1
|
||||||
curve_ls.append(-1)
|
curve_ls.append(-1)
|
||||||
else:
|
else:
|
||||||
pt_num += DEG_ORDER_U-1
|
pt_num += DEG_ORDER_U
|
||||||
curve_ls = curve_ls + curve_ls[0:DEG_ORDER_U]
|
curve_ls = curve_ls + curve_ls[0:DEG_ORDER_U]
|
||||||
|
|
||||||
file.write('curv 0.0 1.0 %s\n' % (' '.join( [str(i) for i in curve_ls] ))) # Blender has no U and V values for the curve
|
file.write('curv 0.0 1.0 %s\n' % (' '.join( [str(i) for i in curve_ls] ))) # Blender has no U and V values for the curve
|
||||||
@ -254,6 +255,8 @@ def write_nurb(file, ob, ob_mat):
|
|||||||
file.write('parm u %s\n' % ' '.join( [str(i) for i in parm_ls] ))
|
file.write('parm u %s\n' % ' '.join( [str(i) for i in parm_ls] ))
|
||||||
|
|
||||||
file.write('end\n')
|
file.write('end\n')
|
||||||
|
|
||||||
|
return tot_verts
|
||||||
|
|
||||||
def write(filename, objects,\
|
def write(filename, objects,\
|
||||||
EXPORT_TRI=False, EXPORT_EDGES=False, EXPORT_NORMALS=False, EXPORT_NORMALS_HQ=False,\
|
EXPORT_TRI=False, EXPORT_EDGES=False, EXPORT_NORMALS=False, EXPORT_NORMALS_HQ=False,\
|
||||||
@ -337,7 +340,6 @@ EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
|
|||||||
|
|
||||||
globalNormals = {}
|
globalNormals = {}
|
||||||
|
|
||||||
|
|
||||||
# Get all meshes
|
# Get all meshes
|
||||||
for ob_main in objects:
|
for ob_main in objects:
|
||||||
for ob, ob_mat in BPyObject.getDerivedObjects(ob_main):
|
for ob, ob_mat in BPyObject.getDerivedObjects(ob_main):
|
||||||
@ -347,7 +349,7 @@ EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
|
|||||||
if EXPORT_ROTX90:
|
if EXPORT_ROTX90:
|
||||||
ob_mat = ob_mat * mat_xrot90
|
ob_mat = ob_mat * mat_xrot90
|
||||||
|
|
||||||
write_nurb(file, ob, ob_mat)
|
totverts += write_nurb(file, ob, ob_mat)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
# end nurbs
|
# end nurbs
|
||||||
|
@ -563,6 +563,8 @@ def create_nurbs(scn, context_nurbs, vert_loc, new_objects):
|
|||||||
return
|
return
|
||||||
|
|
||||||
cu = bpy.data.curves.new(name, 'Curve')
|
cu = bpy.data.curves.new(name, 'Curve')
|
||||||
|
cu.flag |= 1 # 3D curve
|
||||||
|
|
||||||
nu = None
|
nu = None
|
||||||
for pt in curv_idx:
|
for pt in curv_idx:
|
||||||
|
|
||||||
@ -907,7 +909,8 @@ def load_obj(filepath,
|
|||||||
context_nurbs['deg']= [int(i) for i in line.split()[1:]]
|
context_nurbs['deg']= [int(i) for i in line.split()[1:]]
|
||||||
elif line.startswith('end'):
|
elif line.startswith('end'):
|
||||||
# Add the nurbs curve
|
# Add the nurbs curve
|
||||||
context_nurbs['name'] = context_object
|
if context_object:
|
||||||
|
context_nurbs['name'] = context_object
|
||||||
nurbs.append(context_nurbs)
|
nurbs.append(context_nurbs)
|
||||||
context_nurbs = {}
|
context_nurbs = {}
|
||||||
context_parm = ''
|
context_parm = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user