import kaleidoscope.*; import toxi.geom.Vec3D; import toxi.geom.Ray3D; import java.awt.event.MouseEvent; import java.awt.event.MouseWheelEvent; import java.awt.AWTException; import java.awt.Point; /** * Crazy Flocking 3D Birds * by Ira Greenberg. * * Simulates a flock of birds using a Bird class and nested * pushMatrix() / popMatrix() functions. * Trigonometry functions handle the flapping and sinuous movement. */ // flock array int birdCount = 400; Bird[]birds = new Bird[birdCount]; float[]x = new float[birdCount]; float[]y = new float[birdCount]; float[]z = new float[birdCount]; float[]rx = new float[birdCount]; float[]ry = new float[birdCount]; float[]rz = new float[birdCount]; float[]spd = new float[birdCount]; float[]rot = new float[birdCount]; Camera cam; PFont font; void setup(){ size(400, 400, P3D); cam = new WebCamera( this ); noStroke(); font = loadFont( "OratorStd-24.vlw" ); textFont( font ); //initialize arrays with random values for (int i=0; i3){ flapSpeed*=-1; } if (ang<-3){ flapSpeed*=-1; } // ang's run trig functions ang2+=rotSpeed; ang3+=1.25; ang4+=.55; popMatrix(); } }