Jump to content
  • Advertisement
Sign in to follow this  

Creating Matrices to map a flat world to the viewport

This topic is 2167 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

I'm working on a "2.5D" game where everything is still proper 3D but everything lives at 0 depth.  Think of any standard side-scroller, Geometry Wars, or so on.


If I know I'm running at 1024x768 (just for example) resolution and I know that my "world" is constrained to x {-1.0, 1.0} and y {-1.0, 1.0) how do I go about creating my perspective and transform matrices other than trial and error?


I probably have to pick a camera depth, and because I do not want a lot of distortion, let's say z=1000 for the camera.  But how do I go about getting my matrices so that the 1024x768 pixels I have map to a 4:3 region of game world?


Since the screen space in a side-scroller may be 1/20th or so of the actual 2D world, the camera will have to move horizontally as well.  And similarly, I need to know when to start and stop the camera so that you do not run off either end.


As I said, I could probably guess and fine-tune until I got it right, but I have to imagine there's a more rigorous way to go about it.  


Thanks for any tips!



PS: I'm not even entirely sure I'll need a projection matrix, but I would like to be able to zoom in and out.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!