Is it possible to attach the endpoints of a curve to two spheres, so that the endpoints would always move with the spheres even when moving the spheres independently of each other? Optimally it should also stretch and compress as the spheres move further apart and closer to each other. I'm doing animations of chemical reactions where I'm depicting the bonds between atoms with a curve which should stay attached to the animated atoms and I'd rather not calculate the transformations for the bonds separately.
3 Answers
This is a great case for hooks.
Position your two spheres where you want. Then add the curve between then with the two ends where you want them to touch on the spheres.
In object mode select one of the spheres then select the curve; hit Tab to go in to edit mode. In the curve's edit mode select the end point of the curve on the same end as the selected sphere, then press ctrl H. Choose hook to selected object.
Repeat for the other end of the curve on the other sphere.
Use hooks to attach each end of the curve to a sphere. You will most likely want to set the curve handles to vector so the curve stays straight between the two points.
I would then add a driver to the curve's bevel depth to have it change size based on the distance between the two spheres.
-
$\begingroup$ This is perfect! Any idea how to do this in python? $\endgroup$– MelodiusCommented Jun 25, 2014 at 14:38
-
1$\begingroup$ One modification you could do since that scripted expression is a simple linear expression, you could replace it: Add Modifier to the driver (using the normally-hidden N panel) of a Generator with poly order 1, then set the coefficients. There is a python example in the addDrivers() method at web.purplefrog.com/~thoth/blender/python-cookbook/… $\endgroup$ Commented Jun 25, 2014 at 20:36
Using hooks is a good idea. I'll add that the laplacian deform modifier works well with hooks for creating deformation effects that resemble natural tug. This short video shows the effect of the modifier and how to apply it using hooks. https://www.youtube.com/watch?v=VgiekNOK0Vw I created a simple example to demonstrate how this could be useful for this particular problem. https://www.dropbox.com/s/9dpgvb9ht0bh9vj/laplacian_deform_test.blend
-
$\begingroup$ Your answer is being flagged as low quality due to it's length. Could you add a bit more detail and maybe some examples? $\endgroup$– gandalf3Commented Jul 5, 2014 at 21:37