FerretEngine/src/Graphics/Camera.cs
/// <summary>
/// Calculates the screenRect based on where the camera currently is.
/// </summary>
Calculates the screenRect based on where the camera currently is.
Calculates the screenRect based on where the camera currently is .
private Rectangle VisibleArea()
        {
            Matrix inverseViewMatrix = Matrix.Invert(TransformMatrix);
            Vector2 tl = Vector2.Transform(Vector2.Zero, inverseViewMatrix);
            Vector2 tr = Vector2.Transform(new Vector2(FeGraphics.Resolution.VirtualWidth, 0), inverseViewMatrix);
            Vector2 bl = Vector2.Transform(new Vector2(0, FeGraphics.Resolution.VirtualHeight), inverseViewMatrix);
            Vector2 br = Vector2.Transform(new Vector2(FeGraphics.Resolution.VirtualWidth, FeGraphics.Resolution.VirtualHeight), inverseViewMatrix);
            Vector2 min = new Vector2(
                MathHelper.Min(tl.X, MathHelper.Min(tr.X, MathHelper.Min(bl.X, br.X))),
                MathHelper.Min(tl.Y, MathHelper.Min(tr.Y, MathHelper.Min(bl.Y, br.Y))));
            Vector2 max = new Vector2(
                MathHelper.Max(tl.X, MathHelper.Max(tr.X, MathHelper.Max(bl.X, br.X))),
                MathHelper.Max(tl.Y, MathHelper.Max(tr.Y, MathHelper.Max(bl.Y, br.Y))));
            return new Rectangle((int)min.X, (int)min.Y, (int)(FeGraphics.Resolution.VirtualWidth / Zoom), (int)(FeGraphics.Resolution.VirtualHeight / Zoom));
        }
private Rectangle VisibleArea ( ) { Matrix inverseViewMatrix = Matrix . Invert ( TransformMatrix ) ; Vector2 tl = Vector2 . Transform ( Vector2 . Zero , inverseViewMatrix ) ; Vector2 tr = Vector2 . Transform ( new Vector2 ( FeGraphics . Resolution . VirtualWidth , 0 ) , inverseViewMatrix ) ; Vector2 bl = Vector2 . Transform ( new Vector2 ( 0 , FeGraphics . Resolution . VirtualHeight ) , inverseViewMatrix ) ; Vector2 br = Vector2 . Transform ( new Vector2 ( FeGraphics . Resolution . VirtualWidth , FeGraphics . Resolution . VirtualHeight ) , inverseViewMatrix ) ; Vector2 min = new Vector2 ( MathHelper . Min ( tl . X , MathHelper . Min ( tr . X , MathHelper . Min ( bl . X , br . X ) ) ) , MathHelper . Min ( tl . Y , MathHelper . Min ( tr . Y , MathHelper . Min ( bl . Y , br . Y ) ) ) ) ; Vector2 max = new Vector2 ( MathHelper . Max ( tl . X , MathHelper . Max ( tr . X , MathHelper . Max ( bl . X , br . X ) ) ) , MathHelper . Max ( tl . Y , MathHelper . Max ( tr . Y , MathHelper . Max ( bl . Y , br . Y ) ) ) ) ; return new Rectangle ( ( int ) min . X , ( int ) min . Y , ( int ) ( FeGraphics . Resolution . VirtualWidth / Zoom ) , ( int ) ( FeGraphics . Resolution . VirtualHeight / Zoom ) ) ; }
Calculates the screenRect based on where the camera currently is.
Calculates the screenRect based on where the camera currently is .