Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
    
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. –  Benjamin Danger Johnson Mar 14 '13 at 16:06
    
Well, see the answer below: Now I know you can –  TM3P Mar 14 '13 at 16:11
    
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. –  Benjamin Danger Johnson Mar 14 '13 at 16:15
    
Well actually that's true. But I can rotate the camera –  TM3P Mar 14 '13 at 16:17
    
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. –  Benjamin Danger Johnson Mar 14 '13 at 16:19
show 1 more comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
    
This works, thanks –  TM3P Mar 14 '13 at 16:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.