Wednesday, 12 January 2011

the code

Here is a download link for my code, and the images with it: http://www.sendspace.com/file/dtvrw5

visualisation

Here's a little visualization I knocked up depicting what the sketch would look like in real life.

Monday, 10 January 2011

deciphering the code

As my code is very much finished I thought I'd post some of it up and explain what certain bits do.

void setup()
{
frameRate (30);
shoe = loadImage("shoe.png");
size(640, 480, OPENGL);
int counter =0;

hint(ENABLE_OPENGL_4X_SMOOTH);
hint(DISABLE_DEPTH_TEST); //These two bits help with making the sketch run faster

for(float x=0; x<8; x++)
{
for(float y=0; y<6; y++)
{
Nike particle = new Nike();

particle.target.set(x*random(70,95), y*random(70,95), 0); //Sets out a grid for the particles, which then fill that grid when drawn
particle.pos.set(x*random(70,95), y*random(70,95), 0);

particles[counter] = particle;
counter ++;
}

}

opencv = new OpenCV( this ); // Initialises the OpenCV object
opencv.capture( 160, 120 ); // Opens a video capture stream
}


That's the setup.

for(int i=0; i {
Nike particle = particles[i];
if(brightness(img.get((int)particle.pos.x/4, (int)particle.pos.y/4))>15)
{
particle.vel.add(random(-2.7, 2.7),random(-2.7, 2.7), 0);
particle.alph-=50;
}

if(brightness(img.get((int)particle.pos.x/4, (int)particle.pos.y/4))<15)
{
particle.vel.add(random(-0.2, 0.2),random(-0.2, 0.2), 0);
particle.alph+=0;
}


This bit of code, placed in the draw setup, tells the sketch to look for areas in the difference image where the brightness is more than 15, if it is more than 15 then it adds a random value from -2.7 to 2.7 in velocity to any particles that are in the area of brightness. It also takes away 50 from the alpha value of that particle.

As well as that, if the brightness is less than 15 then it adds only a slight velocity value, but then adds 0 to 'alph' ('alph' is set to 1) so that the particle slowly fades back in.

alph+=1;

if(alph>255)
{
alph=255;
}

if(alph<0)
{
alph=0;
}


This bit of code in the Nike class sets the 'alph' parameters so that the values never get so high/low that the particles wont disappear/reappear when their required actions are performed.

Saturday, 8 January 2011

the particles...

As my frustration grew ever so much during this period of development I thought I'd showcase some of the terrible results.

Mouldy Wotsits



Pollution



Melting Simpson

Tuesday, 4 January 2011

further progress

After deciding on the final background image I started work on the particles again. I have now made them look more 'misty' and have therefore removed the use of gold in them, as the background image now features that colour. It took A LOT of tweaking to get an image I was happy with, and I think it looks very effective.