PImage imgFront, imgBack, imgLeft, imgRight, imgTop, imgBottom; // declare image variables void setup() { size(600, 600, P3D); // set the canvas to be 3D // load the images imgFront = loadImage("front.jpg"); imgBack = loadImage("back.jpg"); imgLeft = loadImage("left.jpg"); imgRight = loadImage("right.jpg"); imgTop = loadImage("top.jpg"); imgBottom = loadImage("bottom.jpg"); } void draw() { background(250); translate(width/2, height/2, 0); rotateX(frameCount * 0.01); rotateY(frameCount * 0.02); float s = 100; // set the size of the cube // apply textures to each face of the box beginShape(QUADS); texture(imgFront); vertex(-s/2, -s/2, -s/2, 0, 0); vertex(s/2, -s/2, -s/2, 100, 0); vertex(s/2, s/2, -s/2, 100, 100); vertex(-s/2, s/2, -s/2, 0, 100); texture(imgBack); vertex(s/2, -s/2, s/2, 0, 0); vertex(-s/2, -s/2, s/2, 100, 0); vertex(-s/2, s/2, s/2, 100, 100); vertex(s/2, s/2, s/2, 0, 100); texture(imgLeft); vertex(-s/2, -s/2, s/2, 0, 0); vertex(-s/2, -s/2, -s/2, 100, 0); vertex(-s/2, s/2, -s/2, 100, 100); vertex(-s/2, s/2, s/2, 0, 100); texture(imgRight); vertex(s/2, -s/2, -s/2, 0, 0); vertex(s/2, -s/2, s/2, 100, 0); vertex(s/2, s/2, s/2, 100, 100); vertex(s/2, s/2, -s/2, 0, 100); texture(imgTop); vertex(-s/2, -s/2, s/2, 0, 0); vertex(s/2, -s/2, s/2, 100, 0); vertex(s/2, -s/2, -s/2, 100, 100); vertex(-s/2, -s/2, -s/2, 0, 100); texture(imgBottom); vertex(-s/2, s/2, -s/2, 0, 0); vertex(s/2, s/2, -s/2, 100, 0); vertex(s/2, s/2, s/2, 100, 100); vertex(-s/2, s/2, s/2, 0, 100); endShape(); } PImage imgFront, imgBack, imgLeft, imgRight, imgTop, imgBottom; // declare image variables void setup() { size(600, 600, P3D); // set the canvas to be 3D // load the images imgFront = loadImage("front.jpg"); imgBack = loadImage("back.jpg"); imgLeft = loadImage("left.jpg"); imgRight = loadImage("right.jpg"); imgTop = loadImage("top.jpg"); imgBottom = loadImage("bottom.jpg"); } void draw() { background(250); translate(width/2, height/2, 0); rotateX(frameCount * 0.01); rotateY(frameCount * 0.02); float s = 100; // set the size of the cube // apply textures to each face of the box beginShape(QUADS); texture(imgFront); vertex(-s/2, -s/2, -s/2, 0, 0); vertex(s/2, -s/2, -s/2, 100, 0); vertex(s/2, s/2, -s/2, 100, 100); vertex(-s/2, s/2, -s/2, 0, 100); texture(imgBack); vertex(s/2, -s/2, s/2, 0, 0); vertex(-s/2, -s/2, s/2, 100, 0); vertex(-s/2, s/2, s/2, 100, 100); vertex(s/2, s/2, s/2, 0, 100); texture(imgLeft); vertex(-s/2, -s/2, s/2, 0, 0); vertex(-s/2, -s/2, -s/2, 100, 0); vertex(-s/2, s/2, -s/2, 100, 100); vertex(-s/2, s/2, s/2, 0, 100); texture(imgRight); vertex(s/2, -s/2, -s/2, 0, 0); vertex(s/2, -s/2, s/2, 100, 0); vertex(s/2, s/2, s/2, 100, 100); vertex(s/2, s/2, -s/2, 0, 100); texture(imgTop); vertex(-s/2, -s/2, s/2, 0, 0); vertex(s/2, -s/2, s/2, 100, 0); vertex(s/2, -s/2, -s/2, 100, 100); vertex(-s/2, -s/2, -s/2, 0, 100); texture(imgBottom); vertex(-s/2, s/2, -s/2, 0, 0); vertex(s/2, s/2, -s/2, 100, 0); vertex(s/2, s/2, s/2, 100, 100); vertex(-s/2, s/2, s/2, 0, 100); endShape(); }
top of page
bottom of page