Jump to content
  • Advertisement
Sign in to follow this  
stabo10

Need math help setting up projection matrix

This topic is 4763 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 making a sprite based game, and I want a camera that is able to zoom in and out. Camera View Point vector (0, 0, -1) Camera Look at Vector (0, 0, 0) All sprites' Z positions are 0. The camera should zoom in by moving on the positive Z axis. At the -1 location I'd like it to get a perfect 1:1 sprite to screen pixel ratio. I'd also like for an increase of 1 on the camera's Vector.x to shift the sprites exactly one pixel to the left on the screen (given the camera's vector.z is currently -1.) Anyone know how to set up the projection matrix to do this? ...or any functions that could create a bridge between this ideal coordinate input system, and the actual view and projection matrices? ------------------ If that is unreasonable, does anyone know how--if using a standard FOV projection matrix, to set the Camera's -Z value so that you will get a perfect 1:1 sprite to screen pixel ratio? Please help me out!

Share this post


Link to post
Share on other sites
Advertisement
I haven't done much with sprites, so I'm not sure what the standard 'pixel perfect' methods are. I will say that you'll probably want an orthographic rather than perspective projection. You can simply set the bounds of the orthographic frustum to the viewport bounds to get (more or less) exact mapping to the screen. There was a thread recently in the OpenGL forum about what sort of tweaks are required to get exact pixel-perfect alignment; I'm not sure how these translate to D3D.

For zooming, rather than move your camera on the z axis, you'll simply change the ortho frustum parameters to map to a smaller area. Keep in mind however that you'll no longer have unit-to-pixel mapping.

Again, I haven't done this - this is all speculative. Perhaps someone who's written sprite-based games in D3D can give you some better advice.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!