I have a 2d Camera with this translation matrix:
Transform = Matrix.CreateTranslation(new Vector3(-Position.X, -Position.Y, 0)) *
Matrix.CreateRotationZ(Rotation) *
Matrix.CreateScale(new Vector3(Scale, Scale, 0)) *
Matrix.CreateTranslation(new Vector3((GraphicsDevice.Viewport.Width * 0.5f), (GraphicsDevice.Viewport.Height * 0.5f), 0));
Which works for Rotation/Zoom where the origin is the center of the camera.
Now I am trying to get the mouse coordinates in the world.
I tried just using an inverse transformation, but that just resulted in NaN errors. I am guessing I need to set up another translation matrix for the mouse coordinates, a reverse of the current one, but I can't figure out how this is set up
I have this,
MousePosition = new Vector2((Mouse.GetState().X - DrawTransform.Translation.X) * (1 / Gamecode.Camera1.Scale), (Mouse.GetState().Y - DrawTransform.Translation.Y) * (1 / Gamecode.Camera1.Scale));
But that doesn't take into account rotation