minor changes from stable

This commit is contained in:
Campbell Barton 2007-08-01 10:19:16 +00:00
parent a84c598b35
commit 311d7e31cc
3 changed files with 21 additions and 46 deletions

@ -1,7 +1,7 @@
#!BPY #!BPY
""" """
Name: '3D Studio (.3ds)...' Name: '3D Studio (.3ds)...'
Blender: 241 Blender: 244
Group: 'Import' Group: 'Import'
Tooltip: 'Import from 3DS file format (.3ds)' Tooltip: 'Import from 3DS file format (.3ds)'
""" """
@ -945,6 +945,7 @@ if __name__=='__main__' and not DEBUG:
#load_3ds('/metavr/convert/vehicle/truck_002/TruckTanker1.3DS', False) #load_3ds('/metavr/convert/vehicle/truck_002/TruckTanker1.3DS', False)
#load_3ds('/metavr/archive/convert/old/arranged_3ds_to_hpx-2/only-need-engine-trains/Engine2.3DS', False) #load_3ds('/metavr/archive/convert/old/arranged_3ds_to_hpx-2/only-need-engine-trains/Engine2.3DS', False)
''' '''
else: else:
# DEBUG ONLY # DEBUG ONLY
TIME= Blender.sys.time() TIME= Blender.sys.time()
@ -956,6 +957,11 @@ else:
file= open('/tmp/temp3ds_list', 'r') file= open('/tmp/temp3ds_list', 'r')
lines= file.readlines() lines= file.readlines()
file.close() file.close()
# sort by filesize for faster testing
lines_size = [(os.path.getsize(f[:-1]), f[:-1]) for f in lines]
lines_size.sort()
lines = [f[1] for f in lines_size]
def between(v,a,b): def between(v,a,b):
if v <= max(a,b) and v >= min(a,b): if v <= max(a,b) and v >= min(a,b):
@ -963,8 +969,8 @@ else:
return False return False
for i, _3ds in enumerate(lines): for i, _3ds in enumerate(lines):
if between(i, 1,200): if between(i, 650,800):
_3ds= _3ds[:-1] #_3ds= _3ds[:-1]
print 'Importing', _3ds, '\nNUMBER', i, 'of', len(lines) print 'Importing', _3ds, '\nNUMBER', i, 'of', len(lines)
_3ds_file= _3ds.split('/')[-1].split('\\')[-1] _3ds_file= _3ds.split('/')[-1].split('\\')[-1]
newScn= Blender.Scene.New(_3ds_file) newScn= Blender.Scene.New(_3ds_file)
@ -972,4 +978,5 @@ else:
load_3ds(_3ds, False) load_3ds(_3ds, False)
print 'TOTAL TIME: %.6f' % (Blender.sys.time() - TIME) print 'TOTAL TIME: %.6f' % (Blender.sys.time() - TIME)
''' '''

@ -706,6 +706,7 @@ def write_scene(file, sce, world):
textures = {} textures = {}
armatures = [] # We should export standalone armatures also armatures = [] # We should export standalone armatures also
armatures_totbones = 0 # we need this because each bone is a model armatures_totbones = 0 # we need this because each bone is a model
ob_type = None # incase no objects are exported, so as not to raise an error
for ob_base in sce.objects.context: for ob_base in sce.objects.context:
for ob, mtx in BPyObject.getDerivedObjects(ob_base): for ob, mtx in BPyObject.getDerivedObjects(ob_base):
#for ob in [ob_base,]: #for ob in [ob_base,]:

@ -1006,46 +1006,6 @@ def read_surfs(lwochunk, surf_list, tag_list):
###if DEBUG: print "-> Material pre-allocated." ###if DEBUG: print "-> Material pre-allocated."
return my_dict return my_dict
def reduce_face(verts, face):
####if DEBUG: print len(face), face
# wants indicies local to the face
len_face= len(face)
# Dont do this, its no good - odd quads are ok and used in subsurf modeling
"""
TriangleArea= Blender.Mathutils.TriangleArea
if len_face==3:
return [face]
elif len_face==4:
vecs= [Vector(verts[i]) for i in face]
# Get the convave quad area
a1= TriangleArea(vecs[0], vecs[1], vecs[2])
a2= TriangleArea(vecs[0], vecs[2], vecs[3])
a3= TriangleArea(vecs[0], vecs[1], vecs[3])
a4= TriangleArea(vecs[1], vecs[2], vecs[3])
if abs((a1+a2) - (a3+a4)) < (a1+a2+a3+a4)/100: # Not convace
####if DEBUG: print 'planer'
return [[0,1,2,3]]
if a1+a2<a3+a4:
return [[0,1,2], [0,2,3]]
else:
return [[0,1,3], [1,2,3]]
"""
if len(face) <= 4:
return [face]
else: # 5+
###if DEBUG: print 'SCANFILL...', len(face)
return BPyMesh.ngon(verts, face, PREF_FIX_LOOPS= True)
# ========================= # =========================
# === Recalculate Faces === # === Recalculate Faces ===
# ========================= # =========================
@ -1200,7 +1160,7 @@ def my_create_mesh(clip_list, surf, objspec_list, current_facelist, objname, not
face_data.append( [vertex_map[j] for j in rev_face] ) face_data.append( [vertex_map[j] for j in rev_face] )
if uv_flag: face_uvs.append(tmp_get_face_uvs(rev_face, i)) if uv_flag: face_uvs.append(tmp_get_face_uvs(rev_face, i))
elif numfaceverts > 4: elif numfaceverts > 4:
meta_faces= reduce_face(complete_vertlist, cur_face) # Indices of triangles meta_faces= BPyMesh.ngon(complete_vertlist, cur_face, PREF_FIX_LOOPS= True)
edge_face_count = {} edge_face_count = {}
for mf in meta_faces: for mf in meta_faces:
# These will always be tri's since they are scanfill faces # These will always be tri's since they are scanfill faces
@ -1689,6 +1649,12 @@ os.system('find /fe/lwo/Objects/ -follow -iname "*.lwo" > /tmp/templwo_list')
print '...Done' print '...Done'
file= open('/tmp/templwo_list', 'r') file= open('/tmp/templwo_list', 'r')
lines= file.readlines() lines= file.readlines()
# sort by filesize for faster testing
lines_size = [(os.path.getsize(f[:-1]), f[:-1]) for f in lines]
lines_size.sort()
lines = [f[1] for f in lines_size]
file.close() file.close()
def between(v,a,b): def between(v,a,b):
@ -1705,8 +1671,9 @@ for i, _lwo in enumerate(lines):
#if between(i, 525, 550): #if between(i, 525, 550):
#if i > 1635: #if i > 1635:
#if i != 1519: # 730 #if i != 1519: # 730
if i>125: if i>141:
_lwo= _lwo[:-1] #if 1:
# _lwo= _lwo[:-1]
print 'Importing', _lwo, '\nNUMBER', i, 'of', len(lines) print 'Importing', _lwo, '\nNUMBER', i, 'of', len(lines)
_lwo_file= _lwo.split('/')[-1].split('\\')[-1] _lwo_file= _lwo.split('/')[-1].split('\\')[-1]
newScn= bpy.data.scenes.new(_lwo_file) newScn= bpy.data.scenes.new(_lwo_file)