Blender 3D: Noob to Pro/Basic Animation/Lattice

From Wikibooks, open books for an open world
Jump to: navigation, search

What is a Lattice?[edit]

A Lattice is essentially a simple container that can be used to deform and manipulate a more complex mesh in a non-destructive manner (i.e. A lattice can be used to seriously deform a mesh then, if the lattice is later removed, the mesh can automatically return to its original shape).

How to add and use a Lattice[edit]

A Lattice is added to the scene in the same way other objects are added. Either:

Noob Note For Blender 2.62 or 2.63 users, I recommend referring to this Lattice Modifier video tutorial by Ed Lazor for animating the lattice, as numerous interface changes have occurred between Blender 2.4x and 2.6x.

  1. Shift-A over the 3D window and choose Lattice from the pop-up menu, or
  2. Press Spacebar over the 3D window and choose Lattice from the pop-up menu, or
  3. LMB ADD from the 3D window menu and choose Lattice from the drop-down menu

The default Lattice looks just like a cube when first added except that it is just one Blender Unit (BU) wide whereas a mesh cube is 2 BU wide. When the Lattice is added, the window remains in Object Mode and the Lattice can be moved, resized and rotated like any other Blender Object.

On its own, a Lattice serves no purpose whatsoever since it can't be seen in a rendered image. Its only use is to manipulate another object and so, to be useful, we need to associate another object with it. The current method for doing this is by applying a "Lattice Modifier" to a Blender object.

