Obi Official Forum
How many particles are defined for a given rope ? - 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: How many particles are defined for a given rope ? (/thread-3171.html)



How many particles are defined for a given rope ? - lufydad - 10-11-2021

Hi, I'm looking for a formula to get the active number of particles for a given rope. (using actor.activeParticleCount).

I noticed that it only depended on the blueprint and that the formula looked like :

Resolution * Length of the rope / Thickness
but it doesn't work every time...


RE: How many particles are defined for a given rope ? - josemendez - 10-11-2021

(10-11-2021, 10:15 AM)lufydad Wrote: Hi, I'm looking for a formula to get the active number of particles for a given rope. (using actor.activeParticleCount).

I noticed that it only depended on the blueprint and that the formula looked like :

Resolution * Length of the rope / Thickness
but it doesn't work every time...

There's not a closed formula that given rope length/resolution returns the number of particles in it, as this also depends on the shape of the rope, and specifically control point placement.

The blueprint is made of catmull-rom curve segments (aka "spans"). Each curve span calculates its own number of particles as:

Code:
particlesInSpan = 1 + Mathf.FloorToInt(spanLength / thickness * resolution);

Then the distance between particles is adjusted as:

Code:
float distance = spanLength / particlesInSpan;

This ensures there's always a particle at each blueprint control point (the point where two consecutive spans meet). However it also causes particle spacing (distance between particles) to vary slightly between spans. You can see the code used in ObiRopeBlueprint.cs, lines 52-82.

let me know if you need further help Sonrisa


RE: How many particles are defined for a given rope ? - lufydad - 10-11-2021

(10-11-2021, 10:32 AM)josemendez Wrote: There's not a closed formula that given rope length/resolution returns the number of particles in it, as this also depends on the shape of the rope, and specifically control point placement.

The blueprint is made of catmull-rom curve segments (aka "spans"). Each curve span calculates its own number of particles as:

Code:
particlesInSpan = 1 + Mathf.FloorToInt(spanLength / thickness * resolution);

Then the distance between particles is adjusted as:

Code:
float distance = spanLength / particlesInSpan;

This ensures there's always a particle at each blueprint control point (the point where two consecutive spans meet). However it also causes particle spacing (distance between particles) to vary slightly between spans. You can see the code used in ObiRopeBlueprint.cs, lines 52-82.

let me know if you need further help Sonrisa

thank you it's clearer.