1
\$\begingroup\$

I have working code to display a tiled map. It's composed of a OrthogonalTiledMapRenderer and an OrthoGraphicCamera :

camera.setToOrtho(false, WORLD_WINDOW_SIZE.x,
            WORLD_WINDOW_SIZE.y);

renderer = new OrthogonalTiledMapRenderer(tiledmap, 1 / TILE_WIDTH);

renderer.setView(camera);

So far so good. The map is rendered as seen from above: Above

My question is, how do I render it with the camera not facing right down to the floor?

Like this: Perspective [Thanks to all GIMP developers :) ]

Is it possible? I tried Camera.rotate(45) but it rotates in the wrong axis. I can't set Camera.direction because of this - taken from OrthogonalTiledMapRenderer.setView(camera) documentation :

Sets the projection matrix and viewbounds from the given camera. If
the camera changes, you have to call this method again. The viewbounds are taken from the camera's position and viewport size as well as the scale. This method will only work if the camera's direction vector is (0,0,-1) and its up vector is (0, 1, 0), which are the defaults.

If I change the camera direction, the renders are weird or non-existant.

Is it possible to do so with the standard LibGDX api? If not, how can I do this? If not are there any workarounds to get the same effect?

\$\endgroup\$
6
  • \$\begingroup\$ You can't do this with an orthogonal camera (orthogonal means 2D/straight down), what you should do is render what gets displayed on the camera to a texture that is placed on a plane in 3D and use a regular camera to display to the user. Then to get the rotation you want you can either rotate the plane or have the camera orbit around it. \$\endgroup\$ Commented Mar 14, 2013 at 16:06
  • \$\begingroup\$ Well, see the answer below: Now I know you can \$\endgroup\$
    – UberLambda
    Commented Mar 14, 2013 at 16:11
  • \$\begingroup\$ I believe that only works for rotating around the y-axis. I'm not sure if there is something that works on the z or x axis's. \$\endgroup\$ Commented Mar 14, 2013 at 16:15
  • \$\begingroup\$ Well actually that's true. But I can rotate the camera \$\endgroup\$
    – UberLambda
    Commented Mar 14, 2013 at 16:17
  • \$\begingroup\$ Ah, I think I see my confusion, I thought you wanted the camera to go up and down like you were looking at a table top game (which is pretty cool in my opinion) but you wanted an isometric view like in the old Age of Empires and Starcraft games. Yeah, the below answer should be good enough in that case. \$\endgroup\$ Commented Mar 14, 2013 at 16:19

1 Answer 1

1
\$\begingroup\$

I think you are looking for isometric view. You should use OtrhographicCamera as you are using now, but construct it using this constructor, passing diamondAngle

public OrthographicCamera(float viewportWidth, float viewportHeight, float diamondAngle)

Constructs a new OrthographicCamera, using the given viewport width and height. This will create a camera useable for iso-metric views. The diamond angle is specifies the angle of a tile viewed isometrically.

resulting view - taken from libgdx tests suite

\$\endgroup\$
0

You must log in to answer this question.

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