int img_width = 240; int img_height = 180; int img_depth = 244; //int img_depth = 259; int screen_width = 350; int screen_height = 300; //String images_name = "tree240x180_"; String images_name = "0000"; color[][][] cube; int img_x; int img_y; int img_z; int depth = -img_depth/2+1; int key_pressed = -1; float angleX=0; float angleY=0; float angleZ=0; float oAngleX=0; float oAngleY=0; float holderAngleX=0; float holderAngleY=0; float holderAngleZ=0; float oHolderAngleX=0; float oHolderAngleY=0; float pressX; float pressY; float holderPressX; float holderPressY; // int moveSpeed = 3; boolean mouseUP = true; boolean keyUP = true; PImage[] img_s = new PImage[6]; PImage img_out = new PImage(screen_width,screen_height); PImage[] img_src = new PImage[img_depth]; PFont font; void setup(){ //size(800, 400, OPENGL); //doesnt make it faster since most of the calculations are made in the code size(700, 400, P3D); font = loadFont("FFFAlias-8.vlw"); background(0); int img_z = 0; cube = new color[img_width][img_height][img_depth]; textFont(font, 8); for(int i = 0;i img_width-1 || yut<0 || yut > img_height-1 || zut<0 || zut > img_depth-1){ return blank; } else{ return cube[round(xut)][img_height-1-round(yut)][img_depth-1-round(zut)]; } } void draw(){ if(key_pressed==-1){ } else{ background(200); textFont(font, 8); text("UP : move cube forward", 50, 20); text("DOWN : move cube backward", 50, 30); text("click and drag : rotate cube", 250, 20); text("SPACE and drag : rotate space", 250, 30); text("1-9 : set speed ("+moveSpeed+")", 450, 20); text("R : reset", 450, 30); if(mousePressed){ if(mouseUP){ pressX = mouseX; pressY = mouseY; oAngleX = angleX; oAngleY = angleY; mouseUP = false; } angleX = oAngleX+radians(-(mouseY-pressY)); angleY = oAngleY+radians((mouseX-pressX)); } else{ mouseUP = true; } if(keyPressed){ if(keyCode==UP){ depth += moveSpeed; } else if(keyCode==DOWN){ depth -= moveSpeed; } else if(key=='r' || key=='R'){ depth = -img_depth/2+1; angleX=0; angleY=0; angleZ=0; holderAngleX=0; holderAngleY=0; holderAngleZ=0; } else if(key==' '){ if(keyUP){ holderPressX = mouseX; holderPressY = mouseY; oHolderAngleX = holderAngleX; oHolderAngleY = holderAngleY; keyUP = false; } holderAngleX = oHolderAngleX+radians(-(mouseY-holderPressY)); holderAngleY = oHolderAngleY+radians((mouseX-holderPressX)); } else{ int tmpSpeed = (int)key-(int)'1'+1; moveSpeed = (tmpSpeed<0 || tmpSpeed>10)?moveSpeed:tmpSpeed; } } else{ keyUP = true; } pushMatrix(); translate(width/4-75, height/2,-100); rotateY(holderAngleY); rotateX(holderAngleX); pushMatrix(); translate(0, 0,depth); rotateY(angleY); rotateX(angleX); translate(-img_width/2, -img_height/2, img_depth/2); image(img_s[2],0,0); rotateX(radians(-90)); image(img_s[1],0,0); rotateY(radians(-90)); image(img_s[0],0,0); translate(0, img_depth, 0); rotateY(radians(90)); rotateX(radians(90)); image(img_s[5],0,0); translate(0, img_height, img_depth); rotateX(radians(-90)); image(img_s[4],0,0); translate(img_width, 0, -img_height); rotateY(radians(-90)); image(img_s[3],0,0); popMatrix(); color c = color(0, 0, 100, 200); fill(c); noStroke(); rect(-screen_width/2, -screen_height/2, screen_width, screen_height); popMatrix(); for(int j = 0;j