## Skeletons

Skeleton is a special purpose deformation lattice object. The idea behind skeletons is quite straightforward: a skeleton is a simple object which is connected to more complex objects. When the skeleton is modified, the attached objects are modified accordingly.

The fact that it is much easier to modify these skeletons than the actual (often quite complex) target objects makes skeletons a powerful animation tool. However, due to generality of the lattice mapping system of Realsoft 3D, skeletons can also be used in various other tasks.

In this tutorial we will demonstrate how to use skeletons to create a walking human body. We will first create a hierarchical human skeleton, then attach the actual model to the skeleton and finally animate the skeleton to take a couple of steps using the key framer.

### Creating a skeleton

Tutorial level: Beginner/Medium

Example project: 'tutorprojects\animation\skeleton\body'.

The Skeleton tool creates a skeleton object through the given joint positions. You can also define minimum and maximum constraint angles while drawing the skeleton. Each joint of a skeleton has six angle constraints, which limit rotations of the bones around the joint.

To create a skeleton representing a leg:

 1. Activate the Skeleton tool from the Modifier tool tab. 2. Take a side view. Click the first point at the hip bone. Now, move the mouse towards the knee but don't fix the position for the knee yet. We will have to define proper constraints for the thighbone first. Rotate the mouse upwards so that it represents the knee in its uppermost position. Then move the mouse to the opposite direction so that it shows the position of the knee in its back position. Then move the mouse to a position between the two extreme angles and to a suitable distance (the length of a thighbone) and fix the second point (the knee) by clicking the mouse. 3. Then move the mouse towards the ankle and repeat the steps above in order to define constraints for the shinbone as well. A skeleton representing a simple leg

4. Next define a bone from the ankle to the tip of the toes (we do not create toe bones this time) with appropriate constraints. Then select Accept from the pop-up menu to terminate the skeleton creation.

Once created, skeletons can be modified in various ways.

For example, to move a joint of the skeleton created:

 1. Select the skeleton and enter the edit mode (as always, you can enter the edit mode either by pressing the space bar, selecting the 'Edit' compass menu, or clicking the 'Edit' tool in the tool control bar). 2. Drag a joint to move it. While you move the mouse, not only the dragged joint but also all the other joints of the leg become modified. However, bone lengths remain unchanged. This method of modifying skeletons is called 'Inverse Kinematics'. Inverse Kinematics is the default tool for the joints and therefore it is automatically started when you drag any joint of the skeleton. Skeleton in the edit state. Drag a joint to apply inverse kinematics.

In addition to inverse kinematics, there are a number of other useful tools for editing skeletons. To apply 'Forward Kinematics' to a joint:

1. Select the desired joint (not the first one).

 2. When a skeleton is selected, the tool control bar shows you various skeleton specific tools. Select the 'FK' tool and click the mouse twice in the view window to modify the selected joint angles. FK tool

To modify the length of a bone:

1. Select a joint

2. Click the 'Length' tool in the tool control bar and enter two points through the view window to adjust the position of the selected joint along the previous bone.

You can add new joints to a skeleton any time by using the Add Joint tool. For example, let's assume we need to add a new joint to the foot bone representing a toe of the leg:

 1. Select the leg and activate the New Joint tool. 2. Drag the mouse over the skeleton. This outlines a small 'cross mark' which indicates the position of the new joint. When a desired position is found, release the mouse to create the new joint. Add Joint tool

### Creating hierarchical skeletons

A hierarchical skeleton is a skeleton, which contains one or more child skeletons. A good example of a hierarchical skeleton system is an arm and its five sub skeletons, the fingers. Another example is a spine and its two sub skeletons, the legs.

Next we will create a hierarchical skeleton roughly representing a human body.

1. Switch to the side view (so that you can see the leg from the side). Create three skeletons: a spine, an arm and a leg.

Note We only have to create the left leg and the left arm for the body!

Side view: a spine and two child skeletons
 2. On the select window, drag & drop the hand and the leg skeleton inside the spine skeleton. You should also rename the skeletons so that you can recognize them later. 3. Switch to the front view and move the leg and the hand skeletons to their correct positions. 4. Select both the sub skeletons and click the Attach button in the tool control bar. This attaches the selected skeletons to the nearest joint of the parent (spine) skeleton. Go back to the side view and try moving joints of the sub skeletons in the edit mode - the inverse kinematics affects the entire body. Front view: the leg and arm displaced from the spine

