X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_mesh.py;h=3873bf329e627f2d108085b73cc0ca76b1c2b8af;hb=9d8e4aa5a9573b34fe06455af249c762433d47c0;hp=30a5b4630a145efaaa0829f1b118b176a5b4ff66;hpb=8141d1e1cf5de45d1e8d640f3f8643ee748292dc;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_mesh.py b/blender/io_mspgl/export_mesh.py index 30a5b463..3873bf32 100644 --- a/blender/io_mspgl/export_mesh.py +++ b/blender/io_mspgl/export_mesh.py @@ -1,12 +1,6 @@ import itertools import bpy -from .outfile import OutFile - -def linear_to_srgb(l): - if l<0.0031308: - return 12.92*l - else: - return 1.055*(l**(1/2.4))-0.055 +import mathutils class VertexCache: def __init__(self, size): @@ -41,25 +35,16 @@ class VertexCache: class MeshExporter: def __init__(self): + self.show_progress = True self.use_strips = True - self.use_degen_tris = True + self.use_degen_tris = False self.max_strip_len = 1024 - self.optimize_cache = False + self.optimize_cache = True self.cache_size = 64 - self.export_lines = True - self.export_uv = "UNIT0" - self.tbn_vecs = False - self.tbn_uvtex = "" self.compound = False - self.object = False self.material_tex = False - self.srgb_colors = True - self.textures = "REF" - self.smoothing = "MSPGL" - self.export_groups = False - self.max_groups = 2 - def stripify(self, mesh, progress = None): + def stripify(self, mesh, progress=None): for f in mesh.faces: f.flag = False @@ -72,6 +57,7 @@ class MeshExporter: cache = VertexCache(self.cache_size) island = [] + face_neighbors = [] island_strips = [] while 1: if not island: @@ -91,11 +77,13 @@ class MeshExporter: face = queue.pop(0) island.append(face) - for n in f.get_neighbors(): + for n in face.get_neighbors(): if not n.flag: n.flag = True queue.append(n) + face_neighbors = [f.get_neighbors() for f in island] + # Unflag the island for the next phase for f in island: f.flag = False @@ -105,11 +93,11 @@ class MeshExporter: # or along borders of a non-closed island. best = 5 face = None - for f in island: + for i, f in enumerate(island): if f.flag: continue - score = sum(not n.flag for n in f.get_neighbors()) + score = sum(not n.flag for n in face_neighbors[i]) if score>0 and score