We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
webcam particles (Read 1229 times)
webcam particles
Jan 20th, 2007, 1:08am
 
hello,

i'm really sorry if the subject had been discussed before but a quick search returned me nothing.

Actually i'm still learning processing and i'm trying to map a simple particle system to a webcam image. I'd like to map each particles to each pixels and that's my pb.

I work with a 320x240 resolution so i need something like 320*240 particles i guess or maybe i can map the particles in a more clever way ?  And i don't really know how to replace each pixel by each particles.

I'm trying that with the JMyron library using the pixel_fun1 example and trying to mess it but i'm quite stuck with that actually.

Thx by advance and thx to you all for making such great things.
Re: webcam particles
Reply #1 - Jan 24th, 2007, 10:22pm
 
maybe it's missunderstandable or my english too bad for explaining what i really want to do ?

but please someone... (i know this kind of questions can be boring) but i need to go deeply into this example in order to understand some kind of concepts and go deeper in the exploration of the world of processing.

thxxxx
Re: webcam particles
Reply #2 - Jan 24th, 2007, 10:51pm
 
It might be fairly straight forwards to do, if you've written a  nice particle class, but slightly more difficult if you're just using arrays.

If you want to have a fixed set of particles (320x240 of them) and update them based on the webcam, then it should be easy, and would go something like:

Code:
myParticleClass Particles=new myParticleClass[320*240];

//in setup()
for(int i=0;i<Particles.length;i++)
{
Particles[i]=new Particle(i%320,i/320,0);
// assuming you've got arguments of x position, y position, colour
}


//in draw
webCamImage.loadPixels();
for(int i=0;i<webCamImage.pixels.length;i++)
{
//update the colour of the particle that
// represents this pixel
Particles[i].colour=webCamImage.pixels[i];
}


If you're just using a bunch of arrays to store them it's slightly more complex setup, but the update is almost the same:

Code:
float[] particlesX=new float[320*240];
float[] particlesY=new float[320*240];
color[] particlesColor=new color[320*240];

//in setup
for(int i=0;i<320*240;i++)
{
particlesX[i]=i%320;
particlesY[i]=i/320;
particlesColor[i]=0; // start off black since no image yet
}

//in draw
webCamImage.loadPixels();
for(int i=0;i<webCamImage.pixels.length;i++)
{
particlesColor[i]=webCamImage.pixels[i];
}


Of course you'll have to do any movement code for yourself, but this should at least let you assign the colours to the particles for whatever use you want.
Re: webcam particles
Reply #3 - Jan 24th, 2007, 11:29pm
 
thx a lot that's exactly what i neeeded Smiley.

many many thx !!!!!

(actually i'm just learning all that stuff as i'm new to this (i.e particle systems mapping), i know it may be sound redundant but just wanna try differents examples to understand how does that work).

thx again JG
Page Index Toggle Pages: 1