//constructs a 4 sided shape using fruit and ground images for textures //changes rotations around x and y based on mouse presses //if no mouse presses in rest milliseconds, restores original rotations //rotations are from -PI to PI, so clicking in the center has the least effects //rotation values converted to degrees are printed out PImage ground; PImage fruit; float rotX, rotY; float last; float rest; void setup() { size(1000,600,P3D); ground = loadImage("leaves.jpg"); fruit = loadImage("fruit.jpg"); last = millis(); rest = 3000; frameRate(4); } void draw() { background(255); translate(width/2, height/2); if ((millis()-last)>rest) { rotY = 0; rotX = 0; } rotateY(rotY); rotateX(rotX); beginShape(); texture(fruit); // tint(255,200); vertex (-100,-100,0,0,0); vertex (200,-100,0,100,0); vertex (200,100,0,100,100); vertex(-100,100,0,0,100); endShape(); beginShape(); texture(fruit); // tint(255,200); vertex (-100,-100,200,0,0); vertex (-100,-100,0,100,0); vertex (-100,100,0,100,100); vertex(-100,100,200,0,100); endShape(); beginShape(); texture(fruit); // tint(255,200); vertex (200,-100,0,0,0); vertex (200,-100,200,100,0); vertex (200,100,200,100,100); vertex(200,100,0,0,100); endShape(); beginShape(); texture(ground); // tint(255,200); vertex (-100,100,0,0,0); vertex (200,100,0,100,0); vertex (200,100,200,100,100); vertex(-100,100,200,0,100); endShape(); } void mousePressed() { rotY =map(mouseX, 0, width, -PI, PI); rotX =map(mouseY, 0, height, -PI,PI); println("rotY is "+degrees(rotY)+" rotX is "+degrees(rotX)); last = millis(); }