float rotation = 0; float throb = 0; Worm robert = new Worm(0, 0, 0, 50, 20, 0, 0.6); Worm steven = new Worm(200, 0, 0, 20, 20, PI/2, 0.1); Worm thomas = new Worm(-200, 0, 0, 20, 20, PI/2, 0.1); Cloud[] weather; void setup () { weather = new Cloud[400]; for( int i = 0; i < 400; i++ ) { weather[i] = new Cloud(int(random(-2500, 2500)), int(random(0, 1000)), int(random(-500, 500)), int(random(5, 40))); } size(600, 400, P3D); framerate(50); colorMode(RGB, 1.0); noStroke(); } void draw () { background(0.7, 0, 0); ambientLight(0.75, 0.75, 0.75); directionalLight(1, 1, 1, 200, 200, 0); translate(300, 200, 0); rotateX(4 + sin(rotation/8)*2); rotateY(sin(rotation/14)*2); rotateZ(sin(rotation/11)*2); robert.squirm(); steven.squirm(); thomas.squirm(); for( int i = 0; i < 400; i++ ) { weather[i].drift(); } rotation += 0.05; throb += 0.1; } // Classes class Worm { int posX; int posY; int posZ; float gray; int tubeSize; int tubeHeight; float sinOff; Worm(int _x, int _y, int _z, int _tubeSize, int _tubeHeight, float _sinOff, float _gray) { posX = _x; posY = _y; posZ = _z; gray = _gray; tubeSize = _tubeSize; tubeHeight = _tubeHeight; sinOff = _sinOff; } void squirm() { pushMatrix(); translate(posX, posY-12*tubeHeight, posZ); rotateY(rotation / 2); for( float i=0; i<24; i++ ) { translate(0, tubeHeight, 0); for( float j=0; j<16; j++ ) { rotateY(PI/8); fill(gray); beginShape(); float thisTubeSize = tubeSize+sin(throb+i/8+sinOff)*tubeSize/2; float thisSize = thisTubeSize/(1+sqrt(2)); vertex(thisSize, tubeHeight+5, thisTubeSize); vertex(thisSize, 0, thisTubeSize); vertex(-thisSize, 0, thisTubeSize); vertex(-thisSize, tubeHeight+5, thisTubeSize); endShape(); } } popMatrix(); } } class Cloud { int posX; int posY; int posZ; int rate; int distance = 1000; Cloud(int _x, int _y, int _z, int _rate) { posX = _x; posY = _y; posZ = _z; rate = _rate; } void drift() { pushMatrix(); translate(posX, posY, 0); fill(0, (1000-abs(posY))*0.00015); beginShape(); vertex(-rate*4, -rate*4, posZ); vertex(-rate*4, rate*4, posZ); vertex(rate*4, rate*4, posZ); vertex(rate*4, -rate*4, posZ); endShape(); popMatrix(); posY -= rate; if( posY < -1000 ) { posY = 1000; } } }