Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using source.core.engine;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace source.core.map
- {
- public class Camera
- {
- public Matrix Projection { get; private set; }
- public float Rotation { get; private set; }
- Matrix _oblique;
- Matrix _orthographic;
- public Camera()
- {
- RecalculateProjection();
- }
- void RecalculateProjection()
- {
- float x = 0;
- float y = (float)Math.Sin(Math.PI / 4 * -1); //45 degrees
- _oblique = new Matrix(
- -1, 0, 0, 0,
- 0, 1, 0, 0,
- x, y, 1, 0,
- 0, 0, 0, 1);
- _orthographic = Matrix.CreateOrthographic(GameEngine.Width / 50, GameEngine.Height / 50, -1, 1000);
- RotateRelative(0.0f);
- }
- void RotateRelative(float radians)
- {
- Rotation += radians;
- Projection = Matrix.CreateRotationZ(Rotation) * (_oblique * _orthographic);
- }
- void Rotate(float radians)
- {
- Rotation = radians;
- Projection = Matrix.CreateRotationZ(Rotation) * (_oblique * _orthographic);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement