float rotx; float roty; float stagez = -500; int numPics = 24; PImage[] images = new PImage[numPics]; PImage[] imcube1 = new PImage[6]; PImage[] imcube2 = new PImage[6]; PImage[] imcube3 = new PImage[6]; PImage[] imcube4 = new PImage[6]; Cube c1 = new Cube(); Cube c2 = new Cube(); Cube c3 = new Cube(); Cube c4 = new Cube(); void setup() { imageMode(CENTER); size(640, 480, P3D); for(int i = 0; i < numPics; i++) { images[i] = loadImage(i + ".jpg" ); } } void draw() { translate(mouseX, mouseY, stagez); background(0); noStroke(); // roty += 0.01; rotateX(rotx); rotateY(roty); loadimages(images); c1.drawcube(0, 100, 0, imcube1); c2.drawcube(-200, -100, -300, imcube2); c3.drawcube(300, 200, 100, imcube3); c4.drawcube(200, -300, -200, imcube4); } void loadimages(PImage[] imagearray) { for(int a = 0; a <6; a++) { imcube1[a] = images[a]; } for(int k = 0; k <6; k++) { imcube2[k] = images[k+6]; } for(int b = 0; b <6; b++) { imcube3[b] = images[b+12]; } for(int c = 0; c <6; c++) { imcube4[c] = images[c+18]; } } class Cube { float xpos, ypos, zpos; Cube () { } void drawcube(float x, float y, float z, PImage[] imarray) { xpos = x; ypos = y; zpos = z; translate(xpos, ypos, zpos); for(int j = 0; j<4; j++) { pushMatrix(); translate(0, 0,100); image(imarray[j],0,0); popMatrix(); rotateY(PI/2); } rotateX(PI/2); pushMatrix(); translate(0, 0, 100); image(imarray[5],0,0); popMatrix(); rotateX(PI); pushMatrix(); translate(0, 0, 100); image(imarray[4],0,0); popMatrix(); } }//class void mouseDragged() { float rate = 0.01; rotx += (pmouseY-mouseY) * rate; roty += (mouseX-pmouseX) * rate; } void keyPressed() { if (keyCode == UP) { stagez += 10; } if (keyCode == DOWN) { stagez -= 10; } if (keyCode == LEFT) { roty += 0.01; } if (keyCode == RIGHT) { roty -= 0.01; } }