5
\$\begingroup\$

I made a 2D isometric renderer. It works fine but now I want to show my scene from 4 different points of view (NE NW SE SW) but, on a 90° rotation, my camera cannot keep the center of my scene on screen.

What's working :

  • I calculate new projection of scene to match the new viewport (x y z in my world).
  • I reorganise part of my scene(chunk) to draw them in a correct order
  • I reorganise 'tiles' of 'chunks' to draw them in a correct order
  • I can keep the correct center with a 180 degrees rotation.

What's do not working :

  • I cannot find a correct translation to apply to my camera after a 90 degrees rotation.

What I know :

  • To keep the same center on a 180° rotation with my camera I have to do this :

camera.Position -= new Vector2(2 * camera.Position.X + camera.Width, 2 * camera.Position.Y + camera.Height);

Illustation of the problem :

enter image description here enter image description here enter image description here

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

How about putting your camera in the center of what you want to render, set the near plane behind the camera and the far plane in front of it?

If you do this, you don't have to move your camera when you rotate.

\$\endgroup\$
7
  • \$\begingroup\$ I asked this question in stackoverflow too, there is a guy who gave me a nice trick with a Matrice rotation, I'll test this evening and I'll report here if my problem is resolved or not. \$\endgroup\$ Feb 22, 2013 at 16:12
  • \$\begingroup\$ @CyrilALFARO make sure you let everybody know of the answer if you figure it out! \$\endgroup\$ Feb 23, 2013 at 9:44
  • \$\begingroup\$ yes of course, I did correctly my rotation with 90°, Vector2(new_camera_x,new_camera_y) = new Vector2(-(old_camera_y - old_camera_height)/2,old_camera_x*2), or a kind of. It 's correct for a Z = 0 in my world but if I change altitude, all is wrong. So finally I need to find the center of my scene (X Y Z) and rotate arround it (par matrice ou simple decallage avant/apres). \$\endgroup\$ Feb 24, 2013 at 12:38
  • \$\begingroup\$ I have rights now to add images so I put them. \$\endgroup\$ Feb 24, 2013 at 12:43
  • \$\begingroup\$ I resolved my issue by calculating tile elligeable to be the center of the screen. Then, I pick up the nearest one of the camera and, after a rotation, I put it back to the middle of the screen. It's a quite easy like this but finally I have to calculate the tile in the center of my screen (because Z axis). \$\endgroup\$ Feb 25, 2013 at 0:04
0
\$\begingroup\$

I resolved my issue by calculating tile elligeable to be the center of the screen. Then, I pick up the nearest one of the camera and, after a rotation, I put it back to the middle of the screen. It's a quite easy like this but finally I have to calculate the tile in the center of my screen (because Z axis).

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .