def length_update(self, context): """If the total time for animation is tweaked, FPS value is recalculated to keep the playback speed as close as possible to the resulting playback speed in the game engine. :param context: Blender Context :type context: bpy.types.Context """ active_object = context.active_object if active_object: if active_object.animation_data: action = active_object.animation_data.action if action: scs_root_object = _object_utils.get_scs_root(active_object) if scs_root_object: active_scs_animation = scs_root_object.scs_props.active_scs_animation scs_object_animation_inventory = scs_root_object.scs_object_animation_inventory animation = scs_object_animation_inventory[ active_scs_animation] _animation_utils.set_fps_for_preview( context.scene, animation.length, action.scs_props.anim_export_step, animation.anim_start, animation.anim_end, )
def active_scs_animation_update(self, context): """Update function for Active SCS Animation record on Objects. :param context: Blender Context :type context: bpy.types.Context :rtype: None """ active_object = context.active_object scs_root_object = _object_utils.get_scs_root(active_object) scene = context.scene # GET ARMATURE OBJECT armature = None if active_object.type == 'ARMATURE': armature = active_object else: children = _object_utils.get_children(scs_root_object) for child in children: if child.type == 'ARMATURE': armature = child break scs_object_anim_inventory = scs_root_object.scs_object_animation_inventory active_scs_anim_i = self.active_scs_animation if len(scs_object_anim_inventory) > active_scs_anim_i: active_scs_anim = scs_object_anim_inventory[active_scs_anim_i] start_frame = active_scs_anim.anim_start end_frame = active_scs_anim.anim_end length = active_scs_anim.length # set frame range properly _animation_utils.set_frame_range(scene, start_frame, end_frame) # set action to armature end properly set preview fps action = None if active_scs_anim.action in bpy.data.actions: action = bpy.data.actions[active_scs_anim.action] _animation_utils.set_fps_for_preview(scene, length, start_frame, end_frame) # ensure animation data block to be able to set action if armature.animation_data is None: armature.animation_data_create() armature.animation_data.action = action # set/reset action of current animation else: print('Wrong Animation index %i/%i!' % (active_scs_anim_i, len(scs_object_anim_inventory))) return None
def length_update(self, context): """If the total time for animation is tweaked, FPS value is recalculated to keep the playback speed as close as possible to the resulting playback speed in the game engine. :param context: Blender Context :type context: bpy.types.Context """ active_object = context.active_object if active_object and active_object.type == "ARMATURE" and active_object.animation_data: action = active_object.animation_data.action if action: _animation_utils.set_fps_for_preview( context.scene, self.length, self.anim_start, self.anim_end, )
def anim_range_update(self, context): """If start or end frame are changed frame range in scene should be adopted to new values together with FPS reset. """ active_object = context.active_object if active_object and active_object.type == "ARMATURE" and active_object.animation_data: action = active_object.animation_data.action if action: _animation_utils.set_frame_range(context.scene, self.anim_start, self.anim_end) _animation_utils.set_fps_for_preview( context.scene, self.length, self.anim_start, self.anim_end, )
def length_update(self, context): """If the total time for animation is tweaked, FPS value is recalculated to keep the playback speed as close as possible to the resulting playback speed in the game engine. :param context: Blender Context :type context: bpy.types.Context """ active_object = context.active_object if active_object: if active_object.animation_data: action = active_object.animation_data.action if action: scs_root_object = _object_utils.get_scs_root(active_object) if scs_root_object: active_scs_animation = scs_root_object.scs_props.active_scs_animation scs_object_animation_inventory = scs_root_object.scs_object_animation_inventory animation = scs_object_animation_inventory[active_scs_animation] _animation_utils.set_fps_for_preview( context.scene, animation.length, action.scs_props.anim_export_step, animation.anim_start, animation.anim_end, )
def active_scs_animation_update(self, context): """Update function for Active SCS Animation record on Objects. :param context: Blender Context :type context: bpy.types.Context :rtype: None """ active_object = context.active_object scs_root_object = _object_utils.get_scs_root(active_object) scene = context.scene # GET ARMATURE OBJECT armature = None if active_object.type == 'ARMATURE': armature = active_object else: children = _object_utils.get_children(scs_root_object) for child in children: if child.type == 'ARMATURE': armature = child break scs_object_animation_inventory = scs_root_object.scs_object_animation_inventory active_scs_animation = self.active_scs_animation if len(scs_object_animation_inventory) > active_scs_animation: active_animation = scs_object_animation_inventory[ active_scs_animation] animation_name = active_animation.name print('Animation changed to %r [%i].' % (animation_name, active_scs_animation)) # SET ACTION STRING action = armature.animation_data.action action_names = [] for act in bpy.data.actions: action_names.append(act.name) if animation_name in action_names: action = bpy.data.actions[animation_name] armature.animation_data.action = action active_object.data.scs_props.current_action = action.name # SET PREVIEW RANGE scene.use_preview_range = True print('CAUTION! --- DELAYED START UPDATE ISSUE --- (see the code)' ) # FIXME: If the start value is other than zero, # it gets only properly updated the second time an "SCS Animation" is hit in the list. For the first time it mysteriously # always gets the old 'anim_end' value. Test is on "multiple_animations_from_one_action.blend" file. print('scene.frame_preview_start:\t%i' % scene.frame_preview_start) print('active_animation.anim_start:\t\t%i' % active_animation.anim_start) start_frame = active_animation.anim_start scene.frame_preview_start = start_frame print('scene.frame_preview_start:\t%i' % scene.frame_preview_start) end_frame = active_animation.anim_end scene.frame_preview_end = end_frame # frame_range = action.frame_range # set_fps(scene, action, frame_range) # set_fps(scene, action, (active_animation.anim_start, active_animation.anim_end)) length = active_animation.length anim_export_step = action.scs_props.anim_export_step _animation_utils.set_fps_for_preview(scene, length, anim_export_step, start_frame, end_frame) else: print('Wrong Animation index %i/%i!' % (active_scs_animation, len(scs_object_animation_inventory))) return None
def active_scs_animation_update(self, context): """Update function for Active SCS Animation record on Objects. :param context: Blender Context :type context: bpy.types.Context :rtype: None """ active_object = context.active_object scs_root_object = _object_utils.get_scs_root(active_object) scene = context.scene # GET ARMATURE OBJECT armature = None if active_object.type == 'ARMATURE': armature = active_object else: children = _object_utils.get_children(scs_root_object) for child in children: if child.type == 'ARMATURE': armature = child break scs_object_animation_inventory = scs_root_object.scs_object_animation_inventory active_scs_animation = self.active_scs_animation if len(scs_object_animation_inventory) > active_scs_animation: active_animation = scs_object_animation_inventory[active_scs_animation] animation_name = active_animation.name print('Animation changed to %r [%i].' % (animation_name, active_scs_animation)) # SET ACTION STRING action = armature.animation_data.action action_names = [] for act in bpy.data.actions: action_names.append(act.name) if animation_name in action_names: action = bpy.data.actions[animation_name] armature.animation_data.action = action active_object.data.scs_props.current_action = action.name # SET PREVIEW RANGE scene.use_preview_range = True print( 'CAUTION! --- DELAYED START UPDATE ISSUE --- (see the code)') # FIXME: If the start value is other than zero, # it gets only properly updated the second time an "SCS Animation" is hit in the list. For the first time it mysteriously # always gets the old 'anim_end' value. Test is on "multiple_animations_from_one_action.blend" file. print('scene.frame_preview_start:\t%i' % scene.frame_preview_start) print('active_animation.anim_start:\t\t%i' % active_animation.anim_start) start_frame = active_animation.anim_start scene.frame_preview_start = start_frame print('scene.frame_preview_start:\t%i' % scene.frame_preview_start) end_frame = active_animation.anim_end scene.frame_preview_end = end_frame # frame_range = action.frame_range # set_fps(scene, action, frame_range) # set_fps(scene, action, (active_animation.anim_start, active_animation.anim_end)) length = active_animation.length anim_export_step = action.scs_props.anim_export_step _animation_utils.set_fps_for_preview(scene, length, anim_export_step, start_frame, end_frame) else: print('Wrong Animation index %i/%i!' % (active_scs_animation, len(scs_object_animation_inventory))) return None