Hello,
I am designing a game for mobile devices (iPhone and Android). 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 mobile devices with different screen resolutions.
Essentially, I have a cube which has a fixed width, height and depth. 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:
http://i1213.photobucket.com/albums/cc466/rwilson1982/CameraProblem.jpg
I would like to minimise any black borders down the left and right of the screen if possible.
Is someone mathmatically inclined able to help me out
?
On a note, when i was just starting out designing menus. I came across this problem and i actually found myself measuring my screen with a ruler, then measuring from one edge to the point where i wanted the GUI element ;).
– timsk