Menu

2DCamera Monogame

September 10, 2016 - Game Programming

GL_2DCoordinates GL_2DViewportAspectRatio

SOURCE 1 (simple) : http://www.david-amador.com/2009/10/xna-camera-2d-with-zoom-and-rotation/

SOURCE 2 (full) : https://roguesharp.wordpress.com/2014/07/13/tutorial-5-creating-a-2d-camera-with-pan-and-zoom-in-monogame/

SOURCE 3 (other with minor difference ? mistake) : http://www.dylanwilson.net/implementing-a-2d-camera-in-monogame

Matrix.CreateTranslation(new Vector3(-Origin, 0.0f)) *

SOUCRE 4 (visual explanation) : https://stevehazen.wordpress.com/2010/02/15/matrix-basics-how-to-step-away-from-storing-an-orientation-as-3-angles/

DISCUSSION 1 : http://gamedev.stackexchange.com/questions/59301/xna-2d-camera-scrolling-why-use-matrix-transform

DISCUSSION 2 : http://gamedev.stackexchange.com/questions/27433/how-do-i-make-the-viewport-move

DISCUSSION 3 : http://gamedev.stackexchange.com/questions/16177/xna-4-0-2d-camera-y-and-x-are-going-in-wrong-direction

This is the mistake: Matrix.CreateTranslation(_position.X, _position.Y, 0.0f)

Make it like this: Matrix.CreateTranslation(-_position.X, -_position.Y, 0.0f)

Explanation: The matrix specifies how the world should be transformed, not how the camera is transformed. Thats why you need to insert the negative values.

Leave a Reply

Your email address will not be published. Required fields are marked *