We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Translating issues
Page Index Toggle Pages: 1
Translating issues (Read 1261 times)
Translating issues
Jun 4th, 2010, 9:53am
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:

void draw() {

 focus.update(); // updates the focus' point coordinates with user input

 translate(width/2, height/2, 0);


 translate(focus.x, focus.y, focus.z);

 // Drawing

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.

Lips Sealed
Re: Translating issues
Reply #1 - Jun 5th, 2010, 1:12pm
When working on 3D games, I've just tended to flip the left/right axis if the up/down axis is crossed.  Brutish but works!
Page Index Toggle Pages: 1