Hi all, again an issue that drives me crazy.
It really sounds simple, but I'm hitting the wall every time.
I wrote a class to move around in 3d space, and even posted it somewhere on these boards. But now I wanted to make a
slight modification to this class.
What it does: it saves a current "focus" point in 3d space, around which you move & rotate the scene. Pretty basic really: the class is just xyz coordinates & rotate parameters saved.
Use it like this, and everything is well:
Code:void draw() {
focus.update(); // updates the focus' point coordinates with user input
translate(width/2, height/2, 0);
rotateY(focus.ry);
rotateX(focus.rx);
translate(focus.x, focus.y, focus.z);
// Drawing
background(255);
box(100);
}
Except that after rotation, the axes on which this focus point moves are also rotated, making the whole thing quite a bit less intuitive (ie. pressing the left/right arrow keys now moves the scene up and down)
So I want to reset the matrix; map the user input (x, y, z vectors of the focus point) to the translated matrix, so that left stays left, right stays right, and one can still happily rotate the scene.