Example #1
0
    // ----- Constructor: Set relevant scene node properties.
    public TextNode()
    {
      // The IsRenderable flag needs to be set to indicate that the scene node should 
      // be handled during rendering.
      IsRenderable = true;

      // The CastsShadows flag needs to be set if the scene node needs to be rendered 
      // into the shadow maps. But in this case the scene node should be ignored.
      CastsShadows = false;

      // A bounding shape needs to be set for frustum culling.
      Shape = new PointShape();
    }
Example #2
0
    // Creates a lot of random objects.
    private void CreateRandomObjects()
    {
      var random = new Random();

      var isFirstHeightField = true;

      int currentShape = 0;
      int numberOfObjects = 0;
      while (true)
      {
        numberOfObjects++;
        if (numberOfObjects > ObjectsPerType)
        {
          currentShape++;
          numberOfObjects = 0;
        }

        Shape shape;
        switch (currentShape)
        {
          case 0:
            // Box
            shape = new BoxShape(ObjectSize, ObjectSize * 2, ObjectSize * 3);
            break;
          case 1:
            // Capsule
            shape = new CapsuleShape(0.3f * ObjectSize, 2 * ObjectSize);
            break;
          case 2:
            // Cone
            shape = new ConeShape(1 * ObjectSize, 2 * ObjectSize);
            break;
          case 3:
            // Cylinder
            shape = new CylinderShape(0.4f * ObjectSize, 2 * ObjectSize);
            break;
          case 4:
            // Sphere
            shape = new SphereShape(ObjectSize);
            break;
          case 5:
            // Convex hull of several points.
            ConvexHullOfPoints hull = new ConvexHullOfPoints();
            hull.Points.Add(new Vector3F(-1 * ObjectSize, -2 * ObjectSize, -1 * ObjectSize));
            hull.Points.Add(new Vector3F(2 * ObjectSize, -1 * ObjectSize, -0.5f * ObjectSize));
            hull.Points.Add(new Vector3F(1 * ObjectSize, 2 * ObjectSize, 1 * ObjectSize));
            hull.Points.Add(new Vector3F(-1 * ObjectSize, 2 * ObjectSize, 1 * ObjectSize));
            hull.Points.Add(new Vector3F(-1 * ObjectSize, 0.7f * ObjectSize, -0.6f * ObjectSize));
            shape = hull;
            break;
          case 6:
            // A composite shape: two boxes that form a "T" shape.
            var composite = new CompositeShape();
            composite.Children.Add(
              new GeometricObject(
                new BoxShape(ObjectSize, 3 * ObjectSize, ObjectSize),
                new Pose(new Vector3F(0, 0, 0))));
            composite.Children.Add(
              new GeometricObject(
                new BoxShape(2 * ObjectSize, ObjectSize, ObjectSize),
                new Pose(new Vector3F(0, 2 * ObjectSize, 0))));
            shape = composite;
            break;
          case 7:
            shape = new CircleShape(ObjectSize);
            break;
          case 8:
            {
              var compBvh = new CompositeShape();
              compBvh.Children.Add(new GeometricObject(new BoxShape(0.5f, 1, 0.5f), new Pose(new Vector3F(0, 0.5f, 0), Matrix33F.Identity)));
              compBvh.Children.Add(new GeometricObject(new BoxShape(0.8f, 0.5f, 0.5f), new Pose(new Vector3F(0.5f, 0.7f, 0), Matrix33F.CreateRotationZ(-MathHelper.ToRadians(15)))));
              compBvh.Children.Add(new GeometricObject(new SphereShape(0.3f), new Pose(new Vector3F(0, 1.15f, 0), Matrix33F.Identity)));
              compBvh.Children.Add(new GeometricObject(new CapsuleShape(0.2f, 1), new Pose(new Vector3F(0.6f, 1.15f, 0), Matrix33F.CreateRotationX(0.3f))));
              compBvh.Partition = new AabbTree<int>();
              shape = compBvh;
              break;
            }
          case 9:
            CompositeShape comp = new CompositeShape();
            comp.Children.Add(new GeometricObject(new BoxShape(0.5f * ObjectSize, 1 * ObjectSize, 0.5f * ObjectSize), new Pose(new Vector3F(0, 0.5f * ObjectSize, 0), QuaternionF.Identity)));
            comp.Children.Add(new GeometricObject(new BoxShape(0.8f * ObjectSize, 0.5f * ObjectSize, 0.5f * ObjectSize), new Pose(new Vector3F(0.3f * ObjectSize, 0.7f * ObjectSize, 0), QuaternionF.CreateRotationZ(-MathHelper.ToRadians(45)))));
            comp.Children.Add(new GeometricObject(new SphereShape(0.3f * ObjectSize), new Pose(new Vector3F(0, 1.15f * ObjectSize, 0), QuaternionF.Identity)));
            shape = comp;
            break;
          case 10:
            shape = new ConvexHullOfPoints(new[]
            {
              new Vector3F(-1 * ObjectSize, -2 * ObjectSize, -1 * ObjectSize),
              new Vector3F(2 * ObjectSize, -1 * ObjectSize, -0.5f * ObjectSize),
              new Vector3F(1 * ObjectSize, 2 * ObjectSize, 1 * ObjectSize),
              new Vector3F(-1 * ObjectSize, 2 * ObjectSize, 1 * ObjectSize),
              new Vector3F(-1 * ObjectSize, 0.7f * ObjectSize, -0.6f * ObjectSize)
            });
            break;
          case 11:
            ConvexHullOfShapes shapeHull = new ConvexHullOfShapes();
            shapeHull.Children.Add(new GeometricObject(new SphereShape(0.3f * ObjectSize), new Pose(new Vector3F(0, 2 * ObjectSize, 0), Matrix33F.Identity)));
            shapeHull.Children.Add(new GeometricObject(new BoxShape(1 * ObjectSize, 2 * ObjectSize, 3 * ObjectSize), Pose.Identity));
            shape = shapeHull;
            break;
          case 12:
            shape = Shape.Empty;
            break;
          case 13:
            var numberOfSamplesX = 10;
            var numberOfSamplesZ = 10;
            var samples = new float[numberOfSamplesX * numberOfSamplesZ];
            for (int z = 0; z < numberOfSamplesZ; z++)
              for (int x = 0; x < numberOfSamplesX; x++)
                samples[z * numberOfSamplesX + x] = (float)(Math.Cos(z / 3f) * Math.Sin(x / 2f) * BoxSize / 6);
            HeightField heightField = new HeightField(0, 0, 2 * BoxSize, 2 * BoxSize, samples, numberOfSamplesX, numberOfSamplesZ);
            shape = heightField;
            break;
          //case 14:
          //shape = new LineShape(new Vector3F(0.1f, 0.2f, 0.3f), new Vector3F(0.1f, 0.2f, -0.3f).Normalized);
          //break;            
          case 15:
            shape = new LineSegmentShape(
              new Vector3F(0.1f, 0.2f, 0.3f), new Vector3F(0.1f, 0.2f, 0.3f) + 3 * ObjectSize * new Vector3F(0.1f, 0.2f, -0.3f));
            break;
          case 16:
            shape = new MinkowskiDifferenceShape
            {
              ObjectA = new GeometricObject(new SphereShape(0.1f * ObjectSize)),
              ObjectB = new GeometricObject(new BoxShape(1 * ObjectSize, 2 * ObjectSize, 3 * ObjectSize))
            };
            break;
          case 17:
            shape = new MinkowskiSumShape
            {
              ObjectA = new GeometricObject(new SphereShape(0.1f * ObjectSize)),
              ObjectB = new GeometricObject(new BoxShape(1 * ObjectSize, 2 * ObjectSize, 3 * ObjectSize)),
            };
            break;
          case 18:
            shape = new OrthographicViewVolume(0, ObjectSize, 0, ObjectSize, ObjectSize / 2, ObjectSize * 2);
            break;
          case 19:
            shape = new PerspectiveViewVolume(MathHelper.ToRadians(60f), 16f / 10, ObjectSize / 2, ObjectSize * 3);
            break;
          case 20:
            shape = new PointShape(0.1f, 0.3f, 0.2f);
            break;
          case 21:
            shape = new RayShape(new Vector3F(0.2f, 0, -0.12f), new Vector3F(1, 2, 3).Normalized, ObjectSize * 2);
            break;
          case 22:
            shape = new RayShape(new Vector3F(0.2f, 0, -0.12f), new Vector3F(1, 2, 3).Normalized, ObjectSize * 2)
            {
              StopsAtFirstHit = true
            };
            break;
          case 23:
            shape = new RectangleShape(ObjectSize, ObjectSize * 2);
            break;
          case 24:
            shape = new TransformedShape(
              new GeometricObject(
                new BoxShape(1 * ObjectSize, 2 * ObjectSize, 3 * ObjectSize),
                new Pose(new Vector3F(0.1f, 1, -0.2f))));
            break;
          case 25:
            shape = new TriangleShape(
              new Vector3F(ObjectSize, 0, 0), new Vector3F(0, ObjectSize, 0), new Vector3F(ObjectSize, ObjectSize, ObjectSize));
            break;
          //case 26:
          //  {
          //    // Create a composite object from which we get the mesh.
          //    CompositeShape compBvh = new CompositeShape();
          //    compBvh.Children.Add(new GeometricObject(new BoxShape(0.5f, 1, 0.5f), new Pose(new Vector3F(0, 0.5f, 0), Matrix33F.Identity)));
          //    compBvh.Children.Add(
          //      new GeometricObject(
          //        new BoxShape(0.8f, 0.5f, 0.5f),
          //        new Pose(new Vector3F(0.5f, 0.7f, 0), Matrix33F.CreateRotationZ(-(float)MathHelper.ToRadians(15)))));
          //    compBvh.Children.Add(new GeometricObject(new SphereShape(0.3f), new Pose(new Vector3F(0, 1.15f, 0), Matrix33F.Identity)));
          //    compBvh.Children.Add(
          //      new GeometricObject(new CapsuleShape(0.2f, 1), new Pose(new Vector3F(0.6f, 1.15f, 0), Matrix33F.CreateRotationX(0.3f))));

          //    TriangleMeshShape meshBvhShape = new TriangleMeshShape { Mesh = compBvh.GetMesh(0.01f, 3) };
          //    meshBvhShape.Partition = new AabbTree<int>();
          //    shape = meshBvhShape;
          //    break;
          //  }
          //case 27:
          //  {
          //    // Create a composite object from which we get the mesh.
          //    CompositeShape compBvh = new CompositeShape();
          //    compBvh.Children.Add(new GeometricObject(new BoxShape(0.5f, 1, 0.5f), new Pose(new Vector3F(0, 0.5f, 0), QuaternionF.Identity)));
          //    compBvh.Children.Add(
          //      new GeometricObject(
          //        new BoxShape(0.8f, 0.5f, 0.5f),
          //        new Pose(new Vector3F(0.5f, 0.7f, 0), QuaternionF.CreateRotationZ(-(float)MathHelper.ToRadians(15)))));
          //    compBvh.Children.Add(new GeometricObject(new SphereShape(0.3f), new Pose(new Vector3F(0, 1.15f, 0), QuaternionF.Identity)));
          //    compBvh.Children.Add(
          //      new GeometricObject(new CapsuleShape(0.2f, 1), new Pose(new Vector3F(0.6f, 1.15f, 0), QuaternionF.CreateRotationX(0.3f))));

          //    TriangleMeshShape meshBvhShape = new TriangleMeshShape { Mesh = compBvh.GetMesh(0.01f, 3) };
          //    meshBvhShape.Partition = new AabbTree<int>();
          //    shape = meshBvhShape;
          //    break;
          //  }
          case 28:
            shape = new ConvexPolyhedron(new[]
            {
              new Vector3F(-1 * ObjectSize, -2 * ObjectSize, -1 * ObjectSize),
              new Vector3F(2 * ObjectSize, -1 * ObjectSize, -0.5f * ObjectSize),
              new Vector3F(1 * ObjectSize, 2 * ObjectSize, 1 * ObjectSize),
              new Vector3F(-1 * ObjectSize, 2 * ObjectSize, 1 * ObjectSize),
              new Vector3F(-1 * ObjectSize, 0.7f * ObjectSize, -0.6f * ObjectSize)
            });
            break;
          case 29:
            return;
          default:
            currentShape++;
            continue;
        }

        // Create an object with the random shape, pose, color and velocity.
        Pose randomPose = new Pose(
          random.NextVector3F(-BoxSize + ObjectSize * 2, BoxSize - ObjectSize * 2),
          random.NextQuaternionF());
        var newObject = new MovingGeometricObject
        {
          Pose = randomPose,
          Shape = shape,
          LinearVelocity = random.NextQuaternionF().Rotate(new Vector3F(MaxLinearVelocity, 0, 0)),
          AngularVelocity = random.NextQuaternionF().Rotate(Vector3F.Forward)
                            * RandomHelper.Random.NextFloat(0, MaxAngularVelocity),
        };

        if (RandomHelper.Random.NextBool())
          newObject.LinearVelocity = Vector3F.Zero;
        if (RandomHelper.Random.NextBool())
          newObject.AngularVelocity = Vector3F.Zero;

        if (shape is LineShape || shape is HeightField)
        {
          // Do not move lines or the height field.
          newObject.LinearVelocity = Vector3F.Zero;
          newObject.AngularVelocity = Vector3F.Zero;
        }

        // Create only 1 heightField!
        if (shape is HeightField)
        {
          if (isFirstHeightField)
          {
            isFirstHeightField = true;
            newObject.Pose = new Pose(new Vector3F(-BoxSize, -BoxSize, -BoxSize));
          }
          else
          {
            currentShape++;
            numberOfObjects = 0;
            continue;
          }
        }

        // Add collision object to collision domain.
        _domain.CollisionObjects.Add(new CollisionObject(newObject));

        //co.Type = CollisionObjectType.Trigger;
        //co.Name = "Object" + shape.GetType().Name + "_" + i;
      }
    }
        public void PerspectiveOffCenterTest()
        {
            Vector3F position = new Vector3F(1, 2, 3);
              QuaternionF orientation = QuaternionF.CreateRotation(new Vector3F(2, 3, 6), 0.123f);
              CameraInstance cameraInstance = new CameraInstance(new Camera(new PerspectiveProjection()))
              {
            PoseLocal = new Pose(position, orientation),
              };
              ((PerspectiveProjection)cameraInstance.Camera.Projection).SetOffCenter(1, 5, 2, 5, 1, 10);

              Matrix44F projection = Matrix44F.CreatePerspectiveOffCenter(1, 5, 2, 5, 1, 10);
              Assert.AreEqual(position, cameraInstance.PoseWorld.Position);
              Assert.AreEqual(orientation.ToRotationMatrix33(), cameraInstance.PoseWorld.Orientation);
              Assert.IsTrue(Numeric.AreEqual(MathHelper.ToRadians(33.690067f), cameraInstance.Camera.Projection.FieldOfViewX));
              Assert.IsTrue(Numeric.AreEqual(MathHelper.ToRadians(15.255119f), cameraInstance.Camera.Projection.FieldOfViewY));
              Assert.AreEqual(4.0f / 3.0f, cameraInstance.Camera.Projection.AspectRatio);
              Assert.AreEqual(4, cameraInstance.Camera.Projection.Width);
              Assert.AreEqual(3, cameraInstance.Camera.Projection.Height);
              Assert.AreEqual(1, cameraInstance.Camera.Projection.Left);
              Assert.AreEqual(5, cameraInstance.Camera.Projection.Right);
              Assert.AreEqual(2, cameraInstance.Camera.Projection.Bottom);
              Assert.AreEqual(5, cameraInstance.Camera.Projection.Top);
              Assert.AreEqual(1, cameraInstance.Camera.Projection.Near);
              Assert.AreEqual(10, cameraInstance.Camera.Projection.Far);
              Assert.AreEqual(9, cameraInstance.Camera.Projection.Depth);
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(projection, cameraInstance.Camera.Projection));
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(projection.Inverse, cameraInstance.Camera.Projection.Inverse));
              Assert.IsNotNull(cameraInstance.BoundingShape);

              // Test shape using collision detection. Remove rotation to simplify test.
              cameraInstance.PoseWorld = new Pose(cameraInstance.PoseWorld.Position);
              CollisionDetection collisionDetection = new CollisionDetection();
              var point = new PointShape();
              CollisionObject pointCollisionObject = new CollisionObject(new GeometricObject(point));
              CollisionObject cameraCollisionObject = new CollisionObject(cameraInstance);

              point.Position = position + new Vector3F(3, 3, -1);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(30, 30, -10);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(3, 3, -0.9f);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(30, 30, -10.1f);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));

              point.Position = position + new Vector3F(1, 2, -1);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(0.9f, 2, -1);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(1, 1.9f, -1);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(5, 5, -1);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(5.1f, 5, -1);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(5, 5.1f, -1);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));

              point.Position = position + new Vector3F(10, 20, -10);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(9.9f, 20, -10);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(10, 19.9f, -10);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(50, 50, -10);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(50.1f, 50, -10);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(50, 50.1f, -10);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
        }
        public void OrthographicTest()
        {
            Vector3F position = new Vector3F(1, 2, 3);
              QuaternionF orientation = QuaternionF.CreateRotation(new Vector3F(2, 3, 6), 0.123f);
              CameraInstance cameraInstance = new CameraInstance(new Camera(new OrthographicProjection()))
              {
            PoseLocal = new Pose(position, orientation),
              };

              ((OrthographicProjection)cameraInstance.Camera.Projection).Set(4, 3, 2, 10);
              Matrix44F projection = Matrix44F.CreateOrthographic(4, 3, 2, 10);
              Assert.AreEqual(position, cameraInstance.PoseWorld.Position);
              Assert.AreEqual(orientation.ToRotationMatrix33(), cameraInstance.PoseWorld.Orientation);
              Assert.AreEqual(4, cameraInstance.Camera.Projection.Width);
              Assert.AreEqual(3, cameraInstance.Camera.Projection.Height);
              Assert.AreEqual(4.0f / 3.0f, cameraInstance.Camera.Projection.AspectRatio);
              Assert.AreEqual(2, cameraInstance.Camera.Projection.Near);
              Assert.AreEqual(10, cameraInstance.Camera.Projection.Far);
              Assert.AreEqual(-2, cameraInstance.Camera.Projection.Left);
              Assert.AreEqual(2, cameraInstance.Camera.Projection.Right);
              Assert.AreEqual(-1.5f, cameraInstance.Camera.Projection.Bottom);
              Assert.AreEqual(1.5f, cameraInstance.Camera.Projection.Top);
              Assert.AreEqual(8, cameraInstance.Camera.Projection.Depth);
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(projection, cameraInstance.Camera.Projection));
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(projection.Inverse, cameraInstance.Camera.Projection.Inverse));
              Assert.IsNotNull(cameraInstance.BoundingShape);

              // Test shape using collision detection. Remove rotation to simplify test.
              cameraInstance.PoseWorld = new Pose(cameraInstance.PoseWorld.Position);
              CollisionDetection collisionDetection = new CollisionDetection();
              var point = new PointShape();
              CollisionObject pointCollisionObject = new CollisionObject(new GeometricObject(point));
              CollisionObject cameraCollisionObject = new CollisionObject(cameraInstance);

              point.Position = position + new Vector3F(-2, -1.5f, -2);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(-2.1f, -1.6f, -1.9f);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(2, 1.5f, -10);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(2.1f, 1.6f, -10.1f);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));

              cameraInstance.PoseWorld = new Pose(position, orientation);
              ((OrthographicProjection)cameraInstance.Camera.Projection).Set(8, 4, 1, 100);
              cameraInstance.Camera.Projection.Near = 1;
              cameraInstance.Camera.Projection.Far = 100;
              projection = Matrix44F.CreateOrthographic(8, 4, 1, 100);
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(projection.Inverse, cameraInstance.Camera.Projection.Inverse));
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(projection, cameraInstance.Camera.Projection));

              // Test shape using collision detection. Remove rotation to simplify test.
              cameraInstance.PoseWorld = new Pose(cameraInstance.PoseWorld.Position);
              point.Position = position + new Vector3F(-4, -2f, -1);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(-4.1f, -1.9f, -0.9f);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(4, 2f, -100);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(4.1f, 2.1f, -100.1f);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
        }
        public void PerspectiveTest()
        {
            Vector3F position = new Vector3F(1, 2, 3);
              QuaternionF orientation = QuaternionF.CreateRotation(new Vector3F(2, 3, 6), 0.123f);
              CameraInstance cameraInstance = new CameraInstance(new Camera(new PerspectiveProjection()))
              {
            PoseLocal = new Pose(position, orientation),
              };

              ((PerspectiveProjection)cameraInstance.Camera.Projection).SetFieldOfView(MathHelper.ToRadians(60), 16.0f / 10.0f, 1, 10);
              Matrix44F projection = Matrix44F.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60), 16.0f / 10.0f, 1, 10);
              Assert.AreEqual(position, cameraInstance.PoseWorld.Position);
              Assert.AreEqual(orientation.ToRotationMatrix33(), cameraInstance.PoseWorld.Orientation);
              Assert.AreEqual(MathHelper.ToRadians(60), cameraInstance.Camera.Projection.FieldOfViewY);
              Assert.IsTrue(Numeric.AreEqual(MathHelper.ToRadians(85.4601055f), cameraInstance.Camera.Projection.FieldOfViewX));
              Assert.AreEqual(16.0f / 10.0f, cameraInstance.Camera.Projection.AspectRatio);
              Assert.IsTrue(Numeric.AreEqual(1.8475209f, cameraInstance.Camera.Projection.Width));
              Assert.IsTrue(Numeric.AreEqual(1.1547005f, cameraInstance.Camera.Projection.Height));
              Assert.AreEqual(1, cameraInstance.Camera.Projection.Near);
              Assert.AreEqual(10, cameraInstance.Camera.Projection.Far);
              Assert.IsTrue(Numeric.AreEqual(-0.9237604f, cameraInstance.Camera.Projection.Left));
              Assert.IsTrue(Numeric.AreEqual(0.9237604f, cameraInstance.Camera.Projection.Right));
              Assert.IsTrue(Numeric.AreEqual(-0.5773503f, cameraInstance.Camera.Projection.Bottom));
              Assert.IsTrue(Numeric.AreEqual(0.5773503f, cameraInstance.Camera.Projection.Top));
              Assert.AreEqual(9, cameraInstance.Camera.Projection.Depth);
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(projection, cameraInstance.Camera.Projection));
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(projection.Inverse, cameraInstance.Camera.Projection.Inverse));
              Assert.IsNotNull(cameraInstance.BoundingShape);

              // Test shape using collision detection. Remove rotation to simplify test.
              cameraInstance.PoseWorld = new Pose(cameraInstance.PoseWorld.Position);
              CollisionDetection collisionDetection = new CollisionDetection();
              var point = new PointShape();
              CollisionObject pointCollisionObject = new CollisionObject(new GeometricObject(point));
              CollisionObject cameraCollisionObject = new CollisionObject(cameraInstance);

              point.Position = position + new Vector3F(0, 0, -1);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(0, 0, -10);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(0, 0, -0.9f);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(0, 0, -10.1f);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));

              point.Position = position + new Vector3F(-0.9237604f, -0.5773f, -1);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(-0.924f, -0.5773f, -1);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(-0.9237604f, -0.58f, -1);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(0.9237604f, 0.5773f, -1);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(0.924f, 0.5773f, -1);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(0.9237604f, 0.58f, -1);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));

              point.Position = position + new Vector3F(-9.237604f, -5.773f, -10);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(-9.24f, -5.773f, -10);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(-9.237604f, -5.8f, -10);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(9.237604f, 5.773f, -10);
              Assert.IsTrue(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(9.24f, 5.773f, -10);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
              point.Position = position + new Vector3F(9.237604f, 5.8f, -10);
              Assert.IsFalse(collisionDetection.HaveContact(pointCollisionObject, cameraCollisionObject));
        }