260 likes | 530 Views
Implementing Inverse Kinematics and a Walking System. Ideas presented by Rune Skovbo Johansen. Inverse Kinematics. Local inverse kinematics control limbs such as legs and arms. Two or more bones per limb – primary focus will be two bones, such as arms and legs in humanoids.
E N D
ImplementingInverse Kinematics and a Walking System Ideas presented by Rune Skovbo Johansen
Inverse Kinematics • Local inverse kinematics control limbs such as legs and arms. • Two or more bones per limb – primary focus will be two bones, such as arms and legs in humanoids. • IK in legs can be used to adapt walking animations to various terrain, speed and turning. • IK in arms can be used to point at specific points, and to touch/grab specific objects. • Primary focus on IK in legs.
Inverse Kinematics in Legs • The inverse kinematics works locally on a limb, such as a leg, from hip to ankle, joined by the knee. • Here, the hip is the root. • Any bones extending from the IK limb (such feet or hands) could also be referred to as the trailing bones. • The IK doesn’t say anything about how the trailing bones move – it is a problem in itself!
Adaptive Walking Adapting walking to the terrain and situation is more than just inverse kinematics: • Step positions (step markers) must be put on the ground, depending on path, speed, and terrain. They determine where the feet land. • Anatomy of creature must be taken into account: • Number of legs • Placement of legs on body • Order in which the legs move (think spiders and bugs) • The trajectory of the ankles must be interpolated between step markers. • The alignment of the feet must be interpolated as well. (Movement of trailing bones is not determined by IK!)
Analysing terrain • The terrain must be analysed to find suitable spots for step markers. • This can be done using raycasts (support in engine?) • ...or another method to easily examine and analyse geometry under the feet. • Character’s current velocity and rotational speed is also taken into account to predict a good step marker position.
Ankle Trajectories • Global position of ankle (relative to ground) is recorded from keyframe data for whole walk-cycle. • Ankle trajectory is deduced from this. • The trajectories are stretched and bended according to placement of step markers.
Foot alignment • Ankle trajectory is obtained from global position in key-frame data (relative to ground) • Alignment of feet (or trailing bones in general) cannot be deduced this way. • Local angles must be maintained (to some extent) from the key-frame data.
Foot alignment • When on a step marker, a foot (trailing bones) must be transformed according to the step marker’s local space. • When between step markers, a foot must be aligned according to local angles (from key-frame data). • The system must know at which points the foot is touching the ground in the key-framed walk-cycle. • The key-framed walk-cycle must be enriched with this data.
Enriched walk-cycle with data (step-nodes) about at which points the feet are touching the ground. Must be provided by the animator.
The step-node starts having influence on the foot alignment here, starting at 0%.
The step-node has 100% influence on the foot alignment here.
The step-node still has 100% influence on the foot alignment here.
The step-node is back to 0% influence on the foot at this point.
Hip Positions • Since the positions of the feet are unpredictable when adapted, the positions of the hips must be adjusted according to the feet. • Example: The feet are so far from the hips that the legs are not long enough. The positions of the hips must be adjusted. • Moving the hips just close enough is not good, as it gives a 100% stretched leg, which give poor movement in walk-cycles! • The desired hip-ankle distance must be found in the key-framed data and applied. A solution that fits both legs as good as possible is preferred. • Alternatively, local angles in hips and knees could be sought maintained, but this cannot be done without iterative approximation.
The Actual Inverse Kinematics • When ankle-position and hip-position is found, the inverse kinematics are straightforward to apply for a two-bone limb, such as a leg. • It can be solved exact. • The knee points in same direction as it already did. 100% straight legs should be prohibited, but workarounds can be implemented anyway.
Walking Speed • Characters that can walk with different speeds are more life-like. • Not just walk or run. • E.g. comes gradually to a stop, etc. • Makes U-turns much more realictic. • The system must support adjustments in speed without requiring separate walk-cycles for each speed.
Adjusting Walking Speed • A creature can double its speed in two different ways: • Take twice as long steps(double step distance) • Take steps twice as fast(double step frequency) • What do humans do...? • Answer: A little of both! • Sqrt(2) longer steps • Sqrt(2) times as fast • (Based on own unscientific tests involving walking a fixed distance at various speeds with a stop-watch while counting steps!)
Adjusting Walking Speed • Engine already supports blending several walk-cycles – this can be done according to character’s current speed. • Result of blending can be used as the basis of the adapted walking. • The enriched data (step-nodes) must be taken into account in the blending though.
Additional Areas of Interest • Inverse kinematics solutons for arms • Extended automated walking system
IK Solutions for Arms • IK in arms can be used to point at specific points, and to touch/grab specific objects. • I haven’t thought as much about this. • Touching/grabbing would often require that upper torso moves as well (bending down, reaching out) for humans. • How could a generic flexible solution be implemented? Perhaps more conventional IK solutions.
Extended AutomatedWalking System • Ability to analyse terrain and choose most suitable keyframed animation, based on step-node data in each. • If animations ”walk straight”, ”walk down”, and ”walk up” exist, most suitable is chosen (or blended between) based on terrain. • Ability to treat hands as additional feet in some animations to enable e.g. climbing.
Engine Features I Need • Query bone rotations in local space (at any point in time in animation). • Query bone positions and alignment in model space (at any point in time in animation). • Adjust bone rotations/alignments. • Adjust speed of animations. • Make raycasts or similar onto geometry.
Content I Need • Several different models with standing, walking and running animations. • Some models with skeletons with realistic human proportions. • Some models that are not humanoid at all. (Pets, spiders, bugs, things with more than two legs.)