public void IfCameraNotAdjustedItBehavesIdenticallyToQuadraticScreenSpace() { var q = new QuadraticScreenSpace(window); var c = new Camera2DScreenSpace(window); Assert.IsTrue( c.FromPixelSpace(new Vector2D(1, 2)).IsNearlyEqual(q.FromPixelSpace(new Vector2D(1, 2)))); Assert.IsTrue( c.FromPixelSpace(new Size(-3, 4)).IsNearlyEqual(q.FromPixelSpace(new Size(-3, 4)))); Assert.IsTrue( c.ToPixelSpace(new Vector2D(2, 6)).IsNearlyEqual(q.ToPixelSpace(new Vector2D(2, 6)))); Assert.IsTrue(c.ToPixelSpace(new Size(-2, 0)).IsNearlyEqual(q.ToPixelSpace(new Size(-2, 0)))); }
public void ToPixelSpace() { var quadraticSize = new Size(window.ViewportPixelSize.Width); var camera = new Camera2DScreenSpace(window) { LookAt = new Vector2D(-0.5f, 0.6f), Zoom = 2.0f }; Assert.AreEqual(quadraticSize.Width * 1.5f, camera.ToPixelSpace(Vector2D.Zero).X); Assert.IsTrue(camera.ToPixelSpace(Vector2D.Half).IsNearlyEqual(new Vector2D(800, 26))); Assert.IsTrue(camera.ToPixelSpace(Vector2D.One).IsNearlyEqual(new Vector2D(1120, 346))); Assert.AreEqual(quadraticSize, camera.ToPixelSpace(Size.Half)); }
public void ToPixelSpaceWithRotation() { var quadraticSize = new Size(window.ViewportPixelSize.Width); var camera = new Camera2DScreenSpace(window) { Rotation = 90.0f }; Assert.AreEqual(0.0f, camera.ToPixelSpace(Vector2D.Zero).X); Assert.IsTrue(camera.ToPixelSpace(Vector2D.Half).IsNearlyEqual(new Vector2D(-160.0f, 90.0f))); Assert.IsTrue( camera.ToPixelSpace(Vector2D.One).IsNearlyEqual(new Vector2D(-320.0f, (160.0f + 90.0f)))); Assert.AreEqual(quadraticSize, camera.ToPixelSpace(Size.One)); }
public void LoopingToAndFromPixelSpaceLeavesAPointUnchanged() { var camera = new Camera2DScreenSpace(window) { LookAt = new Vector2D(-0.5f, 0.6f), Zoom = 3.0f }; Assert.IsTrue( camera.ToPixelSpace(camera.FromPixelSpace(new Vector2D(1.2f, 3.4f))).IsNearlyEqual( new Vector2D(1.2f, 3.4f))); Assert.IsTrue( camera.FromPixelSpace(camera.ToPixelSpace(new Vector2D(1.2f, 3.4f))).IsNearlyEqual( new Vector2D(1.2f, 3.4f))); }