1
\$\begingroup\$

I'm trying to create a camera using matrix transforms, the gist is as follows:

Transform =
     Matrix.CreateRotationZ(Rotation) *
     Matrix.CreateTranslation(new Vector3(-Position.X, -Position.Y, 0)) *
     Matrix.CreateScale(Zoom) *
     Matrix.CreateTranslation(new Vector3(Bounds.Width * 0.5f, Bounds.Height * 0.5f, 0));

It works but with one issue. The rotation origin remains at the starting (-Position.X, -Position.Y) while the zoom works fine (at the center screen) which is obvious from the code. I'd like the rotation to occur at the center screen as well.

\$\endgroup\$
2
  • \$\begingroup\$ Hey Avagantamo, could you provide more code? Because currently, it's not sure what values the Rotation, Position, Zoom and Bounds are. \$\endgroup\$
    – Steven
    Nov 17 '20 at 7:26
  • \$\begingroup\$ Hi @Steven . The code is from this link community.monogame.net/t/simple-2d-camera/9135 with an extra property (Rotation) similar to how the Zoom works in it. The above code is an altered version from the UpdateMatrix() method for including the rotation \$\endgroup\$
    – Avagantamo
    Nov 17 '20 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.