Flip Animation Add-On for Mirroring Keyframes in Blender

Posted by on in Development-Blog
  • Font size: Larger Smaller

After wasting a lot of time when flipping Blender animations made for left side to the right and vice versa, I decided to write an add-on doing it automatically. Have you ever been annoyed about copy & paste X-flipped pose frame by frame? See the video tutorial below how to solve this problem in your project.

Blender allows you to copy poses and paste them as X-flipped Pose within one frame provided your bone names conform to the naming convention. This is nice but when animating a run cycle and you have set up the first half of it, you don't want to copy and paste frame by frame.

[UPDATE:]

I found some problems with newer Blender versions 2.6.3-2.6.6a but I'm currently too busy to fix this. See the GitHub repository for the latest version.

See how to solve the problem with the help of this little add-on called Flip Animation (download here). Tip use 720p quality and full screen mode viewing.

  • The first part (≈ 90 seconds) shows how to use it.
  • The second part contains more details about how to install it, some background information about the implementation and hints for trouble shooting.

View directly on YouTube or Vimeo (opens new window / tab)

 

Feature Summary

Append Mode

In Append Mode all frames within the specified range are copied and the flipped keyframes are appended starting at end frame + 1

If Append Mode is not checked, Flip Animation mirrors the whole action overwriting the existing keyframes with a flipped version

Operates on the current action of the active armature.

Checks if all preconditions are met (hope so)

Installable via user / preferences / add-on

 

Not (Yet) Implemented

I was thinking about a Select Mode: Consider only those bones that are selected including their counterparts.

Pros:

  • Nice to exclude some bones from mirroring like the hair for example, which looks more natural if its swinging is modelled manually

Cons:

  • Questionable, if this will be used intensively
  • Not yet a final idea to implement it

 

Troubleshooting

  • You have to be in pose mode to see the Flip Animation panel
  • If have more than one armature in your scene, Flip Animation operates on the active armature only
  • Check that your bones conform to Blender's bone naming conventions. That means suffix _ or . and then R / L, r / l, right / left, Right / Left. Alternatively you can use them as prefix in similar way.
    Examples: Hand_R, Hand.r, Hand.Right, … or R_Hand, r.Hand, Right.Hand
  • Does the current keying set contain all relevant channels? For example check that you selected LocRotScale if your keyframes define location, rotation and scaling changes
  • If the start or end frame is outside of the defined range of the action, the add-on shows a warning messages in the status field of the info menu
  • Note that in append mode all existing keyframes within the range needed for appending, are overwritten.
    If we for example specify the range  1-5 all frames between 6 and 10 are deleted and the flipped keyframes are inserted instead
  • As the code relies on the Blender operators for copy pose and Past X-Flipped Pose it needs some preconditions met, especially regarding Keying Sets.
    • There is a button in Timeline View to enable Automatic Keyframe Insertion for Objects And Bones. This little red recording icon. This needs to be enabled. If it's deactivated, a warning message shows up.
    • The same applies for other button right to it called Automatic Keyframe Insertion Using Active Keying Set Only. I decided to make it mandatory because if not, the results might be pretty weird and analysis isn't that easy.
    • The keying set to use for inserting and deleting keyframes set right here, should fit the needs of your action. In most cases Available should be a good choice. If you have keyframes containing Location and Rotation values but have configured Location only as active keying set, pasting will not consider your rotation keys.
  • Sometimes pasting a pose X-flipped leads to kind of weird results. I ran into this occasionally already before I developed the add-on and noticed some issues within the quaternions as the inversion did not perform right and I found myself editing signs of quaternions. Maybe this is solved in the meantime. If you have this problem at one single bone, just modify the rotation slightly and it disappears in many cases.
  • Another issue is bone roll. If you have for example a RootIK bone with let's say a bone roll of 90°, translating it to the right results in a change of the Z coordinate in positive direction. But mirroring keeps the Z coordinate although its sign should be inverted in this case. This is because only X coordinates are affected.
    If you see strange effects on partial bones, check whether they really behave as expected i.e. transforming along X results in a changed X coordinate and nothing else. If not try to set the bone roll to 0 (edit mode / Properties shelf / Transform / Roll). But this can affect existing actions relying on your previous bone roll value != 0. So take care of testing everything., you have to fix this manually after mirroring.
  • I have tested it on Mac OSX 10.7 with Blender 2.58 and on Linux with Blender 2.6.6. On Mac OSX I ran into problems with 2.6.3 and 2.6.6 (s. my the update note above).
  • You can download my really ugly (but working :-) SimpleRig.blend to check if it is basically working in your environment.
  • If you want to have debug information in the console, set debug_output = True in FlipAnimation.py. On MacOS and Linux you need to start Blender from terminal. Load your modified FlipAnimation.py in a script window and press Run Script

 

Other solutions

I just finished the add-on, wrote the blog made the video and then it happened: I stumbled upon this forum thread at blender Artists quick and lazy script to mirror a walk cycle. When you scroll down you see a post by user mishurov where he did a similar thing. If I had found that before I would have saved the work as it turned out that there is new version 2.0 for download at Walk Cycle Mirror 2.0. It's a slightly different approach under the hood but similar in the results and the Author (Alexander Mishurov) seems to have done a good job (I have not yet installed it but looked at the code).

Anyway, it was fun to write an add-on and I won't miss it :)

 

Submit to FacebookSubmit to TwitterSubmit to LinkedIn
Rate this blog entry:

Comments

  • CG Monday, 11 March 2013

    exactly what i need

    thanks for sharing :-)

  • Panduaji Tuesday, 12 March 2013

    Great

    It's cool dude, i will try it. thank you

  • Maciej Szczesnik Tuesday, 16 April 2013

    Thanks a lot!

    This add-on should be a standard in Blender. It saves a lot of work.

    Reply Cancel
  • Kay Tuesday, 16 April 2013

    Thanks :)

    I plan to supply it to blender.org ASAP

  • Maciej Szczesnik Friday, 19 April 2013

    I have found some problems though

    Your add-on has some problems with animations that have key frames in every frame. Try to make a stationary "idle" animation with just hips moving up and down (and IK for legs). Then bake it with the Bake Action command, select to remove the constraints from action. Then try to run your add-on on it, you should observe lot's of jittering after the animation is flipped.

  • Kay Friday, 19 April 2013

    Re: I have found some problems though

    Maybe this related to the bone roll problem which is not solveable as the internal operator behaves that way. Did you try out what happens if you select the affected bones (which have key frames defined) and perform the copy and paste X-flipped process manually? I had this jittering in some situations with bone roll != 0° (or was should it be 90?). I have never used baking before as it is not recommended for my game engine (Unity) so I have no experience with it.

  • robik Sunday, 23 June 2013

    Support for latest blender

    It would be nice if you could provide support for Blender 2.67 too.

  • Kay Monday, 08 July 2013

    Re: Support for latest blender

    I tried to figure out what is wrong with it and posted in some forums, but have not yet an idea what happens. Pretty annoying :-( I will give it a another chance this summer.

  • Konstantin Dmitriev Wednesday, 25 June 2014

    RE:Re: Support for latest blender

    There is a modification of the script that works with 2.70 - https://github.com/morevnaproject/FlipAnimation
    ^__^

    Reply Cancel
  • Kay Thursday, 26 June 2014

    RE: Support for latest blender

    Thanks a lot :D Works fine, I merged it into my master branch

Leave your comment

Guest Saturday, 30 August 2014

Additional information