import peasy.org.apache.commons.math.*; import peasy.*; import peasy.org.apache.commons.math.geometry.*; import processing.opengl.*; import javax.media.opengl.*; PeasyCam cam; static final float CAM_DEFAULT = 2000; static final float CAM_MINIMUM = 50; static final float CAM_MAXIMUM = 4500; PointCloud cloud; static final int CLOUD_DEPTH = 5; static final float CLOUD_GIRTH = 20000; static final int POINT_LIFETIME = 17500; //15000; Spawner spawner; LinkedList crawlers; static final int NUM_CRAWLERS = 25; static final int CRAWLER_COLOR = 25; static final float CRAWLER_RADIUS = 450;//500; static final float CRAWLER_STEP = 150; static final float CRAWLER_SPREAD = 600; static final int CRAWLER_LIFETIME_MIN = 10000; static final int CRAWLER_LIFETIME_MAX = 25000; LineCloud lines; static final int NUM_LINES = 20000; static final float LINE_SPACE = .01; static final String[] PALETTES = { "palette_psychogreen.png", "palette_redgreen.png", "palette_midwarm.png", "palette_seaturtle.png" }; GameTime time; void setup() { size(645, 645, OPENGL ); GLSetup(); // Draw Settings ellipseMode( CENTER ); strokeCap(ROUND); strokeWeight( .25 ); noFill(); smooth(); time = new GameTime(); cam = new PeasyCam( this, CAM_DEFAULT ); cam.setMinimumDistance( CAM_MINIMUM ); cam.setMaximumDistance( CAM_MAXIMUM ); Fire(); } void draw() { time.Update(); GLDraw(); background( REVERSECOLOR ? 255 : 0 ); ListIterator it = crawlers.listIterator(); while( it.hasNext() ) { Crawler crawler = (Crawler)it.next(); crawler.Update( time ); if ( crawler.IsDead() ) { it.set( spawner.Spawn() ); } } for( int i = 0; i < crawlers.size(); i++ ) { Crawler crawler = (Crawler)crawlers.get(i); crawler.Update( time ); } cloud.Update( time.Delta ); lines.Update( time.Delta ); beginShape( LINES ); lines.AddToShape(); endShape(); } void Fire() { cloud = new PointCloud( CLOUD_DEPTH, CLOUD_GIRTH ); crawlers = new LinkedList(); lines = new LineCloud( NUM_LINES ); spawner = new Spawner( CRAWLER_SPREAD, CRAWLER_RADIUS, CRAWLER_STEP ); for( int i = 0; i < NUM_CRAWLERS; i++ ) { crawlers.add( spawner.Spawn() ); } } /* void Fire() { cloud = new PointCloud( CLOUD_DEPTH, CLOUD_GIRTH ); crawlers = new ArrayList(); lines = new LineCloud( NUM_LINES ); PVector hotspot = new PVector( random(-1,1), random(-1,1), random(-1,1) ); PVector center = new PVector( random(-100,100), random(-100,100), random(-100,100) ); PVector wind = PVector.sub( center, hotspot); wind.normalize(); float scalar = CRAWLER_STEP; Palette pal = new Palette( PALETTES[(int)random( PALETTES.length )] ); for( int i = 0; i < NUM_CRAWLERS; i++ ) { PVector pos = new PVector( random( -CRAWLER_SPREAD, CRAWLER_SPREAD), random( -CRAWLER_SPREAD, CRAWLER_SPREAD ), random( -CRAWLER_SPREAD, CRAWLER_SPREAD )); PVector vel = PVector.add( wind, new PVector( random( -1.2, 1.2), random( -1.2, 1.2 ), random( -1.2, 1.2 )) ); vel.mult( scalar ); crawlers.add( new Crawler( pos.get(), vel.get(), CRAWLER_RADIUS, pal.GetColor() ) ); } } */ void keyPressed() { if( key == ' ' ) { Fire(); } }