import mathutils
class ObjectExporter:
- def compute_bounding_sphere(self, obj):
- 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
-
- return center, radius
-
def collect_object_lods(self, obj):
lods = [obj]
lods += sorted([c for c in obj.children if c.lod_for_parent], key=(lambda l: l.lod_index))
if material.render_mode!='EXTERNAL':
tech_name = material.name+".tech"
if tech_name not in resources:
+ material = Material(material)
material_export.export_technique_resources(material, resources)
resources[tech_name] = material_export.export_technique(material, resources)
elif "stub.tech" not in resources:
obj_res = Resource(obj.name+".object", "object")
statements = obj_res.statements
- center, radius = self.compute_bounding_sphere(obj)
+ from .util import compute_bounding_sphere
+ center, radius = compute_bounding_sphere([v.co for v in obj.data.vertices])
statements.append(Statement("bounding_sphere_hint", *center, radius))
prev_mesh = None