From 0065c197c85cd249dbb4b72d6058a1fb265dea02 Mon Sep 17 00:00:00 2001 From: Daniel Salazar <zanqdo@gmail.com> Date: Mon, 30 Dec 2013 05:43:40 -0600 Subject: [PATCH] Animall addon: Add support for Surface objects Add support for simple point animation in meshes and lattices UI improvements for Shapekey animation --- animation_animall.py | 125 ++++++++++++++++++++++++++++++++----------- 1 file changed, 94 insertions(+), 31 deletions(-) diff --git a/animation_animall.py b/animation_animall.py index c331f5249..a7eb1ab69 100644 --- a/animation_animall.py +++ b/animation_animall.py @@ -19,10 +19,10 @@ bl_info = { 'name': 'AnimAll', 'author': 'Daniel Salazar <zanqdo@gmail.com>', - 'version': (0, 5), - "blender": (2, 63, 0), - 'location': 'Select a Mesh/Lattice/Curve: Tool Shelf > AnimAll panel', - 'description': 'Allows animation of mesh, lattice and curve data (Shape Keys, VCols, VGroups, UVs, Points, Radius, Tilt)', + 'version': (0, 6), + "blender": (2, 69, 7), + 'location': 'Select a Mesh/Lattice/Curve/Surface: Tool Shelf > AnimAll panel', + 'description': 'Allows animation of mesh, lattice, curve and surface data (Shape Keys, VCols, VGroups, UVs, Points, Radius, Tilt)', 'warning': '', 'wiki_url': 'http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Animation/AnimAll', 'tracker_url': 'http://projects.blender.org/tracker/index.php?'\ @@ -32,14 +32,6 @@ bl_info = { """------------------------------------------------------------------------- Thanks to Campbell Barton and Joshua Leung for hes API additions and fixes Daniel 'ZanQdo' Salazar - -Rev 0.1 initial release (animate Mesh points) -Rev 0.2 added support for animating UVs, VCols, VGroups -Rev 0.3 added support for animating Lattice points -Rev 0.4 added support for ShapeKey layer animation, removed support -for direct point animation since this new aproach is much stronger -and inline with the animation system -Rev 0.5 merged curve animation features from rotobezier and ported to new bmesh API -------------------------------------------------------------------------""" import bpy @@ -52,7 +44,7 @@ from bpy.props import * bpy.types.WindowManager.key_shape = BoolProperty( name="Shape", description="Insert keyframes on active Shape Key layer", - default=True) + default=False) bpy.types.WindowManager.key_uvs = BoolProperty( name="UVs", @@ -72,7 +64,7 @@ bpy.types.WindowManager.key_vgroups = BoolProperty( bpy.types.WindowManager.key_points = BoolProperty( name="Points", description="Insert keyframes on point locations", - default=True) + default=False) bpy.types.WindowManager.key_radius = BoolProperty( name="Radius", @@ -98,8 +90,9 @@ class VIEW3D_PT_animall(bpy.types.Panel): def poll(self, context): if context.active_object: return context.active_object.type == 'MESH'\ - or context.active_object.type == 'LATTICE'\ - or context.active_object.type == 'CURVE' + or context.active_object.type == 'LATTICE'\ + or context.active_object.type == 'CURVE'\ + or context.active_object.type == 'SURFACE' # draw the gui def draw(self, context): @@ -111,19 +104,30 @@ class VIEW3D_PT_animall(bpy.types.Panel): row = col.row() if Obj.type == 'LATTICE': + row.prop(context.window_manager, "key_points") row.prop(context.window_manager, "key_shape") elif Obj.type == 'MESH': + row.prop(context.window_manager, "key_points") row.prop(context.window_manager, "key_shape") - row.prop(context.window_manager, "key_uvs") row = col.row() row.prop(context.window_manager, "key_vcols") row.prop(context.window_manager, "key_vgroups") + row = col.row() + row.prop(context.window_manager, "key_uvs") elif Obj.type == 'CURVE': row.prop(context.window_manager, "key_points") + #row.prop(context.window_manager, "key_shape") + row = col.row() row.prop(context.window_manager, "key_radius") + row.prop(context.window_manager, "key_tilt") + + elif Obj.type == 'SURFACE': + row.prop(context.window_manager, "key_points") + row.prop(context.window_manager, "key_shape") row = col.row() + row.prop(context.window_manager, "key_radius") row.prop(context.window_manager, "key_tilt") row = col.row() @@ -132,19 +136,22 @@ class VIEW3D_PT_animall(bpy.types.Panel): row = layout.row() row.operator('anim.clear_animation_animall', icon='X') - if Obj.type != 'CURVE' and context.window_manager.key_shape: + if context.window_manager.key_shape: ShapeKey = Obj.active_shape_key + ShapeKeyIndex = Obj.active_shape_key_index split = layout.split() row = split.row() - if ShapeKey: + if ShapeKeyIndex > 0: row.label(ShapeKey.name, icon='SHAPEKEY_DATA') row.prop(ShapeKey, "value", text="") row.prop(Obj, "show_only_shape_key", text="") + elif ShapeKey: + row.label('Can not key on Basis Shape', icon='ERROR') else: - row.label('No active ShapeKey', icon='INFO') + row.label('No active Shape Key', icon='ERROR') class ANIM_OT_insert_keyframe_animall(bpy.types.Operator): @@ -175,9 +182,13 @@ class ANIM_OT_insert_keyframe_animall(bpy.types.Operator): Data = Obj.data if context.window_manager.key_shape: - if Obj.active_shape_key: - for Point in Obj.active_shape_key.data: - Point.keyframe_insert('co') + if Obj.active_shape_key_index > 0: + for Vert in Obj.active_shape_key.data: + Vert.keyframe_insert('co') + + if context.window_manager.key_points: + for Vert in Data.vertices: + Vert.keyframe_insert('co') if context.window_manager.key_vgroups: for Vert in Data.vertices: @@ -202,16 +213,22 @@ class ANIM_OT_insert_keyframe_animall(bpy.types.Operator): if context.mode != 'OBJECT': Mode = not Mode bpy.ops.object.editmode_toggle() + + Data = Obj.data if context.window_manager.key_shape: - if Obj.active_shape_key: + if Obj.active_shape_key_index > 0: for Point in Obj.active_shape_key.data: Point.keyframe_insert('co') + + if context.window_manager.key_points: + for Point in Data.points: + Point.keyframe_insert('co') if Mode: bpy.ops.object.editmode_toggle() - if Obj.type == 'CURVE': + if Obj.type == 'CURVE' or Obj.type == 'SURFACE': Mode = False if context.mode != 'OBJECT': Mode = not Mode @@ -219,24 +236,42 @@ class ANIM_OT_insert_keyframe_animall(bpy.types.Operator): Data = Obj.data + # run this outside the splines loop (only once) + if context.window_manager.key_shape: + if Obj.active_shape_key_index > 0: + for CV in Obj.active_shape_key.data: + CV.keyframe_insert('co') + try: # in case spline has no handles + CV.keyframe_insert('handle_left') + CV.keyframe_insert('handle_right') + except: pass + for Spline in Data.splines: if Spline.type == 'BEZIER': + for CV in Spline.bezier_points: + if context.window_manager.key_points: CV.keyframe_insert('co') CV.keyframe_insert('handle_left') CV.keyframe_insert('handle_right') + if context.window_manager.key_radius: CV.keyframe_insert('radius') + if context.window_manager.key_tilt: CV.keyframe_insert('tilt') elif Spline.type == 'NURBS': + for CV in Spline.points: + if context.window_manager.key_points: CV.keyframe_insert('co') + if context.window_manager.key_radius: CV.keyframe_insert('radius') + if context.window_manager.key_tilt: CV.keyframe_insert('tilt') @@ -276,8 +311,12 @@ class ANIM_OT_delete_keyframe_animall(bpy.types.Operator): if context.window_manager.key_shape: if Obj.active_shape_key: - for Point in Obj.active_shape_key.data: - Point.keyframe_delete('co') + for Vert in Obj.active_shape_key.data: + Vert.keyframe_delete('co') + + if context.window_manager.key_points: + for Vert in Data.vertices: + Vert.keyframe_delete('co') if context.window_manager.key_vgroups: for Vert in Data.vertices: @@ -294,17 +333,31 @@ class ANIM_OT_delete_keyframe_animall(bpy.types.Operator): for Data in VColLayer.data: Data.keyframe_delete('color') - if Mode: bpy.ops.object.editmode_toggle() if Obj.type == 'LATTICE': + + Mode = False + if context.mode != 'OBJECT': + Mode = not Mode + bpy.ops.object.editmode_toggle() + + Data = Obj.data + if context.window_manager.key_shape: if Obj.active_shape_key: for Point in Obj.active_shape_key.data: Point.keyframe_delete('co') + + if context.window_manager.key_points: + for Point in Data.points: + Point.keyframe_delete('co') + + if Mode: + bpy.ops.object.editmode_toggle() - if Obj.type == 'CURVE': + if Obj.type == 'CURVE' or Obj.type == 'SURFACE': Mode = False if context.mode != 'OBJECT': Mode = not Mode @@ -312,6 +365,16 @@ class ANIM_OT_delete_keyframe_animall(bpy.types.Operator): Data = Obj.data + # run this outside the splines loop (only once) + if context.window_manager.key_shape: + if Obj.active_shape_key_index > 0: + for CV in Obj.active_shape_key.data: + CV.keyframe_delete('co') + try: # in case spline has no handles + CV.keyframe_delete('handle_left') + CV.keyframe_delete('handle_right') + except: pass + for Spline in Data.splines: if Spline.type == 'BEZIER': for CV in Spline.bezier_points: @@ -343,7 +406,7 @@ class ANIM_OT_delete_keyframe_animall(bpy.types.Operator): class ANIM_OT_clear_animation_animall(bpy.types.Operator): bl_label = 'Clear Animation' bl_idname = 'anim.clear_animation_animall' - bl_description = 'Clear all animation' + bl_description = 'Delete all keyframes for this object' bl_options = {'REGISTER', 'UNDO'} # on mouse up: @@ -372,4 +435,4 @@ def unregister(): pass if __name__ == "__main__": - register() + register() \ No newline at end of file -- GitLab