Sign in to follow this  
rwilson1982

Placing a Camera In World (Screen Resolution)

Recommended Posts

Hello,

I am designing a game for mobile devices. I am trying to come up with a formula that will allow me to place the main camera in the world so that what it sees will look the same on different screen resolutions.

Essentially, I have a cube which has a fixed width, height and depth which sits on the origin. I need the camera to look on one side of the cube which is actually a room in my game. There is no rotation on the camera and it looks straight ahead at the cube. At the moment I set the Y axis of the camera so that it is half the height of the cube (i.e. 25.0f). I need to know how to calculate how far back to place it on the Z axis so that the face of the cube fills the screen at different screen resolutions.

Please see the linked picture below for a rough visual attempt at the problem:

[url="http://i1213.photobucket.com/albums/cc466/rwilson1982/CameraProblem.jpg"]http://i1213.photobu...meraProblem.jpg[/url]

I would like to minimise any borders down the left and right of the screen if possible.

Is someone mathmatically inclined able to help me out :) ?

Share this post


Link to post
Share on other sites
Thats a bit of an issue a friend of mine has been working on for the past year(?) or so. He's been building a 2D engine for mobile platforms and had similar problems regarding the viewport. You can take a look at his implementation here: http://yoghurtgum.googlecode.com/svn/trunk/Source/Modules/RenderMethodDirectDraw/src/ViewportDirectDraw.cpp

But the problem is that if you have a solution for one type of screen / resolution its not always going to work for every single one. There are many solutions for all different problems. So good luck on this one, think you'll have to trial-and-error most of it yourself :wink:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this