Using Array Limits to position Particles
in
Contributed Library Questions
•
7 months ago
Javier (jacracar) has been extremely helpful in directing me toward the ability to implement a particle generator emitting particles from interactive movement captured via Kinect. I have tried to contact him regarding more questions, but I don't want to bother him as I have a feeling he is busy any may not be able to offer any more help.
I would like to be able to create similar visual effects as these:
and
I believe the Midas Project is using VVVV and the Christian Mio video is using processing with MSAfluid.
I've been experimenting with various sketches trying to figure out how to incorporate *any* particle generator with moving humans using the Kinect. As a non-programmer, I'm still struggling with some things.
The sketch that Javier was so gracious to post in the forums here is this one which works fine, but Javier suggested that I "
Use the array limits[] to position your particles" but I am at a loss as to what that entails:
- import SimpleOpenNI.*;
- SimpleOpenNI context;
- ArrayList limitsList = new ArrayList();
- void setup()
- {
- context = new SimpleOpenNI(this);
- context.enableScene();
- size(context.sceneWidth(),context.sceneHeight());
- }
- void draw()
- {
- context.update();
- PImage sceneImg = context.sceneImage();
- limitsList.add(obtainLimits(sceneImg,color(0)));
- if(limitsList.size() > 10){
- limitsList.remove(0);
- }
- background(150);
- for(int i = 0; i < limitsList.size(); i++){
- PVector[] limits = (PVector[]) limitsList.get(i);
- stroke(color(25*i,0,0));
- for(int j = 0; j < limits.length; j++){
- point(limits[j].x,limits[j].y);
- }
- }
- }
- PVector[] obtainLimits(PImage img, color bgCol){
- img.loadPixels();
- ArrayList leftRightLimits = new ArrayList();
- ArrayList upDownLimits = new ArrayList();
- for(int y = 0; y < img.height; y++){
- color prevCol = bgCol;
- for(int x = 0; x < img.width; x++){
- color col = img.pixels[x + y*img.width];
- if(col != prevCol){
- if(col != bgCol){
- leftRightLimits.add(new PVector(float(x),float(y)));
- }
- else{
- leftRightLimits.add(new PVector(float(x-1),float(y)));
- }
- }
- prevCol = col;
- }
- }
- for(int x = 0; x < img.width; x++){
- color prevCol = bgCol;
- for (int y = 0; y < img.height; y++){
- color col = img.pixels[x + y*img.width];
- if(col != prevCol){
- if(col != bgCol){
- upDownLimits.add(new PVector(float(x),float(y)));
- }
- else{
- upDownLimits.add(new PVector(float(x),float(y-1)));
- }
- }
- prevCol = col;
- }
- }
- ArrayList combinedLimits = new ArrayList();
- for(int i = 0; i < leftRightLimits.size(); i++){
- boolean repeated = false;
- PVector l1 = (PVector) leftRightLimits.get(i);
- for(int j = 0; j < combinedLimits.size(); j++){
- PVector l2 = (PVector) combinedLimits.get(j);
- if(l1.dist(l2) == 0){
- repeated = true;
- }
- }
- if(!repeated){
- combinedLimits.add(l1);
- }
- }
- for(int i = 0; i < upDownLimits.size(); i++){
- boolean repeated = false;
- PVector l1 = (PVector) upDownLimits.get(i);
- for(int j = 0; j < combinedLimits.size(); j++){
- PVector l2 = (PVector) combinedLimits.get(j);
- if(l1.dist(l2) == 0){
- repeated = true;
- }
- }
- if(!repeated){
- combinedLimits.add(l1);
- }
- }
- return (PVector[]) combinedLimits.toArray(new PVector[combinedLimits.size()]);
- }
Say, for instance, I wanted Memo's MSAfluid (
http://www.memo.tv/msafluid/) particles and have the human form be the particle generator (instead of the cursor), would I be able to somehow reference the msafluid sketch from this sketch that Javier has offered? Or even something much simpler like *any* kind of particles coming off the array limits that would replace the red outlined echo effect?
I am using Windows7 with Processing 1.5.1 and the Kinect for Windows, would it be better to use the latest Processing version?
- James
1