Jump to content
  • Advertisement
Sign in to follow this  
rwilson1982

Placing a Camera In World (Screen Resolution)

This topic is 2454 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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:

http://i1213.photobu...meraProblem.jpg

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!