Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'Free-Fall' mode for Rope
#1
Is there any way to set a rope to not stretch at all and to extend more rope whenever it's pulled? A mode where there is never any strain or tension, and the rope is in a free-fall state, where even gravity will pull on the rope. It's also important to be able to turn this mode off without a sudden spring-back behavior in the rope.

- I've tried using a temporary Obi Handle for the end of the rope, and set the rope's length to the distance between the rope's start & end before disabling the handle; but this didn't help with the spring-back problem.

- I've also tried increasing the rope's length any time the strain (calculated using Rope.CalculateLength() / Rope.RestLength) passes 1. This however was not stable or precise, which made it unfavorable.

This is currently the one thing stopping me from being able to use Obi in my product & it would make my day if I could find a solution for this.
Reply
#2
(02-10-2017, 05:52 PM)basilfamer Wrote: Is there any way to set a rope to not stretch at all and to extend more rope whenever it's pulled? A mode where there is never any strain or tension, and the rope is in a free-fall state, where even gravity will pull on the rope. It's also important to be able to turn this mode off without a sudden spring-back behavior in the rope.

- I've tried using a temporary Obi Handle for the end of the rope, and set the rope's length to the distance between the rope's start & end before disabling the handle; but this didn't help with the spring-back problem.

- I've also tried increasing the rope's length any time the strain (calculated using Rope.CalculateLength() / Rope.RestLength) passes 1. This however was not stable or precise, which made it unfavorable.

This is currently the one thing stopping me from being able to use Obi in my product & it would make my day if I could find a solution for this.

You're going to need to use the ObiRopeCursor with your rope. You can see an example in the Crane scene. To see if the rope being stretched to start expanding your rope you can do something like this:


Code:
public bool IsStretchingRopeGreaterThanResistance(float resistanceMultiplier)

        {
            ObiDistanceConstraintBatch distanceBatch = Rope.DistanceConstraints.GetBatches()[0] as ObiDistanceConstraintBatch;
            float[] forces = new float[distanceBatch.ConstraintCount];
            Oni.GetBatchConstraintForces(distanceBatch.OniBatch, forces, distanceBatch.ConstraintCount, 0);

            for (int i = 0; i < forces.Length; i++)
            {
                float p1Resistance = Rope.tearResistance[distanceBatch.springIndices[i * 2]];
                float p2Resistance = Rope.tearResistance[distanceBatch.springIndices[i * 2 + 1]];

                // average particle resistances:
                float resistance = (p1Resistance + p2Resistance) * 0.5f * resistanceMultiplier;

                float force = -forces[i] * 1000;

                if (force > resistance)
                {
                    return true;
                }
            }

            return false;
        }
Reply
#3
@Nizmo,


Thanks for your reply. We were actually using that method at first, extending from the ApplyTearing() script in ObiRope, and we are definitely using a Cursor, since this is required for extending the rope. We followed the Crane example very closely before attempting anything.

Determining whether or not there is strain is not the issue, it's what to do in order to relieve strain at all times.
Reply
#4
(02-10-2017, 11:33 PM)basilfamer Wrote: @Nizmo,


Thanks for your reply. We were actually using that method at first, extending from the ApplyTearing() script in ObiRope, and we are definitely using a Cursor, since this is required for extending the rope. We followed the Crane example very closely before attempting anything.

Determining whether or not there is strain is not the issue, it's what to do in order to relieve strain at all times.

Hi!

It is highly unlikely that ObiRope will support something like this out of the box in the future, as it is a very specific use case.

Depending on what you want to do, there might be better solutions to this. Calculating the entire rope's strain but then trying to minimize it by changing the length of only 1 constraint -the one directly affected by the ObiRopeCursor- is acceptable for some uses, but certainly not 100% physically accurate and will result in sudden "jumps" if used in this particular scenario.

Suppose you need an infinite rope to constantly fall from the top to the bottom of the screen, in 2D (this is a long shot and probably not exactly what you're looking for, but taking advantage of the limitations imposed by a particular scenario will oftentimes simplify things):

For every particle that goes out of the screen trough the bottom, spawn a new one at the top. (link constraints appropriately, like ObiRopeCursor does, and spawn the new particle from the rope's particle pool, also copy the velocity from the bottom particle and apply it to the one you just spawned). Then, return the particles that went trough the bottom to the rope's particle pool. Depending on where you spawn the new particles at the top, the behavior of the falling rope would be different.

This is a relatively simple approach that doesn't require to deal with physics calculations at all, and would result in an infinitely long, free-falling rope. Hopefully it will inspire you to try some other approaches. 

cheers!
Reply