float rotation = 0; float rippler = 0; float[][] boxPos = new float[21][21]; float[][] boxPosNew = new float[21][21]; void setup () { size(600, 400, P3D); framerate(20); colorMode(RGB, 1.0); noStroke(); } void draw () { background(0); ambientLight(0.75, 0.75, 0.75); directionalLight(1, 1, 1, 200, 200, 0); translate(300, 200, 100); rotateX(rotation); rotateY(rotation / 2); rotateZ(rotation / 3); pushMatrix(); for( int i=0; i<21; i++ ) { for( int j=0; j<21; j++ ) { pushMatrix(); if( (i==11) & (j==11) ) { boxPosNew[i][j] = -sin(rippler); } else { boxPosNew[i][j] = (boxPos[i][abs(j-1)%21]+boxPos[i][(j+1)%21]+boxPos[abs(i-1)%21][j]+boxPos[(i+1)%21][j])/4; } translate(-105+i*10, -105+j*10, boxPosNew[i][j]*400); float iFloat = i; float jFloat = j; fill(color(sqrt(boxPosNew[i][j]), 0, sqrt(-boxPosNew[i][j]))); box(abs(boxPosNew[i][j]*100), abs(boxPosNew[i][j]*100), abs(boxPosNew[i][j]*200)); popMatrix(); } } for( int i=0; i<21; i++ ) { for( int j=0; j<21; j++ ) { boxPos[i][j] = boxPosNew[i][j]; } } popMatrix(); rotation = rotation + 0.01; rippler = rippler + 0.1; }