## Particles, drawing conditional connections?

Mar 10 2014 | 5:08 pm
Hey, I'm currently playing with 3D particle systems. In the past I have used shiva/vishnu, java code and now gen (tanx for the samples Wes!). I'm looking for a way to draw conditional connecting lines between particles. A basic case would be to connect all particles that are within range x from each other. While I can see this done in java I'm unsure about ways to do it with regular objects and/or gen.
I think I'd need a way of iterating through the particles and build a command list for jit.gl.sketch, or to format a vertex position matrix for jit.gl.mesh.
Any ideas for efficient approaches?

• Mar 10 2014 | 10:22 pm
Here's a solution using js. Still curious about whether there's a way with gen.
var d = 1.0;
// get the patcher object p = this.patcher;
// get the sketch object var sketcher = p.getnamed("sketchy"); if (sketcher == null){ post("couldnt find sketch object\n"); } else{ post("bind successful\n"); }
// get the field matrix var fieldmat = new JitterMatrix("field");
function bang() {
sketcher.reset();
for(var i = 0; i < 100; i++) {
for(var j = 0; j < 100; j++) {
var p1 = fieldmat.getcell(i); var p2 = fieldmat.getcell(j); var distsum = (p1[0]-p2[0])*(p1[0]-p2[0]); distsum+= (p1[1]-p2[1])*(p1[1]-p2[1]); distsum+= (p1[2]-p2[2])*(p1[2]-p2[2]); //post(distsum+"\n"); if(distsum sketcher.linesegment(p1[0],p1[1],p1[2],p2[0],p2[1],p2[2]);
} } } }
function dist(v) { d = v;
}
• Mar 10 2014 | 10:24 pm
(Btw, the forum's code tag is malfunctioning there)
• Mar 12 2014 | 10:49 am
Still looking for more efficient approaches. The js method above, inside my larger system, can only process 40 particles while maintaining 60fps. Pretty bad on a quad-core 3GHz machine.
• Mar 12 2014 | 3:46 pm
The issue should have been clear to me right away: it's the iterating through the particles. Jitter tutorial 46 exemplifies that well. Matrix op or expr in js is far more efficient.
I 'm now working on a basic particle system with one 'attractor'. Not really an attractor cause what I do is draw a line between 2 particles when both are within range x from the attractor and within range x of each other. I can make it a lot more efficient by calculating the distances from particles to the attractor using the op method of tutorial 46, but then I still can't get around some iteration to check the particles I'm left with after the range check. Depending on how many that is I experience fps dips.
Ideas?
• Mar 12 2014 | 4:51 pm
...and now gen (tanx for the samples Wes!).
Could you please post the link to the samples? And also thanks for the hints so far in this topic...this is something I plan to do in near future.
• Mar 12 2014 | 5:00 pm
just found the patches from Wes...happy days:)