PDA

View Full Version : rotate for a point in plan



02-24-2004, 11:37 AM
HI,
I'm working on an RTS 3D engine, and i've a lot of problems with rotations.

I want to rotate (with the mousewheel) the view, not at the windows center, but at a pixel of the screen( the one under mouse for exemple).
The code is not hard :
- glTranslatef( ix, iy );
- glRotatef( angle, 0, 0, 1);
- glTranslatef( -ix, -iy );

where ix and iy are world coordinates of the pixel under the mouse.
It works fine.
But I want the center of rotation to change ( where my mouse is)
So when I change the mouse position and start to turn wheel, the plan rotate for the good world coordinate point, but it doesn't correspond to my mouse location. It's due to the formules, I know, but i don't know how to achive that.
Maybe there is a fonction to force one world point to draw on one screen pixel (xith a translation probably).
If anybody can help me....
Thanks and sorry for my poor english

modest
02-24-2004, 12:25 PM
are you using gluUnProject to transform window coordinates to world coordinates?

modest
02-24-2004, 12:26 PM
are you using gluUnProject to transform window coordinates to world coordinates?

modest
02-24-2004, 12:27 PM
are you using gluUnProject to transform window coordinates to world coordinates?