def __getattr__(self, attr):
return getattr(self._medge, attr)
- def __cmp__(self, other):
- return self is other
-
def check_smooth(self, limit):
if len(self.faces)!=2:
return
else:
self._mvert = mv
self.uv = None
- self.orig_index = self._mvert.index
self.flag = False
self.faces = []
self.tan = None
smooth_limit = math.cos(m.degr*math.pi/180)
else:
smooth_limit = -1
+
for e in self.edges.itervalues():
e.v1 = self.verts[e.v1.index]
e.v2 = self.verts[e.v2.index]
def __getattr__(self, attr):
return getattr(self._mesh, attr)
+ def splice(self, other):
+ offset = len(self.verts)
+ for v in other.verts:
+ v.index += offset
+ self.verts.append(v)
+
+ offset = len(self.faces)
+ for f in other.faces:
+ f.index += offset
+ self.faces.append(f)
+
+ for e in other.edges.itervalues():
+ e.key = make_edge_key(e.v1.index, e.v2.index)
+ self.edges[e.key] = e
+
+ self.lines += other.lines
+
def split_vertices(self, find_group_func, debug):
groups = []
for v in self.verts:
self.cache_size = 64
self.export_lines = True
self.tbn_vecs = False
+ self.compound = False
self.debug = False
self.strip_debug = False
self.split_debug = False
def export(self):
scene = bpy.data.scenes.active
- obj = scene.objects.active
- if obj.getType()!="Mesh":
- raise Exception, "Can only export Mesh data"
+ objs = Blender.Object.GetSelected()
+ if not objs:
+ raise Exception, "Nothing to export"
+ for o in objs:
+ if o.getType()!="Mesh":
+ raise Exception, "Can only export Mesh data"
mesh = Blender.Mesh.New("export_tmp")
- mesh.getFromObject(obj)
+ mesh.getFromObject(objs[0])
mesh = Mesh(mesh)
+ if self.compound:
+ bmeshes = []
+ for o in objs[1:]:
+ bmesh = Blender.Mesh.New("export_tmp")
+ bmesh.getFromObject(o)
+ bmeshes.append(bmesh)
+ mesh.splice(Mesh(bmesh))
if self.debug:
ntris = sum([len(f.verts)-2 for f in mesh.faces])
mesh.compute_tbn()
strips = []
+ loose = mesh.faces
if self.use_strips:
strips, loose = self.stripify(mesh)
self.cache_size = Blender.Draw.Create(self.config.get('cache_size', 64))
self.export_lines = Blender.Draw.Create(self.config.get('export_lines', False))
self.tbn_vecs = Blender.Draw.Create(self.config.get('tbn_vecs', False))
+ self.compound = Blender.Draw.Create(self.config.get('compound', False))
self.debug = Blender.Draw.Create(self.config.get('debug', False))
self.strip_debug = Blender.Draw.Create(self.config.get('strip_debug', False))
self.split_debug = Blender.Draw.Create(self.config.get('split_debug', False))
("Cache size", self.cache_size, 8, 1024, "Cache size to optimize for"),
("Export lines", self.export_lines, "Export lone edges as lines"),
("Compute T/B vecs", self.tbn_vecs, "Compute tangent/binormal vectors for bumpmapping"),
+ ("Compound", self.compound, "Create a compound mesh of all selected objects"),
("Debugging options"),
("Debug", self.debug),
("Debug strips", self.strip_debug),
("Debug splitting", self.split_debug)])
if ret:
dirname = self.temp_config.get("dirname", Blender.sys.dirname(Blender.Get("filename")))
- obj = bpy.data.scenes.active.objects.active
+ obj = Blender.Object.GetSelected()[0]
Blender.Window.FileSelector(self.export, "Export MSP GL mesh", "%s/%s.mesh"%(dirname, obj.name))
def draw(self):
self.config['cache_size'] = self.cache_size.val
self.config['export_lines'] = self.export_lines.val
self.config['tbn_vecs'] = self.tbn_vecs.val
+ self.config['compound'] = self.compound.val
self.config['debug'] = self.debug.val
self.config['strip_debug'] = self.strip_debug.val
self.config['split_debug'] = self.split_debug.val
exp.cache_size = self.cache_size.val
exp.export_lines = self.export_lines.val
exp.tbn_vecs = self.tbn_vecs.val
+ exp.compound = self.compound.val
exp.debug = self.debug.val
exp.strip_debug = self.strip_debug.val
exp.split_debug = self.split_debug.val