+ p1 = max(((v.co, v.co.length) for v in obj.data.vertices), key=lambda x:x[1])[0]
+ p2 = max(((v.co, (v.co-p1).length) for v in obj.data.vertices), key=lambda x:x[1])[0]
+ center = (p1+p2)/2
+ radius = (p1-p2).length/2
+ for v in obj.data.vertices:
+ d = v.co-center
+ if d.length>radius:
+ center += d*(1-radius/d.length)/2
+ radius = (radius+d.length)/2
+
+ out_file.write("bounding_sphere_hint", center[0], center[1], center[2], radius)
+
+ prev_mesh = None
+ prev_tech = (None, None)
+ for i, l in enumerate(lods):
+ if i>0:
+ out_file.begin("level_of_detail", i)
+ objs = [l]
+
+ if i==0 or l.data.name!=prev_mesh:
+ mesh = self.export_object_mesh(context, out_file, l, objs, progress)
+ prev_mesh = l.data.name
+
+ same_tech = True
+ mat = None
+ if l.material_slots and l.material_slots[0].material:
+ mat = l.material_slots[0].material.name
+ if mat!=prev_tech[1]:
+ same_tech = False
+ if self.external_tech and l.technique!=prev_tech[0]:
+ same_tech = False
+ if i==0 or not same_tech:
+ self.export_object_technique(l, mesh, out_file, i)
+ prev_tech = (l.technique, mat)
+
+ if i>0:
+ out_file.end()
+
+ def export_object_mesh(self, context, out_file, lod, objs, progress):