Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    Jul 2005
    Location
    Southwest Texas
    Posts
    3,699

    IK/FK snap / switch - how?

    I am getting back into rigging / animation in Blender and I can't find any tutorials about how to make IK / FK snap. Can anyone please point me to a tutorial about that or maybe explain how to accomplish it (or perhaps have a Py script where I can just change bone names and get it over with) ?

    Thanks beforehand
    Kot-in-Action Creative Artel - a factory of the awesome games! http://www.kot-in-action.com
    Steel Storm series - brilliant action/shooter/adventure games ! http://www.steel-storm.com



  2. #2
    Member Hadriscus's Avatar
    Join Date
    Apr 2012
    Location
    Massilia, France
    Posts
    1,333
    Hey hi,

    pitchipoy rig has it iirc (or was it rigify... I think they're the same now aren't they ?), you can check inside the rig generation script. On paper, IK to FK snapping is simple because you only need to copy the rotation values from the IK bones to the FK controllers. FK to IK is a little more involved in that you need to find the shoulder-elbow-hand plane, and place the pole vector somewhere on that plane, in alignment with the elbow.
    I have never made one in Blender so this is just theory, but it should apply.

    Hadrien
    Last edited by Hadriscus; 12-Oct-17 at 07:20.



  3. #3
    Member
    Join Date
    Jul 2005
    Location
    Southwest Texas
    Posts
    3,699
    The rig that comes with 2.79 is overly complex I don't need any facial bones, nor stretchy bones, nor complex spine. I wish there was an easy way to simplify it.
    Kot-in-Action Creative Artel - a factory of the awesome games! http://www.kot-in-action.com
    Steel Storm series - brilliant action/shooter/adventure games ! http://www.steel-storm.com



  4. #4
    Member Richard Culver's Avatar
    Join Date
    Feb 2007
    Location
    USA
    Posts
    2,405
    Just use the old rig. Go to Base/Basic Human Meta Rig. Has the same IK/FK stuff and looks like it also has the stretchy. But to be honest. Dude. You want that. Won't hurt you. Will reduce popping.

    Also the more advanced rig, you can just delete the facial bones before you generate the rig. Also should be noted you can build your own riggify rig with rig types piece by piece which might give you more control over what you want and don't want.

    Not a real big fan of self-rigging since there are so many great free rigs out there. And from my experience the new Riggify is one of the best.

    But if you really want to build your own rig I know it is possible. Just look around for some rigging tutorials.

    https://www.youtube.com/watch?v=rxF45UV1wU0

    https://www.youtube.com/watch?v=LNsqBuIg5_Y


    Last edited by Richard Culver; 12-Oct-17 at 11:54.



  5. #5
    Member Hadriscus's Avatar
    Join Date
    Apr 2012
    Location
    Massilia, France
    Posts
    1,333
    I am saying you should take a look at the script that generates it in order to replicate it in your own rig.



  6. #6
    You can look at this example :
    https://gist.github.com/dskjal/76a77...k_snap_easy-py

    Haven't tested tho.

    I've made a quick one recently,
    Using python you can make a vector from say the upperarm and scale it , that give you the pole position.
    But if the limb is straight the pole get positioned into the limbs and then is hard to grab, so this isn't perfect.

    I finally used helper bones (parented to limbs) to recover pole target position, kind of hackish but as I'm a failure at math and I needed a quick and dirty solution...



  7. #7
    I made an IK-FK and FK-IK snap script for UE4Tools. The UE4Tools rig is a single chain rig (instead of IK and FK separated) which led to a few problems, like being to unable to reset the FK rotation when switching to IK (if you reset the FK rotation you would get a snap because the IK constraint took in account the FK rotation). This means that the pole target will be a bit inaccurate when switching from FK to IK, but maybe not a huge issue. You could also reset the FK rotation on the next IK pose keyframe and have a nice blend between them. Ideally you would have a separate IK chain and FK chain though I think.

    The main setup was to make new pole targets (grabbing the thigh/upperarm bones, copying in edit mode, then disabling location lock and drag them out on the local x axis). These were set to be the new pole targets, then they were copied again and set to have the thigh/upperarm bones as parents. These new bones will be used for snapping FK to IK.

    The snapping itself is pretty easy:

    IK-FK
    1. Select the bones that should be keyed (depending on selected IK bone/s), for example left thigh, left calf and left poletarget if the left foot was selected.
    2. Insert LocRot keyframes.
    3. Set the value of the FK-IK switch to 1.000 and insert a keyframe. (bpy.context.selected_objects[0][IKDataPath] = 1.000 where IKDataPath is the data path for the FK-IK switch for the bone. Then bpy.context.selected_objects[0].keyframe_insert(data_path='["'+IKDataPath+'"]'))
    4. Go to the next frame and select the thigh/calf bones again, insert a keyframe with visual locrot. This will give the FK rotations you need.
    5. Set the FK-IK switch to 0.000 and insert a keyframe.

    FK-IK
    1. Set the FK-IK switch to 0.000 and insert a keyframe.
    2. Select the thigh/calf bones and insert LocRot keyframes. Deselect bones.
    3. Select the pole snap target (the pole target parented to thigh/upperarm), do Cursor to Selected. Deselect bones.
    4. Select the real pole target and do Selected to Cursor. Insert a LocRot keyframe. Deselect bones.
    5. Repeat the above method for the foot bone, set a 3D cursor there, then snap the feet IK control to it.
    6. Go to the next frame, set the FK-IK switch to 1.000 and insert a keyframe.
    (normally you would reset the transforms for the FK bones and insert a keyframe here, but in a single chain rig this will cause a snap because of the FK rotation influencing the IK bones).

    You can use this for snapping the cursor:
    Code:
    def SnapCursor(type):    for area in bpy.context.screen.areas:
            if area.type == 'VIEW_3D':
                ctx = bpy.context.copy()
                ctx['area'] = area
                ctx['region'] = area.regions[-1]
                if(type=="CursorToSelected"):
                    bpy.ops.view3d.snap_cursor_to_selected(ctx)
                if(type=="SelectedToCursor"):
                    bpy.ops.view3d.snap_selected_to_cursor(ctx)
    I don't really use this stuff myself though, I use IK for everything using the smoothed f-curve branch. But I may release it in the future as a fork of UE4Tools.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •