Blender Spring Rig Header

Probably the best way to make a spring mesh is to use the Screw tool – but what if you want to compress and expand the spring for animation? It’s possible to rig a dynamic spring with an armature, and then animate it with Ipo curves or the Action editor.

There was a question posted on the Blender Underground Forums about how to make a spring in Blender. If you don’t need a dynamic spring, just use the Screw tool. If you need more than a static mesh spring, i.e., something that appears to function, the answer isn’t so simple…

I tried several different ways that I found unsatisfactory, mainly because most of them would deform the spring rod itself, forcing it from round to oblong. I tried a curve modified cylinder, with a lattice on the curve itself, but the curve would deform leaving the mesh behind. I tried a lattice on a curve lofted with a bevel object, but all of the geometry deformed, not just the curve shape. I tried some other things too, none of which I can remember well enough to enumerate.

What I came up with couldn’t necessarily be described as elegant, but it works. It’s not too egregiously complex either, but it takes a little time to set up. Now I wouldn’t be surprised to hear that there was a much easier way to do what I did. I’ve been in that situation before, having worked very hard to make a complex setup functional, only to hear, “Dude, all you have to do is…,” and be shown how there was a simple or built in way to accomplish what I jumped through hoops for. So if you know of an easier or better way to do this, just give me a shout and say, “Dude….”

Making a Spring Rig in Blender

Blender Finished Spring Rig
Finished Spring Rig

Creating the Curve

It starts with the default scene, in Top view (NUMPAD 7). Delete the cube, if you have one, and add a Bezier Circle. This will be the basis of the spring shape. Name it “Spring” and if you desire, name it’s data Spring as well. In the Curves and Surfaces panel, activate 3D.

Blender Curve 3D Mode
Curve Settings

Press the C Key to “Toggle Cyclic.” This changes the curve from a closed loop into an open curve. You’ll notice the handles on the open ends have rotated, making the shape non-round. This is an easy fix.

Blender Curve Spring Thickness
Rotating the Curve Handles, Before and After

Select one of the handles, as in the picture above. Don’t select the entire point, just one of the two handles that influence it. Press R to rotate and hold CTRL to snap to 5 degree increments. Rotate 45 degrees for each handle. This will restore the round shape of the open curve. Make sure your 3D Pivot mode is set to Median point, and not something like 3D Cursor.

Next we need to adjust our points on the Z axis. Select the leftmost control point (from a top-down perspective). We’re going to raise this up a little. Activate Front view with NUMPAD 1 (or use a comfortable 3/4 rotated view). Press G to grab, and press Z to constrain on the Z axis. Key in 0.5 to raise the control vertex up on half of a Blender unit.

For the top control point, we can leave it where it is. Select the rightmost control point and drag it down -0.5 units, either by keying in the value directly, or holding CTRL while dragging on the Z axis. Select the last control point. This should be the bottom vertex, and it should be the other open end. Lower it to -1.0 units.

Drag Curve Control Vertex
Raising and Lowering Control Points, Before and After

Now alternate between Front and Side views and adjust your control handles to point at one another. Only Rotate the handles, don’t drag them, in order to make sure the handle length doesn’t change. Consistent handle lengths will give our curves the best look.

Drag Curve Control Vertex
Rotating Handles for Constant Slope, Before and After

This is an iterative process, and you’ll want to go through a few times, switching between front and side views, and rotating the handles a little at each pass. What you want to achieve is an even slope between all points, and it’s worth taking a few minutes to get it right. Your result should look like the above.

The next step is making our spring longer, so we’re going to duplicate our first section and join them together.

From Front view, press A to select all points. Press SHIFT+D to duplicate. Press Z to constrain on the Z axis, and lower the duplicate section -2.0 units.

Curve Join Segments
Joining Segments, Before and After

Now select the two points indicated in the picture above. These are the topmost point from the bottom section, and the bottommost point from the original, top section. Press F to join them together. Note that this is the same key you use to create a face or edge while mesh editing.

This is a good time to go back through and rotate the handles again, and make sure the slope between points is consistent. Once again, alternate between Front and Side views, and rotate the handles a little at a time until the result is satisfactory. You may find that it requires no further adjustment, if the first section was spot on.

Repeat the duplicating and joining process one more time to double the length of the spring curve. Press A to select all control vertices, Press SHIFT+D to duplicate them, Press Z to constrain movement on the Z axis, and drag them down -4.0 units. Select the middle, open control points and press F to join the segments.

You can repeat the duplication process as much or as little as you like, according to your needs. You can also scale the length of the spring segments, once you have joined them all together.

Blender Curve Spring Final
Finished Spring Curve

The last step in this part of the process is to create a Curve Circle to be used as a Bevel Object.

TAB out of Edit mode and activate Top view. Add another Bezier Circle and scale it down somewhat. Name the new circle object, “SpringLoft” and rename it’s data as well, if it suits you.

Curve Bevel Loft
Bevel Object and Settings (Loft)

Select your spring shape and enter the name of the loft shape (SpringLoft) in its BevOb field, located in the Curves and Surfaces panel. This will use the newly created Bezier Circle as a loft shape, to give the spring 3 dimensions. The Loft shape itself doesn’t need to be 3D, so make sure to leave it off for the Loft shape.