The basic workflow is:

  • Add a mesh (cube, cylinder, cone, sphere, etc.)
  • Add a Lattice
  • Select the mesh
  • Press F9 and go to Modifiers Panel(buttons window). In the modifiers tab Press Add Modifier > Lattice
  • In the Ob: Panel, enter the name of the Lattice (The default name is Lattice, Lattice.001, Lattice.002, etc. - or you can give it a useful name that you'll remember later)

NOTE: In older versions of Blender, a lattice was applied using a parent method - select the mesh, then select the Lattice, then press Ctrl-P and choose "Lattice Deform". While this method is still available, it does not offer the full functionality of the newer Lattice Modifier. If you use the parent method, you will need to press the "Make Real" button in the modifiers palette to enable the modifier functionalities. Using the method, the Lattice becomes a parent and a modifier. As a parent, it will act on the mesh in Object Mode whereas a true modifier lattice only influences the mesh when altered in Edit Mode.

Lattice AddModifier.jpg
Adding a Lattice Modifier to an object

Now, we can change the Lattice in Edit Mode and any changes we make to it will affect the mesh.

Note: Applying the Modifier Correctly[edit]

When adding the modifier to your object, you must enter exactly the same name as your lattice. The default is Lattice with a capital "L" but if you've changed it or have more than one Lattice, then you will need to enter the new name. When you enter a valid Lattice name, the name stays visible in the Ob: box. If your entry disappears then you've entered the name incorrectly.

One simple way to get the right name is to select the Lattice, go to F9, Link and Materials panel and where it says Ob:Lattice or Ob:Lattice.001 etc., move the mouse over this field and press Ctrl-C (don't click on it, just hover over it). This copies the Lattice name. Then select your object, go to the Lattice Modifier panel, hover the mouse over the Ob: field and press Ctrl-V to paste the name in. Now it should stay there and your Lattice should work in Edit Mode.

Noob note: I recommend the method with Ctrl-P for animation.

Basic Exercise:[edit]

  1. Start with a new Blender scene, delete the default cube and add a UVsphere (Spacebar>Add>Mesh>UVsphere). Accept the default 32 Segments and Rings. You could use any of the mesh shapes but because the sphere is heavily subdivided (made up of lots of edges and faces); you will get a better idea of what the Lattice is doing.
  2. Tab back into Object Mode then add a Lattice. It is generally wise to resize the Lattice so that it surrounds the mesh it will be deforming. So, press SKEY and enlarge the lattice to 2 BU wide.
  3. Select (RMB) the Sphere and add a Lattice Modifier to it. Make sure that you type the exact Lattice name correctly into the box. Nothing appears to happen but that's fine.
  4. Now select your Lattice, TAB into Edit Mode, select just one control point (a control point looks like a vertex) on the Lattice and move it around. You will see the sphere mesh stretching and squashing relative to that control point. Move each Lattice control point one at a time and see just how far you can deform the mesh. Zoom in your 3D window if you need a closer look.
  5. The control points of the Lattice can be moved, scaled and rotated in the usual ways. Try selecting a few of all the control points and scaling them (SKEY) or Rotating them (RKEY) and watch the mesh follow along.
  6. Now, exit Edit Mode (TAB) and select the sphere in Object Mode. Go to the modifiers panel and press the big "X" button to remove the modifier. Despite all that deforming, the sphere immediately returns to its original size and shape. Nothing was really changed in the sphere's mesh data. Immediately re-apply the modifier as before and see the Lattice immediately apply its own deformation to the sphere again.

Getting more involved with Lattice[edit]

The default Lattice is two control points high, two wide and two deep, i.e., it is two control points wide in each direction (these are referred to as the U, V and W directions). However, we can change the number of control points in one, two or all directions. This is done by selecting the Lattice, going to the Lattice Panel (F9) and changing the values in the U, V & W buttons. If you decrease one figure to a value of 1, the Lattice will become two-dimensional (planar). Decreasing two values to 1 will change the Lattice to a line (one dimension). This can be useful, especially if the remaining value is increased, but is not the most common usage of Lattice.

Lattice UVWsets.jpg
UVW settings for Lattice

NOTE: The "Make Regular" button will set the UVW control points of an unscaled Lattice to be exactly one Blender Unit apart in each direction. The "Outside" button effectively removes all the internal control points which are added when the UVW settings are higher than 2.

In most situations you will want to increase some or all the values as this gives you more control over complex deformations, much like a subdivided mesh. How much you increase the UVW directions depends entirely on how much detailed control you need over deformations. As you've already seen basic squash, stretch, shear and simple deforms can easily be achieved with the default 2,2,2 Lattice but by increasing the UVW values a little, a whole new range of deform possibilities becomes available.

Lattice UVWtypes.jpg
Three Lattices with different UVW settings

One thing to understand, however, is that a Lattice cannot bend the individual edges of a mesh (the lines connecting any two vertices) so the mesh must contain enough edges in order to apply complex lattice deformations to it. These edges must be genuine edges and not the virtual edges created by a subsurf modifier (Correction: Yes, they can be edges generated by a subsurf modifier, provided the subsurf comes above the lattice in the modifier stack for the object being deformed; use the up/down-arrow buttons next to each modifier to rearrange them as necessary). Edges can also be added to a mesh using a variety of tools including subdivide, knife and loop cuts (some info on these [[1]]).

New Note: Use the K key to open a menu for the knife, loop cuts, etc. Knives are used to add a vertex to each line you left click and drag the cursor over, and loop cuts allow you to make multiple cuts into your active object.

About loop cuts: Ctrl + R also is a direct shortcut to a loop cut. Furthermore, loop cuts' main uses are for subsurf modeling. In order to accomplish a hard edge in a subsurfed object (for example the edges and corners of a wooden table or the bumpers of a car) you must apply loop cuts to the faces surrounding the edge and place them very close to them (and parallel). Experiment with a simple subsurfed cube and you'll see. Keep in mind this is why when modeling it is highly recommended to use quads. A loop cut will only cut a quad face, or every face connected with it in one direction, but only quads. Another main reason why it is recommended to model with quad faces is regarding animation but I suppose other tutorials will deal with that later. More information: [2]

Lattice complex.jpg
A simple subdivided cube after a complex lattice deformation

Intermediate Exercise[edit]

For this exercise, start over with a new scene and repeat Steps 1 - 3 in the Basic Exercise above. Don't go into Edit Mode yet.

Basic Exercise:

1. Start with a new Blender scene, delete the default cube and add a UVsphere (Spacebar>Add>Mesh>UVsphere). Accept the default 32 Segments and Rings. You could use any of the mesh shapes but because the sphere is heavily subdivided (made up of lots of edges and faces); you will get a better idea of what the Lattice is doing.

2. Tab back into Object Mode then add a Lattice. It is generally wise to resize the Lattice so that it surrounds the mesh it will be deforming. So, press SKEY and enlarge the lattice to 2 BU wide.

3. Select (RMB) the Sphere and add a Lattice Modifier to it. Make sure that you type the exact Lattice name correctly into the box. Nothing appears to happen but that's fine.

  • In Object Mode, select the Lattice then press F9 and go to the Lattice Panel. Increase all the UVW values to 4. You will immediately see the change displayed in the 3D window.
  • Tab into Edit Mode and play with the control points again. The first thing you might notice is that the corner control points have less influence now than before. This is because the effect is proportional to the distance of each point from the mesh. Move some points in the middle of a side face and you'll see the effect is significantly greater.
  • Try selecting groups of control points and pulling them away from the Lattice to stretch lumps and bumps out from the mesh. If you are familiar with the proportional edit tool, try that too - it works on Lattices just like it does on meshes.

Try doing the same exercise but increasing values in only the W direction. (U divides in the X direction, V divides the Y direction and W divides the Z direction). So, set the UVW to 2,2,4 and play with the control points again in Edit Mode. Select the two rows of control points around the centre of the Lattice and scale them up (SKEY) then Scale them down along Z-axis only (Skey>ZKey). Try other transforms constrained on different axes for interesting, controlled results.

There are three different options for how the Lattice Modifier affects each UVW direction. These are Linear, Cardinal and B-Spline. All I can say is that B-Spline is the default and to find out what the difference is, press the buttons and see.


Lattice Samples.jpg

Some examples of a Lattice deforming a standard UV Sphere mesh (not smoothed)

Making it stick[edit]

To keep the mesh deformed permanently, you can select it and press the "APPLY" button in the Lattice Modifier panel. This "bakes" the mesh in the deformed position and disconnects it from the Lattice. The Lattice can then be deleted without the mesh returning to its original shape. This is useful if you are using the Lattice as a modelling tool rather than an animating tool.

Also, instead of deleting the Lattice, you can use it to immediately modify another mesh. Simply move the Lattice over the new mesh in Object Mode then apply the Lattice Modifier to the new mesh. If the Lattice is already in a deformed state, the mesh will immediately be deformed too. Press Apply again to "bake" that mesh and keep re-using the already deformed Lattice on as many other meshes as you wish for matching results.

[Noob Note: I found it interesting that you can even apply the lattice deformation to the original object again once baked, and it will deform even further.]

Animating a Lattice Modifier[edit]

Lattice animation uses a workflow almost identical to the RVK (Relative Vertex Key) workflow from Blender 2.37 and earlier. You don't need to know this but some people might find the information useful.

With your Lattice Modifer already added to your object, select the Lattice and press I-Key to tell Blender you wish to animate the Lattice. Choose "Lattice" from the pop-up list. This sets the basis key (undeformed state) for the Lattice.

Adding the basis key

In the Editing panel (F9), press the "Relative" button.

Lattice revkey.jpg
Set the keys to "Relative"

NOTE: The Slurph setting determines the delay, in frames, for how long it will take to morph from their former state to the one applied by the new lattice.

To set your first deform key, press I-Key and then "Lattice" again then enter Edit Mode. Deform the Lattice by scaling or moving control points then Tab back into Object Mode. If you open an Action Window now, you will see your first key, "Key 1", added to the list. If you press the small arrow at the top of the list, it will display the slider for that key.

Lattice sliders.jpg
Lattice key sliders in the Action Window [Noob note for blender 2.48a] In the action window, select "ShapeKey editor" in the dropdown "editing modes for this editor" (in the panel header)

To add more Lattice keys, for a variety of deform shapes, repeat the process: I-Key, Tab to Edit Mode, move control points, Tab back to Object Mode. Each time you exit edit mode, a new key will be added to the list in the Action Window.

Animating the Lattice uses the same process as animating Shape Keys for meshes.

If you want the object to begin undeformed, then set each key slider to zero on the first frame of the animation. Move through the frames, setting the sliders as you go to deform the Lattice as desired. You will often find you'll need to set a key before and after each deform key in order to control the rate at which deformations take place in the animation.

Lattice Animkeys.jpg
Setting keys in an animation

Noob note: I'm doing everything as described and get no keys in action window when exiting Edit mode... Any suggestions?

Noob note; Is it possible to create a keyframe using the object's mesh rather than applying a lattice?

Noobie note: What to press after I-Key? I'm not getting any keys in the action window, help please.

Another Noob: No keys here. I got something changing to IPO Curve Editor and choosing Shape in IPO Type

Noob note; Select Action Editor header->Shape Key Editor. Make sure you also selected Buttons Window->Editing (F9)->Relative Keys

Noob Tip: I am seeing a possible bug in 2.49 in which the key sliders will not appear on the Action Editor unless there is at least one window set to Action Editor when the keys are created. To reveal key sliders for keys that have already been created, save the file, re-open it, set one window to "Action Editor" set the window sub-type to "Shape Key Editor" then switch the Lattice "Relative" setting on and off (putting the cursor over the Action Editor window and hitting HOMEKEY will help locate the sliders). Or, by preference, make sure at least one window is set to "Action Editor" before creating the keys.

Noob note: I couldn't see the sliders either; then I scrolled up and there they were, off the visible portion of the window. However, I had by then change the window type a few times, so I can't rule out that that did something first.

Let the fun begin![edit]

Now you have your object safely locked away inside your Lattice, you can still animate the object itself, inside the Lattice!

Why would I animate the object too?[edit]

Take the case of the classic cartoon eyeball which is taller than it is wide. If you just stretched the sphere object itself, instead of using a Lattice to deform it, then you couldn't properly rotate the eyeballs to look up and down because the whole "egg-shaped" eyeball would rotate and end up lying on its front or back. The eyes would literally pop-out of the head.

Lattice eyes without.jpg

Cartoon eyes: The stretched spheres don't rotate properly.

If, however, you use a Lattice to deform the basic sphere to make it into a tall "egg" shape, you can still select the eyeball itself and animate it within the Lattice. Now when you rotate the eyeball, it will look up and down but still maintain its deformed shape within the head.

Lattice eyes with.jpg
Cartoon eyes: Spheres deformed with Lattice can still be rotated with good results.