3D movement enviroment
in
Core Library Questions
•
1 years ago
im having a lot of trouble trying to get my 3D etch a sketch background to rotate to allow the user of my etch a stech to see their 3D image clearly and i am wandering how it can be achieved :
here is my code so far:
import processing.opengl.*;
int x, y, z;
int speed = 10;
float a;
float b;
PImage etch;
color bgColor;//global declaration for random backgrounds
void setup() {
size(700, 630, OPENGL);
etch = loadImage("etchaskechcha.jpg");
background(etch);
a = (random(128));
}
void draw() {
if (key == 's'){
//off button
background(0);
// Button turns off
smooth();
strokeWeight(4);
fill(200);
ellipse(width/2, height/2, width/3+25, height/3+25); // gray edge
fill(134, 0, 0);
ellipse(width/2, height/2, width/3, height/3); // red button
strokeWeight(2);
stroke(0);
ellipse(width/2, height/2, width/6, height/6); // black color
line(width/2, height/2-20, width/2, height/2-75);
}
else if(key == 'e'){
exit();
}
lights();// shadow
pushMatrix();
translate(width/2, height/2);
noFill();
//b = stroke(128, 128);
//stroke(a);
box(350, 270, 407);//the contruct of 3D environment (w,h,d)
//beginShape();
//vertex(35, 50,407);
//vertex(65, 50);
//vertex(35, 80);
//endShape();
translate(width/12, height/12);
translate(x, y, z);
noStroke();
strokeWeight(20);//weght of sketch
//stroke(128);//sketch is grey
fill(a);//colour of sketch
box(10);//sketch
smooth();
//strokeWeight(200);
//stroke(50);
//noFill();
//smooth();
strokeWeight(1.4);//border thickness
popMatrix();
if (mousePressed) {
int bg = int(random(5));
if (bg==0) {
background(0, 0, 255);//when screen yellow marker turns blue
tint(255,128);
}
else if (bg== 1) {
background(0, 0, 0);// black
tint(255,128);
}
else if (bg== 2) {
background(51, 255, 51);//green
tint(255,128);
}
else if (bg== 3) {
background(255, 255, 0);//yellow
tint(255,128);
}
else if (bg== 4) {
background(255, 69, 0);//red/orange
tint(255,128);
}
background(etch);
}
}
void keyPressed() {
if (keyCode == UP) {
y-=speed;
}
if (keyCode == DOWN) {
y+=speed;
}
if (keyCode == LEFT) {
x-=speed;
}
if (keyCode == RIGHT) {
x+=speed;
}
if (keyCode == SHIFT) {
z+=speed;
}
if (keyCode == CONTROL) {
z-=speed;
}
}
thank you for your time
1