Wednesday 27 February 2013

Processing experiments with flocking

For the past 2 days I have been intensively into Processing. I've spent about 20 hours out of the past 48 coding.
The result has been that I've created a few Processing sketches, all on the subject of "flocking". Each of the boids detects the proximity of its peers and steers towards the average direction of the "flock". They also repel each other, and attract towards each other to form the "flocks". When the boids collide they both take a new vector of the average sum of the previous ones.
For some of these sketches, colour is controlled by the weighted number of nearby boids, some of them alpha is the attribute thats modified, and for all of them diameter/size is also controlled by size of the flock.

For colourising the main 3D sketches I mapped the boids location in 3D space to control the values of RGB. There is also basic user interface for the 3D sketches, allowing the user to change colour modes between B&W, Blue & Black, and Rainbow, and to change the camera mode between spiral rotation, level rotation, and mouse rotation. There is also facility to pause the camera so the user may examine the flocking inside the cube.
The 2D sketches respond to mouse gestures and the boids repel away from the mouse.

Also most of the 2D sketches are js compatible and you can view one of them here, its #04.

I used heavily modified code from these locations:
http://www.openprocessing.org/sketch/47022
http://processing.org/learning/topics/flocking.html


3D sketches


Video of 3D Flocking Demo


2D sketches

No comments:

Post a Comment