Forums > Jitter

Particles, drawing conditional connections?

Mar 10 2014 | 10:08 am

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, or to format a vertex position matrix for

Any ideas for efficient approaches?

Mar 10 2014 | 3: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()


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]);


function dist(v)
d = v;


Mar 10 2014 | 3:24 pm

(Btw, the forum’s code tag is malfunctioning there)

Mar 12 2014 | 3: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 | 8:46 am

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.


Mar 12 2014 | 9:51 am

…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 | 10:00 am

just found the patches from Wes…happy days:)

Viewing 7 posts - 1 through 7 (of 7 total)

Forums > Jitter