### Editing angle constraints

 If you switch to the front view and try to move one of the hand joints horizontally, you will notice that the entire skeleton moves as a rigid body. Both the arm and the leg refuse to rotate sideways. The constraint angles between the arm and the body do not allow rotations to the side. There are two ways to edit the constraints. Either you drag the desired constraint angles through the view window, or you use the property window. For example, to modify the constraint of the root joint of the arm skeleton: 1. Select the first joint of the arm skeleton by clicking it Select the root joint of the arm
 2. Open the property window. Select the 'Spec/Joints/Constraints' tab. 3. As you can see, the 'Pitching' constraint angles are zero. Increase the 'Max' value and decrease the 'Min' value. While you move the slider, you can see how the 'pitching' handle of the skeleton moves in the view window accordingly. You can also edit the constraint angle by dragging the handle (the cross at the corner of the angle sector) directly through the view window. Modify the 'Pitching' angle to allow the hand to rotate sideways
 The pitching constraint expanded Edit also the constraints of the hip joint of the leg skeleton so that it allows appropriate rotations in both the heading and the pitching directions. The knee and elbow constraints are OK - they do not bend sideways. So, we now have a body, which only has a left leg and arm. The right arm and leg can be created easily. Just select the root skeleton (spine) and apply the DupMir tool.

DupMir tool

This duplicates and mirrors all the sub skeletons of the spine. The skeleton is ready.

A human skeleton

### Attaching bodies to skeletons

 The next step is to attach the skeleton to the actual body. Use the subdivision surface tool set to create a body, which roughly matches the skeleton. If you are familiar with the SDS tool set, you should be able to create a simple body for the skeleton quite rapidly. If you are too busy to model the body, you can load one from: 'tutorprojects\animation\skeleton\body and skeleton' Adjust the skeleton so that it matches the body. We will attach the body to the skeleton using the 'Multi Map' lattice mapping tool. This tool is capable of attaching a body to a hierarchical skeleton using weighted multi mapping. This means that a single point can be mapped to many skeletons with appropriate weights. The higher the weight, the stronger the skeleton in question affects the point. For example, a point between the start of two fingers can be mapped to both fingers with equal weights, which gives a realistic skin effect. A body and a skeleton

1. Select the spine and click the 'Map Volume' tool. This turns on visualization of so-called mapping radius property.

2. Click the 'Adj. Rad' tool and enter a point through the view window. If you now move the mouse up/down, you will be able to adjust the mapping volume radius so that those points you want to map to the spine are inside the mapping volume. Repeat the steps for the legs and arms.

Note Shaded OpenGL mode usually shows best what is an appropriate mapping radius. The wireframe of the SDS control polygon outside the mapping volume can be easily detected.

3. Once you have managed to define appropriate mapping volumes, just select the body and the root skeleton (spine) and click the 'Multi Map' lattice mapping tool. Your body is now attached to the skeleton and you can switch the mapping volumes off by selecting the skeletons and clicking the 'Map Volume' button on the tool control bar.

Mapping volumes defined for the skeletons.

Note The mapping volumes overlap where the legs and arms join to the body. Correspondingly, points near these joints get mapped to multiple skeletons!

Multi Map tool

To make sure all the points were attached to the skeleton, just modify the skeleton (drag a joint in the edit mode). The body should follow the skeleton.

Tutorial project: 'tutorprojects\animation\skeleton\attached body'

Note If you defined too small mapping volumes, some points in the model may not get mapped to any skeleton. To fix the problem, select the point, then select the appropriate skeleton and use the

standard lattice mapping Map tool with the 'Selected Points' option to attach the point to the skeleton manually.

If the mapping volumes are too large, some points may get mapped to multiple skeletons when they should not. You can detach a point from a skeleton by multi selecting the point and the skeleton and then applying the Unmap tool.

### Animating skeletons

Animating skeletons using the key framer does not differ from animating other objects, such as spheres. Just modify the skeleton in the animation recording mode. For example, let's make the skeleton wave its hand.

2. Switch to the side view and drag the end point of the right arm of the skeleton.

3. Jump to frame 40 and drag the end point of the right arm back to its original position.

4. Switch the animation recording off and play the animation. Tutorial Project: 'tutorprojects\animation\skeleton\say hi'

We have now gone through a basic workflow for creating and animating characters. To keep the example simple, we just attached two sub skeletons to the body to animate legs and arms. However, you can create any number of sub skeletons for controlling the body. Lips, eyes and other parts in your model can be animated this way. In the following chapters, we will go through a number of other useful tools for animating skeletons.

### Key framing angles and joint positions

When you modify a skeleton in animation recording mode, the animation system animates the skeleton by key framing the bone angles, regardless of the tool you use to modify the skeleton.

The problem with angle based key framing is that it tends to create 'slipping feet' problems. It is a difficult job to key frame the bone angles so that their motions match exactly the translation of the body.

Instead of key framing bone angles, you can record joint positions. In this case, the system applies inverse kinematics to move the joints through the recorded key positions.

To do this, set the 'Preferred Anim. Method' field in the property window's 'Spec/Skeleton' tab to 'Inverse Kinematics' and then modify the skeleton in the animation recording mode as usual.

Note When using joint position key framing, key frames are created only for the selected joints (those joints you modify directly with the mouse)!

### Mixing angle and position keys

Angle and position key framing can also be mixed. For example, you can first key frame the skeleton using 'Angles'. Then you can define an exact path for a certain joint by key framing its position. This way the system first sets the skeleton to a 'nearly' correct position using angles and then inverse kinematics fine-tunes the position.

 To achieve this, use Angles as the preferred animation technique and apply IK Target tool to the desired point. This tells the animation system that the selected joint should be key framed using inverse kinematics and key framed positions. Alternatively, you can use Inverse Kinematics as the preferred animation method and use the Angle tool to activate angle key framing for a desired joint. IK Target tool

### Anchoring joints

The 'Anchor' tool fixes the joint to object space so that IK cannot move it. This tool is useful when using inverse kinematics to control the joint positions. For example, you can create a moving compass needle and use IK to make it point to the north pole. You have to anchor the origin of the needle so that IK won't pull the entire needle to the North Pole. Let's create a walking leg to demonstrate the 'Anchor' and 'I.K Target' tools.

1. Create a simple skeleton consisting of four joints, representing a leg.

2. Set animation recording on, jump to the last frame and move the entire skeleton horizontally by dragging its 'x' axis. We have now created a simple 'moving leg' animation. Reset animation recording.

3. Enter the edit mode and apply the 'Anchor' tool for the root joint.

4. Select the last joint of the leg and apply the 'IK Target' tool.

Play the animation.

The root joint is now anchored so it is forced to move according to the translation we applied to the entire skeleton. However, the last joint acts as an 'IK Target'. Because we didn't key frame the position of the last joint, it attempts to remain in its original position.

Tutorial project: 'tutorprojects\animation\skeleton\iktarget'

### IK stoppers

When you apply inverse kinematics to a joint (say, you pull a finger of a robot), the effect propagates through the entire skeleton and bends and twists it according to joint frictions and constraints.

Let's assume you want to pull the finger so that only the arm is stretched. Once the arm forms a straight line, the rest of the body is 'moved' as a rigid body.

The 'Head' and 'Tail' tools can be used for this. For example, apply the 'Head' tool to the shoulder of a robot. Then you can pull the finger of the hand. Inverse kinematics propagates towards the shoulder and when it reaches the shoulder, it stops and simply moves the joints at the other side of the joint.

IK Stopper tools

Correspondingly, the Tail tool can be used for stopping inverse kinematics from propagating to the tail of the skeleton when one of the parent joints are modified. For example, if you move the robot from its spine, the arm keeps its current position if 'Tail' stopper is set for the shoulder.

### Foot steps

A foot step system moves a character along a path defined by a set of footprints. The character's legs are moved using inverse kinematics. Characters with any number of legs can be attached to a footstep sequence. The system assumes only that each leg is either left or right handed.

1. Model a skeleton with two legs (or load the skeleton modeled in the previous tutorials, 'tutorprojects/animation/skeleton/body').

 2. Switch to the top view (so that you can see the character from top) and activate the Foot Step/Foot tool.
 3. Click the mouse to define a set of foot print objects.When a desired number of footprints has been created, select 'Accept'. This creates a foot print object consisting of a set of left and right handed foot objects. 4. Switch to the side view. You can now see small 'step height' handles above each foot object. Move the skeleton so that its feet are positioned below these 'step height' handles. Click the mouse on a view window to define a sequence of footprints

Note It is important that only the joints of the feet are positioned below the line formed by step height handles. The positioning defines which joints are interpreted to be part of the feet - they will be moved using IK.

 5. Select the skeleton and the foot step object (in any order) and click Foot Step/Automap tool. This attaches the skeleton into the foot step sequence.

Play the animation and the skeleton walks along the footsteps.

### Modifying foot steps

Many ideas used in path animations apply directly to the footsteps too. For example, you can modify the timing by editing 'Lattice Translate' curves in the choreography window.

Each foot object inside the foot step level object defines a 'step height' handle. You can drag these handles in the edit mode to control the step height of the walking skeleton.

You can also modify positions of desired feet to get more interesting animations. Footprint objects inside the footstep object can be duplicated to get longer walking sequences.