Blender 3D: Noob to Pro/Advanced Tutorials/Advanced Animation/example/Piston, Rod and Crank

Piston, Rod and Flywheel
A setup like that shown in Image 1 is e.g. typical for a steam engine. It is surprisingly difficult to animate this setup, because one has to translate a rotating movement (of the Flywheel) to a horizontal movement (of the Piston). This alone wouldn't be too difficult, but the Rod has to stay attached to the Piston. The shown setup uses three empties and two armatures, each with two bones.

The horizontal direction is the Y-direction, if this is different in your model you have to exchange Y with your horizontal direction.



Setup
This will spare you from bad surprises if you rotate the flywheel afterwards.
 * Use Ctrl-A->Apply scale and rotation on all mechanical parts in object mode.

We need an object which follows the rotation of the flywheel. We use an Empty, which is parented to a Vertex.
 * Change to edit mode of the flywheel. Select a Vertex in the middle of the crank.
 * Move the cursor to the Vertex (Shift-S->Cursor->Selection).
 * Change to object mode and insert an Empty (ERotation).


 * Change back to edit mode of the flywheel. The vertex is probably already selected, now select with Ctrl-RMB the Empty and press Ctrl-P->Make vertex parent (Image 2).

 We need two more Emptys:
 * Place the second Empty (EGelenk) in the center of the joint between Rod and Piston.
 * Place the third Empty (ESteuerung) near to the joint.
 * Now select at first EGelenk, than Shift-RMB ESteuerung and parent EGelenk to ESteuerung with Ctrl-P.

We're going to insert two armatures, each with two bones. The first armature, helps translate the rotation to a horizontal movement. The second armature drives the Piston and the Rod. The cursor should be positioned at the Empty ERotation (like in Image 3), else set it there.


 * Add an armature (AHelfer). The root of the first bone (BHelfer1) has the same position as ERotation, the tip has to be positioned to the Empty EGelenk (select Empty first, Cursor->Selection, than select bonetip, Selection->Cursor).
 * Extrude another small bone (BHelfer2) in horizontal direction.

BHelfer2 is automatically Child of BHelfer1. The second armature that is driving the movement of piston and rod will be inserted in the opposite direction, i.e. from right to left in our example.

Connecting the two bones will ensure that the rod cannot disconnect from the piston.
 * Position the cursor on the piston.
 * Add an armature (AGestaenge).
 * Move the tip of the first bone (BKolben) to EGelenk.
 * Extrude the first bone and place the tip of the second bone (BPleuelstange) to ERotation.



Now we're going to add the "logic". Now the root of the bone BHelfer1 follows the rotation of the Flywheel. Its tip follows the joint, but with slight deviations upwards and downwards. The position of BHelfer2 governs the horizontal position of the Piston. We just have to "extract" the horizontal position, for that we're going to use a CopyLocation constraint, but only in Y-direction. There is no offset for a copy location constraint - else we could have done with one empty less.
 * Add a Copy Location constraint to BHelfer1 which points to ERotation. To do this change to the pose mode of the armature AHelfer and select BHelfer1. In the Constraints panel click Add Constraint->Copy Location and type ERotation into the Ob: field.
 * BHelfer1 needs a second constraint: Track To to EGelenk (Image 5).


 * ESteuerung gets a CopyLocation constraint in Y-direction to AHelfer->BHelfer2. You have to inactivate X and Z (Image 6).
 * Make ESteuerung the parent of AGestaenge.

The armature AGestaenge gets its horizontal movement from BHelfer2 via ESteuerung.

Nearly finished:
 * Give BPleuelstange a Track To constraint to ERotation.
 * Parent the piston and the rod (the meshobjects) to their bones.



Overview about the relations between armature bones and objects



 * Schwungrad is vertex parent of ERotation.
 * BHelfer1 has a Copy Location X/Y/Z constraint to ERotation.
 * BHelfer1 has a Track To Constraint to EGelenk.
 * ESteuerung has a Copy Location Y constraint to BHelfer2.
 * ESteuerung is parent of AGestaenge.
 * ESteuerung is parent of EGelenk.
 * BPleuelstange has a Track To constraint to ERotation.
 * BKolben is parent of Kolben.
 * BPleuelstange is parent of Pleuelstange.

The Parent-Child relations between the bones are inserted automatically through extruding, you have to insert the other relations yourself.



Finishing Touches
The driving object is the flywheel, all the other movements are synchronized with its rotation.
 * Animate the rotation of the flywheel.

If you've done everything right, your animation should look like in Image 8.



Links
The German original of this tutorial (same author)

Another method using constraint system