Skip to content

tomcatmew/IK_example

Repository files navigation

IK_example (CCD Jacobian FABRIK)

Practice for some popular IK implemntaion in OpenGL 2.0
Make sure you build in Release Mode

My understanding of speed&performance for different IK methods May be different based on how many joints you have

Fast ←------------------------→ Performance 
CCD            FABRIK           Jacobian

Installation guide for Windows user (Visual Studio)

  1. git submodule update --init.
  2. download glfw pre-compiled library and put the uncompressed files under 3rd_party/libglfw.
    • alternatively you can build by yourself, but make sure the include and lib are under 3rd_party/libglfw
  3. run cmake -S . -B build under /0_ikccd or /1_skeleton_ik or /2_ik_jacobian or /3_FABRIK folder.
  4. /***/build/***.sln will be the Visual Studio solution files, open it and build in Release mode.

Control

  1. Using W S A D control the horizontal movement of the target
  2. Using E Q control the vertical movement of the target
  3. Using 1 2 3 4 switch between four different target IK
  4. Using Hold ALT + Left Click control the camera
  5. Using Scroll up/down control the camera zoom in/out

TODO

  • CCD
    • Basic
    • Hinges (Constraint of rotation axis)
    • Limits (Constraint of rotation angle)
  • FABRIK
  • Jacobian
    • Jacobian Transpose
    • Jacobian Inverse

CCD IK with Constraints(0_ikccd)

Constraints are on first 3 joints. Green joint only can rotate along local Y axis,
Red joints only can rotate along local X axis, with constraint of Euler degree between -90 , +90 degrees.
All IK implementation using a custom 3D struct built by myself
No external library for 3D object

title

Skeleton IK (1_skeleton_ik)

Applying the CCD IK on rig bones

Local to world coordinates. The dfm2::CRigBone is the bone structure developed by Prof.Umetani. We must be careful when dealing with the IK in world space because we must convert the rotation to local space.

By using quaternion, the process will be straightforward to compute.

$q_{local} = q_{parent}^{*}(q_{increment}q_{world})$


title

Jacobian Transpose (2_ik_jacobian)

Using Jacobian Transpose and analytical method to compute the Jacobian Matrix
Currently it only rotates along Z axis, I'm working on adding X and Y axis rotation
In 2D case, every bone's rotation axis is always the Z axis (0,0,1), but in 3D case each bone's rotation axis will change based on parent's bone
Analytical method formula

$J=\alpha_i \times (e-r_i)$

J = jacobian
a = rotation axis
e = end effector position
r = joint position

I set a small number of maxmium iteration per frame, so you can clearly see how the joints moving with slow speed

jacobian

FABRIK (3_FABRIK)

No constraints applied

fabrik
Practice for some popular IK implemntaion in OpenGL 2.0 Copyright Yifei Chen

About

CCD IK, Jacobian IK and FABRIK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published