X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_animation.py;h=45eff8f9d09e80cdbe8aa0d0a18520f8db0559fd;hb=HEAD;hp=90d5d4125197d0557741febe92eb75d311181778;hpb=42ae18b7a9dc13a72bf421e564f02829d4bdd5be;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_animation.py b/blender/io_mspgl/export_animation.py index 90d5d412..ba83cd49 100644 --- a/blender/io_mspgl/export_animation.py +++ b/blender/io_mspgl/export_animation.py @@ -2,13 +2,8 @@ import math import os class AnimationExporter: - def __init__(self): - self.export_all = False - self.collection = True - self.looping_threshold = 0.001 - - def export_to_file(self, context, out_fn): - if self.export_all: + def export_to_file(self, context, out_fn, *, export_all=False, collection=True, looping_threshold=0.001): + if export_all: actions = [] for o in context.selected_objects: if not o.animation_data: @@ -24,12 +19,12 @@ class AnimationExporter: resources = {} for a in actions: - resources[a.name+".anim"] = self.export_animation(context, a) + resources[a.name+".anim"] = self.export_animation(context, a, looping_threshold=looping_threshold) path, base = os.path.split(out_fn) base, ext = os.path.splitext(base) - if self.collection: + if collection: from .datafile import Resource dummy = Resource("dummy", "dummy") dummy.references = list(sorted(resources.values(), key=lambda r: r.name)) @@ -40,17 +35,17 @@ class AnimationExporter: 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) resource.write_to_file(out_fn) - def export_animation(self, context, action): + def export_animation(self, context, action, *, looping_threshold=0.001): from .animation import create_animation_from_action - anim = create_animation_from_action(context, action, looping_threshold=self.looping_threshold) + anim = create_animation_from_action(context, action, looping_threshold=looping_threshold) from .datafile import Resource, Statement resource = Resource(action.name+".anim", "animation")