def set_action(context,item=None):
sprite_object = get_sprite_object(context.active_object)
if item == None:
item = sprite_object.coa_anim_collections[sprite_object.coa_anim_collections_index]
children = get_children(context,sprite_object,ob_list=[])
for child in children:
clear_pose(child)
if child.animation_data != None:
child.animation_data.action = None
if child.type == "ARMATURE" and item.name == "Restpose":
for bone in child.pose.bones:
bone.scale = Vector((1,1,1))
bone.location = Vector((0,0,0))
bone.rotation_euler = Euler((0,0,0),"XYZ")
bone.rotation_quaternion = Euler((0,0,0),"XYZ").to_quaternion()
if child.type == "MESH" and item.name == "Restpose":
child.coa_sprite_frame = 0
child.coa_alpha = 1.0
child.coa_modulate_color = (1.0,1.0,1.0)
#child["coa_slot_index"] = len(child.coa_slot)-1#child.coa_slot_reset_index
#print(child["coa_slot_index"])
elif not (child.type == "MESH" and item.name == "Restpose") and context.scene.coa_nla_mode == "ACTION":
action_name = item.name + "_" + child.name
action = None
if action_name in bpy.data.actions:
action = bpy.data.actions[action_name]
if action != None:
action.use_fake_user = True
if child.animation_data == None:
child.animation_data_create()
child.animation_data.action = action
context.scene.frame_set(context.scene.frame_current)
context.scene.update()
评论列表
文章目录