Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using source.core.engine;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace source.core.map
  10. {
  11. public class Camera
  12. {
  13. public Matrix Projection { get; private set; }
  14. public float Rotation { get; private set; }
  15.  
  16. Matrix _oblique;
  17. Matrix _orthographic;
  18. public Camera()
  19. {
  20. RecalculateProjection();
  21. }
  22.  
  23. void RecalculateProjection()
  24. {
  25. float x = 0;
  26. float y = (float)Math.Sin(Math.PI / 4 * -1); //45 degrees
  27. _oblique = new Matrix(
  28. -1, 0, 0, 0,
  29. 0, 1, 0, 0,
  30. x, y, 1, 0,
  31. 0, 0, 0, 1);
  32.  
  33. _orthographic = Matrix.CreateOrthographic(GameEngine.Width / 50, GameEngine.Height / 50, -1, 1000);
  34. RotateRelative(0.0f);
  35. }
  36.  
  37. void RotateRelative(float radians)
  38. {
  39. Rotation += radians;
  40. Projection = Matrix.CreateRotationZ(Rotation) * (_oblique * _orthographic);
  41. }
  42.  
  43. void Rotate(float radians)
  44. {
  45. Rotation = radians;
  46. Projection = Matrix.CreateRotationZ(Rotation) * (_oblique * _orthographic);
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement