X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_animation.py;h=3f174e549ba8d616542314e27a7cc36830ebae29;hb=160293feec7b0b976856685153cd24c7f1ce9492;hp=0d72edb4d5eed4894e1df575e8a5b396213ab158;hpb=569abc900f42d8e7b70520e2c9ef8a5547878266;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_animation.py b/blender/io_mspgl/export_animation.py index 0d72edb4..3f174e54 100644 --- a/blender/io_mspgl/export_animation.py +++ b/blender/io_mspgl/export_animation.py @@ -30,36 +30,30 @@ class AnimationExporter: base, ext = os.path.splitext(base) if self.collection: - from .datafile import Statement - with open(os.path.join(path, base+".mdc"), "w") as out_file: - for r in resources.values(): - st = Statement("animation", r.name) - st.sub = r.statements - st.write_to_file(out_file) + from .datafile import Resource + dummy = Resource("dummy", "dummy") + dummy.references = list(sorted(resources.values(), key=lambda r: r.name)) + dummy.write_collection(os.path.join(path, base+".mdc"), exclude_self=True) else: for r in resources.values(): - with open(os.path.join(path, r.name), w) as out_file: - for s in r.statements: - s.write_to_file(out_file) + r.write_to_file(os.path.join(path, r.name)) else: anim_data = context.active_object.animation_data if not anim_data: - raise Exception("Object has no animation data") + raise Exception("Object {} has no animation data".format(context.active_object.name)) if not anim_data.action: - raise Exception("No active action") + raise Exception("Object {} has no active action".format(context.active_object.name)) resource = self.export_animation(context, anim_data.action) - with open(out_fn, "w") as out_file: - for s in resource.statements: - s.write_to_file(out_file) + resource.write_to_file(out_fn) def export_animation(self, context, action): from .animation import create_animation_from_action anim = create_animation_from_action(context, action, looping_threshold=self.looping_threshold) from .datafile import Resource, Statement - resource = Resource(action.name+".anim") + resource = Resource(action.name+".anim", "animation") components = [(0, "location", "position"), (1, "rotation_euler", "euler"), (2, "scale", "scale")] coords = "xyz"