Help Getting particle connections - 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: Help Getting particle connections (/thread-2140.html) |
Getting particle connections - SpiralCircus - 03-04-2020 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? RE: Getting particle connections - SpiralCircus - 05-04-2020 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? RE: Getting particle connections - josemendez - 05-04-2020 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; 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. RE: Getting particle connections - SpiralCircus - 05-04-2020 (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); RE: Getting particle connections - josemendez - 05-04-2020 (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. RE: Getting particle connections - SpiralCircus - 06-04-2020 (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. RE: Getting particle connections - josemendez - 06-04-2020 You're welcome |