From BlenderWiki

Jump to: navigation, search
Image:LeftArrowHeader.png
[[{{{2}}}|      ]]>
Image:RightArrowHeader.png
[[{{{3}}}|      ]]>
Blender Summer of Documentation: Contents | Manual | Blender Version 2.41

[edit] Introduction

Level
basic

Recommended pre-requisites: working knowledge of Blender's interface, armatures and weight painting.


[edit] About

In this tutorial we play with the "Stretch To" constraint to control squashing and stretching of a mesh with one of its armature bones.

[edit] Tutorial

1) Our start: Suzanne and a two-bone armature.

[edit] Basic Setup

We need a model, a simple armature and the "Stretch To" constraint. Suzanne is a perfect candidate, so that's where we start.

  1. Add Suzanne's head:
    SPACE >> Add >> Mesh >> Suzanne
  2. Add an armature:
    1. SPACE >> Add >> Armature. This first bone is the one we will add a "StretchTo" constraint to.
    2. Still in armature edit mode select and move (G or use the translation manipulator) the created bone to the middle of Suzanne's head. Note: this step can be avoided by placing the 3D Cursor at the right point before adding the armature.
    3. Turn "X-Ray" on in the Armature panel (Buttons window, Editing tab) to make the armature always visible in the 3D View.
  3. Add another bone at the top of the head. This will be the control bone:
    (in armature edit mode) SPACE >> Add >> Bone.
  4. Select the mesh and add an Armature modifier to it:
    1. Buttons window >> Editing tab >> Modifiers panel >> Add Modifier >> Armature.
    2. Set the "Ob:" (object) field in the modifier panel to the name of the armature object, probably "Armature", unless you changed it.
  5. To simplify, rename the bone at the middle of the head to "Stretching" and the one at the top to "ControlStretch", or what you prefer.
Organization
it's always a good idea to keep your scenes well organized, at least with each object having a meaningful name.


The placement of the bones as we've done is not a requirement, just a good suggestion based on simplicity and the possibility of using bone envelopes to define influences. Later we can hide the stretching bone and only keep the control one visible.

2) Stretching bone's weights: all 1.0.

[edit] "Stretch To" Constraint

Now we add the constraint to the stretching bone, linking it to the control one.

  1. Select the armature object and enter Pose mode:
    Ctrl TAB
  2. Select the bone in the middle of the head (the stretching bone) and add the "Stretch To" constraint to it:
    Buttons window >> Editing or Object tab >> Constraints panel >> Add Constraint >> Stretch To
    In the Stretch To constraint panel:
    1. Set Object (OB:) to Armature
    2. A new field will appear: (BO:). Set it to the name of the control bone.
      The other options can be left with default values, which means keeping volume in XZ with Volume Variaton as 1.0.
  3. The control bone will not directly deform the mesh, so we can turn off that behavior for it:
    Toggle off the "Deform" button in the Armature Bones panel. Don't do this to the stretching bone!

The stretching bone should now have a different color, like shown in figure #2. If not, review the above steps.

[edit] Basic Weight Painting

As a start we want the stretching bone to deform the head as a whole. We can either do this setting a proper envelope or painting weights. For this tutorial the second option is more interesting, because we will experiment a little with it in the next section.

  1. Make sure the armature is in Pose mode.
  2. Select the mesh and enter Weight Paint mode:
    Ctrl TAB
  3. Select the stretching bone with  RMB Image:Template-RMB.png.
  4. Paint a little on the head with  LMB Image:Template-LMB.png, a single click is enough. We just want Blender to create a vertex group for us.
  5. Enter Edit mode:
    TAB
  6. Select all vertices and set their weight to 1.0:
    1. A once or twice to select all vertices
    2. In the Link and Materials panel of the Editing buttons set "Weight" to 1.0 and press "Assign".
  7. Leave Edit mode:
    TAB
  8. The mesh should be all red, like the one in figure #2. We can leave Weight Painting mode now:
    Ctrl TAB

