Sign in to follow this  

[XNA] Getting the origin at the bottom left of the screen

This topic is 2809 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

Hi guys I decided to check out XNA and I was going through the tutorials, but one thing I cannot figure out is how to change the origin of my coordinate system on my window from top left to bottom left. So I want, relative to the window, x positive going right y positive going up I dont mind the direction of z How do I modify the code here to do this: http://msdn.microsoft.com/en-us/library/bb196414.aspx does it have something to do with this? :
viewMatrix = Matrix.CreateLookAt(
    new Vector3(0.0f, 0.0f, 1.0f),
    Vector3.Zero,
    Vector3.Up
    );

projectionMatrix = Matrix.CreateOrthographicOffCenter(
    0,
    (float)GraphicsDevice.Viewport.Width,
    (float)GraphicsDevice.Viewport.Height,
    0,
    1.0f, 1000.0f);
Thanks for all the help in advance

Share this post


Link to post
Share on other sites
Is there a reason why you need this? I think it is hardcoded into the viewport to have the origin at top left. It would be simple to have a method that sets the position of objects based on the lower left corner though.

If you have an object at (50, 50) relative to a bottom left origin and your viewport is 800 x 600 then all you have to do is set the position as (50, ViewPort.Height - 50). If you make a nice function to do this it should be easy enough to use.

Before you go doing that though I'd really examine why you need to do it and would it be easier to just change your coordinate system to match XNAs default.

Share this post


Link to post
Share on other sites

This topic is 2809 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this