View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Creating Matrices to map a flat world to the viewport

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1davepl1968  Members

Posted 08 August 2013 - 07:52 PM

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.

### #2Burnt_Fyr  Members

Posted 09 August 2013 - 09:04 PM

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

### #3Mussi  GDNet+

Posted 09 August 2013 - 09:25 PM