import processing.opengl.*; PImage a, b, c, d, e, f; int s = 200; int m = 800; float rotationX = 0; float rotationY = 0; float velocityX = 0; float velocityY = 0; float pushBack = 400; void setup() { size(400, 400, OPENGL); a = loadImage("V01.jpg"); b = loadImage("V02.jpg"); c = loadImage("V03.jpg"); d = loadImage("V04.jpg"); e = loadImage("V05.jpg"); f = loadImage("V06.jpg"); textureMode(IMAGE); //smooth(); //initializeCube(m,s); //camera(); camera(0.0, 0.0, 0.0, // eyeX, eyeY, eyeZ 1.0, 1.0, 1.0, // centerX, centerY, centerZ 1.0, 0.0, 1.0); // upX, upY, upZ } void draw() { background(0); renderCube(); } void renderCube() { pushMatrix(); //translate(width/2.0, height/2.0, pushBack); pushMatrix(); noFill(); //stroke(255,10); //strokeWeight(0); noStroke(); //smooth(); popMatrix(); //lights(); pushMatrix(); rotateX( radians(-rotationX) ); rotateY( radians(270 - rotationY) ); //rotateZ( radians(rotationX) ); fill(200); //noStroke(); textureMode(IMAGE); texturedCube(m, s); popMatrix(); popMatrix(); rotationX += velocityX; rotationY += velocityY; velocityX *= 0.95; velocityY *= 0.95; // Implements mouse control (interaction will be inverse when sphere is upside down) if(mousePressed){ velocityX += (mouseY-pmouseY) * 0.01; velocityY += (mouseX-pmouseX) * 0.01; } } // Generic routine to draw textured sphere void texturedCube(float m, float s) { // +Z "front" face beginShape(); texture(a); vertex(-s, -s, s-1, 0, 0); vertex( s, -s, s-1, m, 0); vertex( s, s, s-1, m, m); vertex(-s, s, s-1, 0, m); endShape(); // -Z "back" face beginShape(); texture(c); vertex( s, -s, -s+1, 0, 0); vertex(-s, -s, -s+1, m, 0); vertex(-s, s, -s+1, m, m); vertex( s, s, -s+1, 0, m); endShape(); // +Y "bottom" face beginShape(); texture(f); vertex(-s, s-1, s, 0, 0); vertex( s, s-1, s, m, 0); vertex( s, s-1, -s, m, m); vertex(-s, s-1, -s, 0, m); endShape(); // -Y "top" face beginShape(); texture(e); vertex(-s, -s+1, -s, 0, 0); vertex( s, -s+1, -s, m, 0); vertex( s, -s+1, s, m, m); vertex(-s, -s+1, s, 0, m); endShape(); // +X "right" face beginShape(); texture(b); vertex( s-1, -s, s, 0, 0); vertex( s-1, -s, -s, m, 0); vertex( s-1, s, -s, m, m); vertex( s-1, s, s, 0, m); endShape(); // -X "left" face beginShape(); texture(d); vertex(-s+1, -s, -s, 0, 0); vertex(-s+1, -s, s, m, 0); vertex(-s+1, s, s, m, m); vertex(-s+1, s, -s, 0, m); endShape(); }