Looooong story short I'm essentially trying to code Mode 7 in XNA. Before I continue bashing my brains out in research and various failed matrix math equations; I just want to make sure that XNA supports this just out-of-the-box (so to speak).

I'd prefer not to have to import other libraries, because I want to learn how it works myself that way I understand the whole thing better. However that's all for naught if it won't work at all. So no opengl, directx, etc if possible (will eventually do it just to optimize everything, but not for now).

tl;dr: Can I has Mode 7 in XNA?


1 Answer 1


You can pass an arbitrary 4x4 matrix to SpriteBatch.Begin (MSDN) - it doesn't even have to be affine (but it can be if you leave the extra elements set to the identity matrix). This transformation will be applied to all the sprites that you draw within that batch.

You can build the matrix by hand, or use the helpful Create* methods on the Matrix type (MSDN). I think for the classic perspective plane effect you need to create the matrix by hand - I'll let you figure out the actual maths involved ;)

(Just remember that XNA's Matrix type is row vector, M41 and M42 are the X and Y translation elements.)

Remember that SpriteBatch draws its sprites, by default and after transformation, in "client space" - (0,0) in the top left, (width,height) in the bottom right. But you can have a completely arbitrary projection by using a custom effect - this is actually easier if you're trying to draw sprites in 3D space, because you can just use a real perspective projection matrix (instead of the built-in orthographic client one) and you can use the built-in creation methods.

  • \$\begingroup\$ Hey, thanks! I really appreciate this answer! I haven't given it a try yet but I definitely will ASAP =) \$\endgroup\$
    – Niko
    Commented Sep 17, 2012 at 23:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .