Creating Matrices to map a flat world to the viewport

Started by
1 comment, last by Mussi 10 years, 8 months ago

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!

Dave

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.

Advertisement

Could you not just use an ortho matrix if it is a flat side scroller?

This should cover your questions.

This topic is closed to new replies.

Advertisement