How to create projection/view matrix for hole in the monitor effect

Posted by Mr Bell on Game Development See other posts from Game Development or by Mr Bell
Published on 2011-11-29T21:20:14Z Indexed on 2011/11/30 2:08 UTC
Read the original article Hit count: 442

Filed under:
|
|
|

Lets say I have my XNA app window that is sized at 640 x 480 pixels. Now lets say I have a cube model with its poly's facing in to make a room. This cube is sized 640 units wide by 480 units high by 480 units deep. Lets say the camera is somewhere in front of the box looking at it.

How can I set up the view and projection matrices such that the front edge of the box lines up exactly with the edges of the application window?

It seems like this should probably involve the Matrix.CreatePerspectiveOffCenter method, but I don't fully understand how the parameters translate on to the screen.

For reference, the end result will be something like Johhny Lee's wii head tracking demo: http://www.youtube.com/watch?v=Jd3-eiid-Uw&feature=player_embedded

P.S. I realize that his source code is available, but I am afraid I haven't been able to make heads or tails out of it.

© Game Development or respective owner

Related posts about math

Related posts about xna-4.0