Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Getting particle connections
#1
I'm interested in tracing all the particle positions, starting from a control node, and progressing along the length of each connected rope, but I need to stop where there has been a tear. The goal is to model electrical connectivity, via obi-ropes acting as wires.

Given a control point, I'd like to be able to trace along the rope until i reach a tear, finding which parts of the rope are "live" (connected to a power source). The result I want is an ordered list of points which I can use to draw electrical VFX on the screen.

Is there a property on a particle I can use to query it's connections to other particles? Or something in the actor or solver I can use to get this info?
Reply
#2
Perhaps a better way to ask this question is, how are the Obi renderers themselves keeping track of the connectivity between particles? And is that data exposed and accessible to our scripts?

A rope line renderer knows to render two seperate lines after a tear, the solver knows to treat the particles either side of the tear as no longer bound by distance constraints etc. How do we access that data?

Further, how do we tell whether particles are "control points" (i.e. points from the blueprint that can have attachments) or regular points?
Reply
#3
Hi there,

Ropes use elements as a high-level description of connectivity. You can think of an element as the "edge" joining two particles.

Each element is a struct that contains the solver indices of the 2 particles joined by it. You can get a list of elements in the rope by accessing the "elements" array in the rope:
Code:
var element = rope.elements;
Unlike constraints, elements are always guaranteed to appear in this array in the same order as they appear in the rope. So if you find that the second particle of element i is not the same as the first particle in element i+1, you know there's a discontinuity (cut) at that point.

This is what renderers use to render torn ropes.

Quote:Further, how do we tell whether particles are "control points" (i.e. points from the blueprint that can have attachments) or regular points?

A particle group is generated for each control point, containing the index of the single particle at that point. You can find all groups of a blueprint by doing:
Code:
ropeBlueprint.groups

However there's no direct way to tell if a given particle "is a control point", you'd need to iterate over all particle groups to see if the given particle index is part of any of them.
Reply
#4
(05-04-2020, 03:22 PM)josemendez Wrote: Ropes use elements as a high-level description of connectivity. You can think of an element as the "edge" joining two particles.

Thanks, this is exactly the info i needed.

(05-04-2020, 03:22 PM)josemendez Wrote: However there's no direct way to tell if a given particle "is a control point", you'd need to iterate over all particle groups to see if the given particle index is part of any of them.

From what I've manage to play around with so far the first element of the particleIndices array in each of the blueprint's groups gives the index of the particle at a control point. Is this correct?

If so, from that I can build a lookup to test a particle against e.g.
Code:
bool IsControlPoint(int index) => lookup.Contains(index);
Reply
#5
(05-04-2020, 05:10 PM)SpiralCircus Wrote: From what I've manage to play around with so far the first element of the particleIndices array in each of the blueprint's groups gives the index of the particle at a control point. Is this correct?

It is. Particle groups are designed to be able to contain more than 1 particle and for some use cases, they do. But as far as control points go, each control point contains exactly 1 particle, and that is found at the first (and only) entry in the group.
Reply
#6
(05-04-2020, 05:32 PM)josemendez Wrote: It is. Particle groups are designed to be able to contain more than 1 particle and for some use cases, they do. But as far as control points go, each control point contains exactly 1 particle, and that is found at the first (and only) entry in the group.

Great. Thank you. You're super helpful.
Reply
#7
You're welcome Guiño
Reply