Obi Official Forum
Inner strain at specific position - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Inner strain at specific position (/thread-2117.html)



Inner strain at specific position - fiasko - 26-03-2020

Hey there, 

I'm trying to measure the strain (or force.. or anything equivalent) at a specific point of the rope. Is that possible? Alternatively, the force/strain on a ParticleAttachment would also suffice.

Please note that comparing ObiRope.restLength and ObiRope.CalculateLength() is not working for me because it would also report some strain if one side of the rope hangs down freely (so it's stretched there) whereas the rest of the rope might be flat on the ground and I'm interested in the strain there.

To give some reference what I'm trying to achieve:
The player should be able to drag a "roll" (it's actually a rope of increasing length) of cable, that is attached to a plug one side towards another location and connect it there. I would like to measure the force at the roll to increase the length of the cable there as he walks.

Thanks in advance!


RE: Inner strain at specific position - josemendez - 26-03-2020

(26-03-2020, 04:31 PM)fiasko Wrote: Hey there, 

I'm trying to measure the strain (or force.. or anything equivalent) at a specific point of the rope. Is that possible? Alternatively, the force/strain on a ParticleAttachment would also suffice.

Please note that comparing ObiRope.restLength and ObiRope.CalculateLength() is not working for me because it would also report some strain if one side of the rope hangs down freely (so it's stretched there) whereas the rest of the rope might be flat on the ground and I'm interested in the strain there.

To give some reference what I'm trying to achieve:
The player should be able to drag a "roll" (it's actually a rope of increasing length) of cable, that is attached to a plug one side towards another location and connect it there. I would like to measure the force at the roll to increase the length of the cable there as he walks.

Thanks in advance!

You could use rope elements to measure strain at any point. Elements are a wrapper over distance constraints, basically a struct that holds the following data:

- Solver indices of the two particles held together by the element.
- rest length of the element.
- current constraint force (only set for tearable ropes)
- tear resistance

The rope.elements array contains all elements in the same order as they appear in the rope (so elements[0] is at one end of the rope, and elements[elements.Length-1] is at the opposite end). So you could do (written off the top of my head, untested):

Code:
foreach (var element in rope.elements)
{
float actualLength = Vector4.Distance(rope.Solver.positions[element.particle1],rope.Solver.positions[element.particle2]);
float strain = actualLength / element.restLength;
}



RE: Inner strain at specific position - fiasko - 26-03-2020

Perfect, works like a charm! Thanks!