Adding Hooks


UPDATE: The below process outlines adding 16 hooks, 1 for each curve vertex. This can be more simply accomplished with a single hook, by selecting all the control points and pressing CTRL+H to add a hook. You can find alternate blend files below containing rigs set up this way.


Hooks are a nifty feature that lets you influence the vertices of an object’s data individually. If you’re familiar with Parenting, Hooks are like having a parent object for a vertex or set of vertices. We need our Spring Curve to compress and expand, but we need the loft shape to remain round while this is happening. Hooks will help us accomplish this. The ace-in-the-hole about using hooks is that when we scale them, they pass the scale information down to the control points, so the handles scale along with the hooks, giving a smooth curve interpolation, no matter how we scale it. This is especially important for compressing the spring, which is done by scaling the hooks on their Z axis. When the hooks are scaled on Z, so are the control point handles, which means they will flatten out as the spring is compressed, and elongate as the spring is expanded. This is really what makes the whole thing work.Let’s begin by shifting the Curve data up in relation to its Origin Point. What we want is the Curve’s data, or control points, above it’s Origin point. TAB into Edit mode, press A to select all the control points, press Z to constrain, and drag the data upward until the bottom vertex is about at the height of the Origin Point. I suppose I could have reversed the creation of the spring segments and duplicated them upward, but this is a simple step so no real time lost.Shift Data Above Origin
Relocating Data Above Origin
From Front or Side view, select the Spring Curve object and TAB into Edit mode. Select the top control point. Make sure you’re selecting the control vertex itself, and not just one of the handles. Press CTRL+H to activate the Hooks menu. Choose “Add, New Empty” from the menu. This will create a new Empty object and assign it as the Hook for the selected control point.

Curve Vertex Control Point Hook
Adding a Hook to a Control Point

Repeat the process for every vertex from top to bottom, until you have 16 empties, each assigned as a hook for the 16 control points of the curve.

Blender Curve Hooks Added
All Hooks Added for Each Control Point

Once all the hooks are added, you can get your first look at the spring action. TAB out of Edit mode, select just the Spring Curve object, and press SHIFT+G for the Select Grouped menu. Choose Object Hooks to select all the hooks. SHIFT select the Spring to deselect it. Press S to scale, and press Z to constrain the scaling to the Z axis. You should be able to see the spring compress and expand, while the rod itself maintains its round shape. Press ESC to cancel the transformation.

Note: You can select the Spring Loft object and scale it up and down in order to adjust the thickness of the spring rod.

Rigging the Armature


UPDATE: If you used a single hook instead of 16, you can parent the single empty to the Stretch_Target bone. Updated blend files are available below if you want to explore alternate setups.


By creating a simple rig to drive the spring action, we can use it as part of a more complex rig and make its motion automatic as part of another animation. We can also animate it directly with the Ipo or Action editors. We can even drive it with Ipo drivers or Action constraints. We’ll develop a basic armature setup. You may want to modify parts in order to meet your needs.From Front view, make sure your 3D cursor is at the position of the Spring Curve object. Select the Spring, press SHIFT+S, and choose Cursor->Selection. Now Add an Armature object. Press G to grab the top point of the new bone, and drag it to the right, making it horizontal and about 2 Blender units long.Blender Curve Rig Armature
Adding the Root Bone
Select the entire bone and name it “Root” in the Armature Bones panel. Next select the base node of the bone and extrude (E) a new bone out of it; press Z to constrain the extrusion on the Z axis, and drag the new bone up to the level of the topmost Spring vertex. Name this bone “Stretch” and make it a child of “Root” with the “Child Of” selector next to the bone name box. Do Not press the Connected button.

Stretch Bone
Stretch Bone and Settings

We need a stretch target bone. This works like an IK target and will give our Stretch bone something to “stretch to.” Select the top node of the Stretch bone and extrude a short bone out of it upward on the Z axis. Name this bone “Stretch_Target.” Deselect the “Con” (Connected) button and make this bone a child of the Root bone.

Stretch Target Bone
Stretch_Target Bone and Settings

It’s time to add the Stretch To constraint. TAB out of Edit mode for the Armature, and with the Armature selected, press CTRL+TAB to enter Pose mode. Alternately, you can choose Pose Mode from the Mode selector at the bottom of the 3D view.

Select the Stretch bone and from the Constraints panel, add a Stretch To constraint. The Stretch bone will turn green, indicating that it has a constraint applied. In the Target field, enter the name of your armature, “Armature.” Another field will appear asking for the name of the bone target. Enter “Stretch_Target” into that field. Lower in the constraint panel, select the NONE button to keep the stretch constraint from affecting XY scale.

Stretch To Constraint
Stretch To Constraint and Settings

If you grab the Stretch_Target bone, you’ll notice that the Stretch bone follows it around. This is exactly what we want.

