#It’s a bit late right now where I am so
1 messages · Page 1 of 1 (latest)
thanks for your response! I've actually figured it out! or at least a good enough solution for my purposes.
I actually ran into the same issue of it constantly springing back and forth.
i'm sure you're familiar with the typical approach to length constraints, in which the Sticks try to stay at the target length.
My initial appoach of setting the stiffness value to 1.0 when the length is outside of the min max range was ALMOST there, but resulted in the back and forth spring.
The missing part of this solution was this!
self.length = maxLength
if dist < minLength:
self.length = minLength```
here, if the length is over, it's length target is maxLength, if it's under, minLength
having this length constraint does two things to improve my simulation:
- it allows me to make pseudo "Angle Limits" for a joint (limiting distance of adjacent points) . this allows for rope that doesn't "cross over" itself (without having to do self collision). This is important for generating a quad strip mesh over top of it, as crossing over itself would flip the "out" vector.
- it allows for soft structures that can deform nicely without totally collapsing in on themselves. I had approached this before using a X structure for extra support, but it could still collapse under certain forces.
here are some WIP videos!
as a fun side effect of the angle limit, the rope can bunch up + "roll out"
Oooo that’s a nice solution! Glad it works!
I’m a little confused how you are controlling the length of individual segments, when you change an individual segments length suddenly i feel like should there be some kind of jerking effect on the rope but it seems perfectly smooth. What step of the simulation process do you alter segment length?
I really like this approach, I bet you could get an even smoother looking rope with the same code if you interpolated between the points with quadratic splines instead of line segments. Might get rid of a lot of the pointedness of the rope while still maintaining the nice behavior you have
Catmal rom spline I think would work well here, sadly I don’t know too much about splines besides some names lol
Ah dang this is making me want to get back into the project I was working on
the process looks like
Apply external forces to points (wind, dragging, etc)
apply line length constraints (iterating multiple times for a more accurate solve. I found this to be required for fully "stiff" constraints, and min/max constraints. in order to still support stiffness less than 1, I divide the stiffness by the iteration count)
Adjust collisions
with only 1 iteration for ApplyConstraints(), even at 1 stiffness, it has a small amount of bounce to it. And strong forces stretch it dramtically. I'm using 15 iterations in that rope example.
Also i've had the same thought about splines!
It's something i may consider in the future, but for now i'll leave it at 1 mesh quad per "stick" for simplicity.
Here are some resources that have been extremely helpful in figuring this stuff out!
https://toqoz.fyi/game-rope.html
probably the most comprehensive explainer of verlet integration for rope. And an extremely useful technique of manipulating a procedurally generated mesh in shader by passing in an array of verlet point positions.
http://graphics.cs.cmu.edu/nsp/course/15-869/2006/papers/jakobsen.htm
what seems to be the OG paper on verlet integration for use in games, as it's referenced by most other resources i found.
https://youtu.be/-GWTDhOQU6M?si=CxPhTZSjbi678RkE
super great video tutorial, explaining why verlet integration is especially useful in these types of simulations over other methods.
And a simplified code example in p5.js
Oh hey I used that first blog as a huge resource as well