Ejemplo n.º 1
0
    public void TestLookAtFromWorldCenter() {
      Camera testCamera = new Camera(Matrix.Identity, Matrix.Identity);

      testCamera.LookAt(Vector3.UnitX); // Look to the right

      Vector3 leftPoint = -Vector3.UnitX;

      Vector3 transformed = Vector3.Transform(leftPoint, testCamera.View);

      // The point should be behind the camera
      Assert.Greater(transformed.Z, 0.0f);
    }
Ejemplo n.º 2
0
    public void TestLookAtFromArbitraryPosition() {
      Camera testCamera = new Camera(Matrix.Identity, Matrix.Identity);

      testCamera.MoveTo(new Vector3(100.0f, 200.0f, 300.0f));
      testCamera.LookAt(Vector3.Zero); // Look to the right

      Vector3 leftPoint = new Vector3(99.0f, 200.0f, 300.0f);
      Vector3 behindPoint = new Vector3(100.0f, 200.0f, 299.0f);

      Vector3 transformedLeft = Vector3.Transform(leftPoint, testCamera.View);
      Vector3 transformedBehind = Vector3.Transform(behindPoint, testCamera.View);

      // The left point should be in front of the camera
      Assert.Less(transformedLeft.Z, 0.0f);
      // The behind point should be right of the camera
      Assert.Greater(transformedBehind.X, 0.0f);
    }