Implementation of Reverse dynamics (ik) of bone Animation

Source: Internet
Author: User

Http://multi-crash.com /? P = 45

Inverse Dynamics: inverse kinematics, IK for short. To put it simply, the azimuth of the child is obtained by the relative transformation of the Parent and Child bones, which is called forward dynamics (forward ).
Kinematics, FK), while IK is the first method to determine the Child Bone's orientation and reverse export its inheritance chain's n-level parent bone's orientation.

The most common application of IK in games is foot.
Placement: When the role is standing on an uneven surface (steps, slopes), it automatically adjusts the height of the two legs (of course, it also affects the posture of the calf and thigh) it seems that the foot is actually "stepping" on the ground, rather than floating in the air or falling below the ground.

Without Ik, you can create different role actions for all possible terrain fluctuations. The workload is unimaginable. Another application is games such as the Prince of Persian and tomb shadows. The protagonist often needs to jump forward and seize something like a flagpole. The bounce ability of the protagonist is usually fixed, and the game cannot require the player to control the role to jump in a specific precise direction at a specific location. Generally, it allows an error range. Then the problem arises. When the main character flies near the flagpole, the flagpole may be on the top of the head, under the shoulder, or left or right, at this time, ik can extend the protagonist's hands to the flagpole, no matter where it is (of course, physically
Possible, that is, within physiological distance ).

How to Implement ik? The easiest thing to think of is solving the equation, but this usually produces an infinite number of solutions. Experiment with your own body. Even if your hands and shoulders do not move, the arm and arm can still rotate freely and flexibly, not to mention ik involving more than 2 levels of bones. The most common ik implementation method is CCD (Cyclic
Coordinate
Descent is an iterative method. In most cases, the position of the target skeleton converges to the specified position. As you can see, even if you do not write a program, it is easy to verify the effectiveness of this algorithm by taking a few matchsticks.

For all bones affected by Ik, perform iterative operations in the order from child bones to parent Bones: rotate the current skeleton so that the link between the current skeleton position and the target skeleton points to the IK target position. Since all bones start ik computing from a specific State, the results are also relatively stable. Generally ~ After 10 iterations, We can get good results.

So far, it is no longer a problem to reach the specified position for the specified skeleton, but this is usually not enough. If it is a human skeleton, not all joints can be rotated in any direction, so we must limit the rotation of the skeleton. For example, the elbow actually has only one axis of freedom, and cannot bend backward. Generally, skeleton animation uses the Quaternary element to indicate rotation, and the angle limitation of the joint can only be expressed by the Euclidean angle. Therefore, each time the skeleton is calculated during iteration, it is converted to the Euclidean angle, check whether the limit value is exceeded. If the limit value is exceeded, it needs to be corrected and then converted back to the Quaternary element for calculation.

After the rotation angle is limited, the result looks good. Note that when all the bones that require ik control are in a straight line and the IK target is in this line, for example ), the algorithm will fail, because no matter how many iterations, each skeleton will think that it does not need to be rotated. Therefore, if you find that the skeleton chain is "very straight", you can add some slight rotation to any direction allowed by the skeleton; or you can simply disable full "Straighten" in the restriction angle data of the skeleton ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.