It’s time to attach the hooks and make this thing functional. Select the top Empty, which is the hook for the top Spring vertex. SHIFT select the Stretch bone, press CTRL+P for the Make Parent menu, and choose “Bone” as the parenting option. If you do not see the Bone option, then your armature is not in Pose Mode. Make sure the Armature is in Pose Mode and try again.

Repeat the process for every Empty Hook, until all 16 are parented to the Stretch bone. To parent all empties simultaneously, select them all then SHIFT select the Stretch bone last, and press CTRL+P choosing “Bone” from the menu. Remember that you can use SHIFT+G on the Spring Curve object to select its hooks all at once.

Once this is done, grab the Stretch_Target bone and move it around. You should have a fully functional spring rig!

Final Touches

There are some things we can do to make this rig a little more user friendly, and a little harder to break. These steps aren’t necessary, but you might find them useful or instructional.

Let’s attach the Spring Loft object to the top of the Spring Curve, and make it stand out a little. Move the Spring Loft object until it is aligned with the first vertex of the Spring Curve. With the Spring Loft circle selected, from the Draw panel in the Object context, activate the Bounds and Name buttons in the Draw Extra options. You can even name this object “Spring Thickness” to make it just a little more descriptive. Parent this object to the Stretch_Target bone so it stays connected to the rig, or alternately, parent it to the top Empty Hook.

Blender Curve Spring Thickness
Spring Loft Curve Object Final Settings

Select the Armature and activate Draw Names from the Armature panel, to see the names of the bones.

You can also activate Protected Transforms for each object to help keep the rig from being easily broken by the user performing unintended transformations. Press N to activate the Transform Properties. With the little lock buttons, you can lock the transforms according to the list below:

Stretch_Target Bone

  • Lock Scale X,Y,Z
  • Lock Rot X,Y,Z

Stretch Bone

  • Lock All Transforms

Root Bone

  • Lock None

Spring Loft Object (Spring Thickness)

  • Lock Loc X,Y,Z
  • Lock Rot X,Y,Z

Spring Curve Object

  • Lock All Transforms

Empties

  • Lock All Transforms – This can be accomplished quickly by locking the transforms for the top Empty, then select all Empties, making sure the top one is the “Active” object. You can SHIFT select the top Empty to make it the Active selection. Press CTRL+C for the Copy Attributes menu, and choose Protected Transforms from the menu. This will copy the protections from the top Empty to every other selected object.

Blender Finished Spring Rig
Finished Spring Rig

If you know of a better way to get this done, please post a comment. This is a learning process for me, and for all of us at Blender Underground. Also, if you find any mistakes or confusing elements, post a comment and let us know. Power to the people.

LINKS:

Project Blend File: Blender Spring Rig (blend file)

Updated Blend File: Blender Spring Rig v1.2 (blend file) – This updated blend features a Z twist fix and uses one hook for all control points.

Version 2.0 Blend File: Blender Spring Rig v2.0 (blend file) – This version contains two rigs, one using the hook method, and the other using the Shape key method, which was adapted from a setup by Gimble of the Blender Artists forum. Thanks Gimble!

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

This entry was posted on Thursday, January 3rd, 2008 at 7:44 pm and is filed under Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

6 Responses

  1. Apollos says

    I found an alternate, incredibly clever and workable spring solution on Blender Artists here: Spring Tutorial.

    It’s an entirely different solution, and goes to show what ingenuity and experimentation can accomplish in Blender! 8)

    It uses a combination of the Array modifier and shape keys, and I recommend it highly.

  2. Coyabbit says

    Both are really good Tutorials for Springs. I like yours because I seem to have more control over the spring and how it is implemented. Its also easer to resize both the diameter of the spring and the wire itself. But if you are looking for a perfect angular shape the one on Blender Artists is great.

    I may have to do a little more research into IPO Drivers, the effect was great but I’m not really sure how I got there.

  3. Apollos says

    I prefer the armature setup as well, as it’s generally more flexible. What I liked about the other tutorial was its ingenuity. It also makes adjusting the length, i.e., number of coils a snap: just change the array size.

    The Ipo Driver and Shape key thing is a little weird, but very cool. What you’re telling Blender is to use an object’s location (or rotation, scale) to determine what frame of an animation to use (the shape key frame).

    Any animation can be set up this way, but it takes some getting used to. Ultimately it’s very powerful, letting the user hook up animated movement to a control object.

  4. Apollos says

    I added update comments to the tutorial text: this can be accomplished with a single hook instead of using one hook for every vertex, by selecting all the curve control points and adding a hook using CTRL+H.

  5. terry_blenderunderground says

    Maybe I’m doing something wrong, but when I take your sample file and rotate it using the Root bone it creates a kink in the spring. RotX=2.612, RotY=14.575, and RotZ=-70.752. If you just use the mouse to rotate the object you can see the kink come and go near the “Spring Thickness” label . Does anyone know if I’m doing something wrong, or how I can correct this?

  6. Apollos says

    terry, welcome to Blender Underground. 8)

    The Z Twist Fix slider is exactly for that purpose. Adjusting it should eliminate that problem in most circumstances. If it doesn’t help, come on in to the forums, or email me directly: apollos@….com.

Leave a Reply

You must be logged in to post a comment.