//import processing.opengl.*; final int S = 30; float a[][] = new float[S][S]; float b[][] = new float[S][S]; float c[][] = new float[S][S]; float d[][] = new float[S][S]; int t[][] = new int[S][S]; int steps = 6; int cnt = 0; float cx = -30; float cz = -30; float cy = -5; int dx = S/2; int dz = S/2; float dy = -10; PImage[] tex1 = new PImage[4]; PImage[] tex2 = new PImage[4]; void setup() { size(800,400,P3D); //size(800,400,OPENGL); framerate(5); //tex1 = loadImage("scr.gif"); //tex2 = loadImage("scr2.gif"); tex1[0] = loadImage("blauhausS.gif"); tex2[0] = loadImage("gruenweissS.gif"); tex1[1] = loadImage("mittefensterlangS.gif"); tex2[1] = loadImage("orangelangS.gif"); tex1[2] = loadImage("mittegestreiftlangS.gif"); tex2[2] = loadImage("graulangS.gif"); tex1[3] = loadImage("scr2.gif"); tex2[3] = loadImage("gruendoppeltS.gif"); // a[S/2][S/2] = 5; // a[S/2+1][S/2] = 5; // a[S/2][S/2+1] = 5; // a[S/2+1][S/2+1] = 5; // b[S/2][S/2] = 5; for(int i = 0;i0) { //camera(cx,cy,cz,0,-1.5,0,0,1,0); //translate(dx-S/2,dy,dz-S/2); //box(1,1,1); mybox(dx-S/2,dz-S/2,dy,dy+1,t[dx][dz]); } step(); } void mybox(float x, float z, float y,float y0, float d, int t) { fill(80); beginShape(QUADS); d *= y; float u = 1+ y<0? y/4:-y/4; vertex(x-d,y,z-d); vertex(x+1+d,y,z-d); vertex(x+1+d,y,z+1+d); vertex(x-d,y,z+1+d); endShape(); textureMode(NORMALIZED); beginShape(POLYGON); texture(tex1[t]); vertex(x,y0,z,0,u); vertex(x+1,y0,z,1,u); vertex(x+1+d,y,z-d,1,1); vertex(x-d,y,z-d,0,1); endShape(); beginShape(QUADS); texture(tex2[t]); vertex(x,y0,z,0,u); vertex(x,y0,z+1,1,u); vertex(x-d,y,z+1+d,1,1); vertex(x-d,y,z-d,0,1); endShape(); } void mybox(float x, float z, float y,float y0,int t) { fill(200); float u = 1+ y<0? y/1:-y/1; u = min(u,1); beginShape(QUADS); vertex(x,y,z); vertex(x+1,y,z); vertex(x+1,y,z+1); vertex(x,y,z+1); endShape(); textureMode(NORMALIZED); beginShape(POLYGON); texture(tex1[t]); vertex(x,y0,z,0,u); vertex(x+1,y0,z,1,u); vertex(x+1,y,z,1,1); vertex(x,y,z,0,1); endShape(); beginShape(QUADS); texture(tex2[t]); vertex(x,y0,z,0,u); vertex(x,y0,z+1,1,u); vertex(x,y,z+1,1,1); vertex(x,y,z,0,1); endShape(); beginShape(POLYGON); texture(tex1[t]); vertex(x,y0,z+1,0,u); vertex(x+1,y0,z+1,1,u); vertex(x+1,y,z+1,1,1); vertex(x,y,z+1,0,1); endShape(); beginShape(QUADS); texture(tex2[t]); vertex(x+1,y0,z,0,u); vertex(x+1,y0,z+1,1,u); vertex(x+1,y,z+1,1,1); vertex(x+1,y,z,0,1); endShape(); } void step() { if( cnt < steps) { cnt++; for(int i = 0;ia[dx][dz]) { b[dx][dz] = 8.; b[(dx-1+S)%S][dz] = 8.; b[dx][(dz-1+S)%S] = 8.; b[(dx-1+S)%S][(dz-1+S)%S] = 8.; a[dx][dz] = 8.; dx = -1; } else dy += .7; } float ox; float oy; void mousePressed() { ox = mouseX; oy = mouseY; } void mouseDragged() { float al = -0.01*(mouseX -ox); ox = mouseX; float be = 0.01*(mouseY - oy); oy = mouseY; if((mouseButton == RIGHT)) { float d = sqrt( cx * cx + cy*cy + cz * cz); d = (d+8*be)/d; cx *= d; cy *= d; cz *= d; return; } cx = cos(al) * cx + sin(al) * cz; cz = cos(al) * cz - sin(al) * cx; float d = sqrt( cx * cx + cz * cz); cx /= d; cz /= d; d = cos(be) * d + sin(be) * cy; cx *= d; cz *= d; //cx = cos(be) * cx + sin(be) * cy; //cz = cos(be) * cz + sin(be) * cy; cy = cos(be) * cy - sin(be) * d; }