/** * Flocking * by Daniel Shiffman. * * An implementation of Craig Reynold's Boids program to simulate * the flocking behavior of birds. Each boid steers itself based on * rules of avoidance, alignment, and coherence. * * Click the mouse to add a new boid. */ import oscP5.*; import netP5.*; OscP5 oscP5; NetAddress myRemoteLocation; Flock flock; PVector target; boolean seeking=false; boolean paused=false; boolean heartOn=false; boolean sendOSC=true; int INITIAL_COUNT=25; void setup() { //size(640, 360); size(1280, 720, P2D); /* start oscP5, listening for incoming messages at port 12000 */ oscP5 = new OscP5(this,12000); // the port supercollider is listening on //myRemoteLocation = new NetAddress("127.0.0.1",57120 ); // leo's computer myRemoteLocation = new NetAddress("192.168.0.127", 7400 ); flock = new Flock(); // Add an initial set of boids into the system for (int i = 0; i < INITIAL_COUNT; i++) { flock.addBoid(new Boid(width/2,height/2)); } target = new PVector(); } void sendCoords(int number, float x, float y, float theta) { /* in the following different ways of creating osc messages are shown by example */ OscMessage myMessage = new OscMessage("/bird"+number); myMessage.add(x); /* add an int to the osc message */ myMessage.add(y); /* add an int to the osc message */ myMessage.add(theta); /* send the message */ oscP5.send(myMessage, myRemoteLocation); // print(x); // print(" "); // print(y); // print(" "); // println(theta); } void sendAllBirds() { for(int i=0;i