7
$\begingroup$

I have a generic spring constraint between two objects. I am able to set the stiffness and damping of the spring, but I would also need to set what length the spring initial was.

Blender now wrongly assumes that the current position is the original length, but in my world the spring should now be stretched some.

enter image description here

Here is an example. Two boxes connected with a spring constraint that only allows movement in the Z direction. When playing this animation, the lower cube will fall down. What I want, however, is that Blender consider the spring now already stretched, so it will have some more force acting upwards.

How can I achieve this?

$\endgroup$

2 Answers 2

2
$\begingroup$

The spring constraint is anchored by the Empty that it lives on. You may be forced to start the objects in the pre-gravity position, and then animate them to move from that position to the stretched rest position in frame 2. Then you can deactivate the Animated checkbox with another keyframe and let the simulation take over.

[editing to address questions in the comments:]

The Animated checkbox can be found in the Rigid Body subsection of the Physics section of the Properties view for the object. The Animated checkbox can have keyframes (so you can give it a keyframe at frame=1 to start it out checked, and then give it another keyframe to uncheck it whenever you need it to switch over to physics simulation).

As for the multi-spring scenario, you may have an incontrovertible point. I consider it possible to construct a set of spring linkages which could have no zero-tension rest position, and can only be expressed using a baseline tension parameter which blender appears to lack.

Although now that I think about it more, I am imagining a scenario where the spring tensions are set for empties that start out unattached, but then are bound to the target object later in the animation (using the Enabled checkbox in the rigid body constraint in the physics section). My physics demo catalog contains several examples where constraints are temporarily disabled. This would still require considerable ingenuity and a non-trivial amount of math to arrange.

$\endgroup$
4
  • $\begingroup$ I'm not sure this will work. I have multiple springs attached to some of the objects, and no way for the object to be in a position in which all the springs are in a resting position. i.imgur.com/8EzWDP0.png In this case, the left and right object is again connected to something else, so I can't move them inwards. And there is no place for the middle object to set a initial length for the springs. $\endgroup$
    – Matsemann
    Commented Jan 28, 2015 at 17:25
  • 1
    $\begingroup$ Just tested it, your method works for situations where it's possible to have a default state in frame 1, and then move everything into the correct position in frame 2. I had to press I with the mouse above the Animation checkbox to record the toggling of it. It also seems like I have to add an extra frame that's just a copy of frame two before turning off animation, otherwise thing will have a velocity when enabling dynamics. $\endgroup$
    – Matsemann
    Commented Jan 28, 2015 at 17:42
  • $\begingroup$ Thanks for your updated answer. Would it be possible to add the constraint through code instead? Bullet has support for setting an equilibrium point in btGeneric6DofSpringConstraint I think. $\endgroup$
    – Matsemann
    Commented Jan 29, 2015 at 12:04
  • $\begingroup$ I opened a python console in blender and used C.active_object.rigid_body_constraint. <ctrl>-<space> to see what python properties are exposed. None of them seem to be related to an equilibrium point. $\endgroup$
    – Mutant Bob
    Commented Jan 29, 2015 at 15:29
2
$\begingroup$

It is possible use force actuators to unload the springs and model everything at rest. The animation below illustrates this.

unloaded spring demo

There are three cubes on the left and three cubes on the right. Both the blue and red cubes are connected by the same springs. The two blue cubes use force actuators to balance the force of gravity. This unloads the spring so the initial position is the 'at rest' position. The two red cubes on the right only use spring constraints and move from their initial location to new positions. To demonstrate that the springs work correctly, the cubes at the top are held still (while black) and then released (when white) to interact with the sprung cubes.


Instruction to replicate this animation in Blender 2.76

  1. Add two planes to the scene. In the physics tab, enable rigid-body on each plane. Select the animation check box to keep the planes in place.

    plane anim setup

  2. Add 6 cubes to the scene per the setup in the animation. In the physics tab, enable rigid-body for each cube.

  3. Add two empties to the scene.
  4. Parent one empty to each blue cube.
  5. Set the location of the empty to -0.1. This will move the empty to just below the origin of the cube and allow the forces attached to the empty to act on the orgin properly.
  6. For each empty, in the phyics tab, enable force field and set the strength to 230. Set the falloff to tube, set the min to 0, and max to 0.2 for each empty. These settings keep the force to a small area near the empty.

    force field settings

  7. When finished, the empty should be set up as shown below:

    empty setup

  8. Add rigid-body spring constraints between the lower cube and plane, and between the mid-cube and the lower cube.

  9. In the physics tab, the animation check box can be used to hold the upper cubes in place until they should be released.

  10. To refine the simulation, the physics solver iterations can be increased.

    physics setup

  11. To keep the stack from toppling, rigid-body constraints were added to keep all movement to the z-axis.


The blender file for this animation is located at:

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .