I have some code to make a scene and then I want to rotate the entire scene (not all the objects in the scene)
When I run this code it rotates the cube and the skysphere seperately, but I want the entire scene to rotate, not individually rotate both the skysphere and the cube
if you need the background sphere to move ( rotate ) on key operation
but the object ( box ) not:
you need the push pop over the rotating sphere and not the box??
if you need them all to rotate: disable all push pop,
that looks correct to me
//PVector pos;
PShape sky;
float x,y,xm,ym;
float limit = 1.5,speed = 0.01;
void settings() {
size(800, 600, P3D);
}
void setup() {
// noStroke();
sky = createShape(SPHERE, 2000);
// sky.setTexture(loadImage("data/img/back.png"));
}
void draw() {
translate(width/2, height/2);
// push(); // add
move();
shape(sky);
// pop(); // add
// pushMatrix();
translate(0, height/2, 0);
stroke(200,0,0);
fill(0,0,200);
box(200, 20, 200);
// popMatrix();
}
void move() {
x += xm;
y += ym;
if (x > limit) x = limit;
if (x < -limit) x = -limit;
println("x "+nf(x, 1, 2)+" y "+nf(y, 1, 2));
rotateX(x);
rotateY(y);
}
void keyPressed() {
if (key == 'w') xm = speed;
if (key == 'a') ym = -speed;
if (key == 's') xm = -speed;
if (key == 'd') ym = speed;
}
void keyReleased() {
if (key == 'w'||key == 'a'||key == 's'||key == 'd') xm= ym = 0;
}
but possibly you expect the box at a different position??