How to animate a beating heart?
An animation of a beating heart can be generated using a fixed geometry and armatures to animate the beating. This method is a way to generate the complex motion by animating a few elements.



(Geometry from Blendswap.com - courtesy Bruno Laurencich/elZancudo)



Procedure:


Load heart geometry as a single mesh





Add bones for the left atrium, right atrium, left ventricle, and right ventricle. Place the bones roughly at the center of each of these parts of the heart. These bones will be animated to make the heart pump.





Add bones for the arteries and veins. These bones will keep that part of the heart relatively stationary. The image below shows all of the bones in the model.





Select all of the bones and join them into a single armature. This can be done using ctrl+J after selecting all of the bones.
The armature is connected to the mesh using automatically calculated weights (see armature automatic weights). This allows each bone to affect only part of the mesh in the heart. This is done by selecting the mesh, then the armature, then hitting ctrl+P. The menu which appears will have an option for armature deform with automatic weights. Select that option. 




This will automatically setup all of the weights for the different bones on the mesh. The weights for the 4 bones in the heart are shown below. For finer control, the weights can be edited.






To keep the rest of the heart still the other bones are affecting the veins and arteries. One of these is shown.

 


To simulate the pumping, the bones in the center of the left atrium, the right atrium, left ventricle, and right ventricle are scaled. Over the timeline, these bones are scaled between 0.9 and 1.1. In the animation that follows, the bones in the 4 chambers of the heart are animated by scaling the bones, this causes the rest of the mesh to smoothly pump. Because the other bones are kept in the same position and with the same scale, the veins and arteries stay relatively still. Looking closely at the following animation shows the small changes in the bones driving the changes in the mesh.


 







Adding material properties and rending gets the final result.






The blend file can be downloaded at: