4
$\begingroup$

I'm trying to simulate the physics of a string that wraps around a motor spool when the motor turns. The body of the motor and the shaft+spool defines a motor constraint, so a velocity can be applied to animate the spool. I modeled the string using this tutorial : https://www.youtube.com/watch?v=4ANT5vf5H-Y&t=310s

This is how the scene looks like at keyframe 0 String position at keyframe 0

And after a few frames, the string doesn't wraps around the spool but goes through instead, there is no collision:

enter image description here

And if I set the string to soft body, then it does this: enter image description here

Is there a way to achieve a nice winding of the string around the spool ? (even wrapping a few turns so having the string to collide against itself the 2nd turn) Thanks :)!

EDIT

Following AdamTM suggestion, I made a string from a curve path, and hook the end vertice to the spool, and add Soft Body physics with the following parameters: enter image description here As we see, when I play the animation, the string seems to curve around the spool, but for some reason, the hook point doesn't stay in place, it does some weird animation and the length has also shrunk a lot.

I've done another test from scratch with a bigger scale, and the result is much better. In this case the string falls from above and nicely wraps around the shaft as it turns : enter image description here

I think the physics parameters has to be very well tune to work at smaller scale.

I couldn't attach the soft body end to the shaft, so I tried with a cloth simulation : enter image description here

I defined a vertex group with end vertices, and hooked it to an empty (ctrl+H), added the pinning option to the vertex group in the cloth parameters, then made a shaft middle vertex as parent of the empty. As we see on the picture the cloth wraps around the shaft and is well attached to it. But somehow the animation doesn't look quite right, not as nice as when using a bezier path with a soft body.

Any idea how to get the nice wrap of the previous string, with the pin point of the cloth simulation ?

Alternatively, using the Molecular add-on seems quite promising : https://www.youtube.com/watch?v=XSPwM8Yv6YE

Here is the blender project file :

$\endgroup$
  • $\begingroup$ I'm not sure its possible to do this properly as the physics are defined in your method by the empties. I would try using a curve instead with softbody physics. My concern still would be that there will be no friction coming from the curve to give you that wrap-around you are looking for, but you would have to try. $\endgroup$ – AdamTM Jul 25 '17 at 9:30
  • $\begingroup$ @AdamTM I've tried your idea, it's better, but I'm still having some weird physics effects. Any idea how to improve and fix the length of the string ? $\endgroup$ – Cyril_J Jul 25 '17 at 16:04
  • $\begingroup$ If you have any modifiers on the spool, try to apply them. Additionally increase the amounts of control points on the string. Alternatively post your blend so we can see whats going wrong. $\endgroup$ – AdamTM Jul 26 '17 at 9:37
  • $\begingroup$ @AdamTM thanks! I've tried at bigger scale with more subdivision and it wraps nicely, with self-colision. I'll see now how I can attach it. $\endgroup$ – Cyril_J Jul 26 '17 at 18:58
  • $\begingroup$ @AdamTM I've updated my post. Is it possible to send the blender file with drag and drop like pictures or does it have to be an online link ? $\endgroup$ – Cyril_J Jul 27 '17 at 9:17
4
$\begingroup$

The simplest way to simulate rope or string is using a Soft Body simulation on a row of vertices and add thickness with Skin and Subdivision Surface modifiers. You can use the Soft Body Goal to pin one end to the spindle - similar to your example.

Looking at your Blend file it appears that there is a problem with your parenting of the 'hook' point - it appears to pass through the surface of the spindle and this could be interfering with your simulation (as it will drag the 'string' through the surface rather than resting on it.

The accuracy of the simulation is determined by the number of verticies in the soft body mesh (more vertices will give a better simulation but will take longer to calculate) and the Soft Body Solver settings (in particular the number of 'steps' and the 'Error Limit').

Start by creating the 'string' of vertices. The simplest way of achieving this is to create a Path (Add/Curve/Path) and convert it to a mesh (Object/Convert To/Mesh from Curve). Create a Plane for it to fall on, with Collision enabled in the Physics properties.

simple string setup

Rotate the string by a slight amount so that the vertices don't falls exactly onto each other (or it will unnaturally balance each vertex onto the next), then add Soft Body in the Physics properties. Disable the Soft Body Goal and run the simulation.

simple string animated

To make the string interact with itself, enable the Soft Body Self Collision.

self collision string animated

Adjust the Collision settings until you get the desired effect (eg, increase the Size for a thicker string).

Add a Skin modifier and a Subdivision Surface modifier to give the string some thickness, setting the vertex Mean Radius X and Y when in Edit mode to control the thickness of the Skin modifier.

Skin modifier radius and modifiers panels

thickened string animated

It's important to note here that the 'collision' is not with the actual skinned 'rope' - rather it is with the 'core' of vertices that runs through the middle. The self-collision (rope with rope) is controlled within the Soft Body Self Collision settings but the collision with the 'floor' surface is controlled by the Collision set on that surface (the 'Outer' Soft Body and Cloth property). This means that this method is only applicable to circular soft body objects and that all soft body objects must have the same radius (ie, you can't have two ropes of differing thicknesses).

All that now remains is to pin the rope onto the spindle and this is achieved using the Soft Body Goal and to explain this fully we need to understand how the Soft Body simulation works.

The Soft Body simulation moves the soft body verticies independently of the 'actual' mesh position. This means that the Soft Body vertices can move away from where the mesh vertices that 'spawned' them actually reside. Each soft body vertex has forces applied to it based on a number of factors (such as the distance to its neighbours, proximity to surfaces, etc.) and the simulation engine determines its new location for each frame by resolving these forces - as if springs were pushing and pulling in different directions. One such 'spring' is the Goal - a spring connecting the soft body vertex with the position of the actual object mesh vertex. With the goal enabled the soft body vertex is constantly pulled towards that location. By hooking the vertex to another location this allows us to drag the associated soft body vertex to that location - which can then be pinned to, say, a rotating spindle. The strength and presence of these 'goal' springs can be controlled by a Vertex Group.

In the example blend file I notice that the Empty used to pin the rope to the spindle is parented to a Vertex, not the parent object. As vertices do not convey any rotation data (they are simply a point in space), this means that the movement of the empty does not properly follow the expected motion around the spindle - it starts outside the spindle but crosses to inside as it travels around. Because it passes inside the spindle mesh this will interfere with the collision and causes unexpected issues with the soft body passing through the spindle. To resolve this, change the Parent Relation from 'Vertex' to 'Object' or '3 Vertices' and re-position the empty back to its start location (both these options include rotational data and so will keep the hook point relative to the outer surface of the rotating spindle). The hook point should now correctly move around the outside of the spindle.

To hook a vertex of the soft body simulation requires the following further steps.

  1. Select the soft body mesh and go into Edit mode (Tab). Select the vertex to act as the hook, create a new Vertex Group, assign that vertex to the Vertex Group.

add vertex to vertex group

  1. In Object mode, select the Empty to use as the hook. Hold Shift and click the soft body to select it (you should now have both the empty and the soft body mesh selected). Go into Edit mode (Tab) and select the vertex to hook and press Ctrl+H to bring up the Hook menu, select 'Hook to Selected Object'. And back to Object mode (Tab).

  2. In the Soft Body, enable the Goal settings and set the Vertex Group to the Vertex Group created in the first step.

  3. Check the order of the Modifiers on the Soft Body object - the Hook modifier must be above the Soft Body modifiers for the Soft Body Goal to take account of it's hooked location.

Rotating the spindle should now drag the soft body vertex around the spindle. Assuming the Spindle has been given suitable Collision properties the rope should lay on its surface and wrap around, colliding with itself (due to the Self Collision) as it accumulates on the spindle.

If the simulation is not accurate then there are a number properties that can be adjusted to help. It's a good idea to always adjust a single property at a time, evaluating the result before adjusting anything else (otherwise you won't know what had the effect). This also means that if you change something that makes the simulation worse it's easy to take a step back to try something else.

  1. If the Soft Body rope is too angular as it wraps around, subdivide the mesh further to provide more vertices.
  2. If the rope between vertices are passing through the spindle or the rope passes into itself, enabled Collision Edge in the Soft Body Edges settings.
  3. If the simulation is erratic, adjust the Soft Body Solver settings (one at a time). eg, decrease the Error Limit, increase Max Step, increase Min Step - these settings can significantly affect calculation times for the simulation. It's not uncommon to adjust these settings by a factor of 10 or more to improve the simulation. eg, Error limit 0.01 or even 0.005 or lower, Max Step 3000 or more, Min Step 100 or more. The trick is to increase them enough to improve the simulation while still keeping the calculation time within acceptable limits.

In addition to this it may help to adjust the Soft Body settings to improve stability. Again, adjust one thing at a time - by small amounts initially try progressively larger amounts if necessary. Soft Body Goal - can increase 'Default' somewhat to make the goal 'spring' stronger (so it's tied more firmly to the goal), adjust Stiffnesss and/or Damping to prevent 'bouncing' around the goal. Soft Body Edges - increase the Push and Pull springs to make them less flexible (so there's less stretch). Damping can slow down 'bouncing', Bending will make the rope less flexible. Enable 'Edge' collision for better collision detection (make edges collide rather than just vertices) - this can cause the simulation to take considerably longer to calculate.

Another thing to note is the Collision physics Soft Body settings. For small objects or fast moving vertices these become very important.

original collision settings

Note the Soft Body and Cloth settings - Outer and Inner - it's important to understand what they mean. For the Soft Body simulation, Blender calculates the new location of each vertex on each 'Step' of the animation. If the new location is within a surface then Blender will apply a repulsive force along the surface normal to repel that vertex. The 'Outer' setting controls how far off the surface the repulsive force starts to have an effect. The 'Inner' setting controls how far below the surface the repulsive force has an effect. For a vertex collision to take place it must 'hit' these collision zones otherwise it will pass straight through (if it's moving too fast, for example) - so larger zones usually produce a better simulation. However, it's also important that zones do not overlap. In the case of a small object like a spindle you should ensure that the Inner collision zone is not too deep as it can cause unexpected behaviour (see below).

Finally, fine tune the Self Collision, the Spindle Collision Outer, and the Skin radii to adjust the thickness of the 'rope' and its interaction with the surface.

Using your Blend as a start point I produced the following animation (after creating a fresh rope as detailed above and changing the parenting of the hook point to 'object') :

animated final

This was using the following Soft Body settings :

soft body settings

Spindle collision :

collision settings

Spindle hook point parenting :

hook point parenting

Note that I reduced the 'Inner' setting of the collision of the spindle - since the spindle is only 0.21 blender units in diameter, the default collision properties of 0.2 results in the collision zones from the front and back faces to overlap to that the opposite side 'inner' ends just 0.01 units below the upper surface. This means that if the 'rope' intersects with the spindle by by more 0.01 then it will be considered further below the opposite surface that it is below the upper surface and is dragged through the spindle. Reducing the Inner to 0.1 removes the overlap, giving a better simulation.

In addition, a stretchy and/or heavy soft body simulation will store up a lot more energy as it falls which can drag the upper vertices further through the spindle, further compounding the collision issue. This can be reduced by either decreasing the Mass of the soft body (in the main 'Soft Body' properties) or increasing the Soft Body Edges Pull/Push Springs closer to 1.0.

Blend file attached.

$\endgroup$
  • 1
    $\begingroup$ One of the best answers ever. $\endgroup$ – batFINGER Nov 2 '17 at 17:34
  • 3
    $\begingroup$ @Rich Sedman : Thank you very much for taking the time to write this great detailed answer and tutorial ! This is exactly the result I was searching for, and it helps a lot to understand the mechanisms and parameters. $\endgroup$ – Cyril_J Jan 15 '18 at 20:03
  • $\begingroup$ @Cyril_J You’re welcome - glad to be able to help. I really enjoyed investigating this issue and learned a lot about soft body and collision along the way. $\endgroup$ – Rich Sedman Jan 15 '18 at 20:30
  • $\begingroup$ Absolutely. This is great. Can't believe I'm only the third upvote. @RichSedman I'm curious about how you research some of the real nitty gritty stuff...e.g. what practical effect a particular soft-body setting has. Any go-to sources that might not be that well known? Or is it pretty much the usual suspects (e.g. Blender manual and this site plus trial-and-error)? Cheers. $\endgroup$ – B Layer Nov 7 '18 at 13:54
  • 1
    $\begingroup$ Thanks @BLayer. It's mostly just a case of trial and error and lots of perseverence - to build up the knowledge and techniques bit by bit - although sometimes dipping into the source code helps (eg, git.blender.org). $\endgroup$ – Rich Sedman Nov 7 '18 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.