[edit] Testing

To stretch or squash this head we only need to move the stretching control bone up or down in armature Pose mode. Quick test:

  1. Select the armature and enter Pose mode, if not already in it:
    Ctrl TAB
  2. Select the upper bone and move it up or down. To return the bone to its rest state:
    Alt G resets selected bone(s) location(s) to the default.

That's it. While animating, we'd save keyframes of this bone to have the head squashed or stretched. It's also a good idea to hide bones that are not needed during posing, like we did in the figures.

Image #3 shows an example of the results with Volume Variation = 1.0. This is good enough for a subtle use of Squash and Stretch, with the control bone moved not too much out of its default position.

3) Example of the effect of stretching or squashing the mesh by moving the stretch control bone up or down, respectively.

Below we see what happens if we exaggerate: the volume isn't preserved, destroying the effect.

4) Bad: exaggerating the stretch bone's displacement gives bad results: volume isn't properly preserved!

One way to prevent this and allow extreme squashing or stretching is to use different Volume Variation settings. Higher values, like 10.0 or 15.0 are good for stretching, while smaller than 1.0 works better for squashing. One possibility is to add two "Stretch To" constraints, one set for squashing and the other for stretching. When using one of them, keep the other's Influence at zero.

5) Better: different volume variation values for stretching and squashing.


[edit] Variations with Weight Painting

6) Stretching bone's new weights.

Up to now the head mesh has been attached to the stretching bone with all influences set to 1.0, the maximum, as shown in figure #2 above.

It works, but we can be more creative than that. Back to Weight Painting mode, where we can customize the vertex weights for the stretching bone. Figure #6 shows what we have done, compare it to image #2 (or just remember that there the head was all red).

7) Root bone's weights.

Now we need another bone to also influence the mesh (if the stretching bone is the only one deforming the mesh, it will still have total control over the deformation, even with smaller weights). So we will add a new bone and use it as the "root" bone for the head.

In Armature Edit mode:

  1. Place the cursor where the new bone should be, then create it:
    1. SPACE >> Add >> Bone. Figure #7 shows where we added ours. Renaming it to "root" now is a good idea.
  2. Select each of the other two bones at a time and make it child of the new one:
    In the Armature Bones panel (Buttons window -> Editing tab) select the parent from the drop-down list.

Now this root bone can be used to move the whole head + armature around, too, in Pose mode. Last step: setting the vertex weights of the root bone (figure #7).

Note from the colors in image #6 how we chose (arbitrarily) to make the stretching bone influence more the area of the brows, eyes and nose, and a little less at the top of the head then at the rest of it. The root bone (image #8) on the other hand has more influence over the bottom sides of the "chin" and ears and less at the brows. The results are shown below (right side Suzanne).




Here we finish with a render of Suzanne's head in its normal and also in two stretched poses, one with all weights set to 1.0 and another with the root bone added and varied weights, to give an idea of the possibilities.

8) Rendered Suzannes, from left to right: a) Normal; b) Stretched with all weights set to 1.0; c) Stretched with varied weights, as shown on images 6 and 7 above.


[edit] Notes

[edit] Reference

This tutorial was inspired by the Ludwig character and rig setup by Jason Pierce. Ludwig is a ready to be animated model with a license that allows its free use in noncommercial work. You can download the .blend file and get detailed informations at this website.

Since we are here: BlenderNation's repositories category, with more examples of free models, textures, sounds and so on.

[edit] The Color Sampler

Our Suzanne here uses Blender's logo colors. To do that we sampled the colors from the small Blender logo at the top of the screen (User Preferences window header), using the color sampler tool available in color picker widgets since version 2.42.


Summer of documentation 2006 -- Willian 18:51, 6 August 2006 (CEST)

{{UM/foot|BSoD/Introduction_to_the_Principles_of_Animation/Tutorials||}