Advertisement

Rotation problem

Started by October 27, 2002 02:50 PM
-1 comments, last by Raduprv 22 years, 4 months ago
I have a ''small'' problem. I am working at an isometric engine. My axes are inverted (z is y), so my plane is delimited by x and y, while z points up and down. Their direction is: x=positive for west y=positive for south z=positive for down I know they are all messed up, but I don''t mind it. Anyway, my poroblem is this: When I rotate the camera, along the z axis, I want the scene to be rotated in the very center of my current window. That is, if I have a cube, at x=20, =-5, and I am with my camera there, when I rotate on z, the center of the cube will still be there, only it''s corners will rotate. This is simple, it only involves this:

	glRotatef(rz, 0.0f, 0.0f, 1.0f);//rz=rotation z
	glTranslatef(cx, cy-1, cz);//cx,cy,cz=camera pos
 
However, if I also want to rotate on x (I do that because I don''t want to see only the roofs of the houses), so I need a x rotation too. But, when I add the x rotation, my scene will not spin around the center of the scene, but around the center of the camera pos (which is NOT what I want). Is there anyone who knows a solution to that? I tried all the possible rotation and translaltion order, still no luck. The code I am using now (which rotates the word around the camera center, not world center) is:

	glRotatef(rx, 1.0f, 0.0f, 0.0f);
	glRotatef(rz, 0.0f, 0.0f, 1.0f);
	glTranslatef(cx, cy-1, cz);
 
I spent days trying to figure this out, and no success so far, so I am really frustrated...

This topic is closed to new replies.

Advertisement